1.创创建数据库
create database python_test_1 charset=utf8;
use python_test_1;
mysql> create table students(
-> id int unsigned primary key auto_increment not null,
-> name varchar(20) default '',
-> age tinyint unsigned default 0,
-> height decimal(5,2),
-> gender enum('男','女','中性','保密') default '保密',
-> cls_id int unsigned default 0,
-> is_delete bit default 0);
mysql> create table classes(
-> id int unsigned auto_increment primary key not null,
-> name varchar(30) not null);
mysql> insert into students
-> values
-> (0,'小明',18,180.00,2,1,0),
-> (0,'小月月',18,180.00,2,1,1),
-> (0,'彭于晏',29,185.00,1,1,0),
-> (0,'刘德华',59,185.00,1,1,0),
-> (0,'黄蓉',38,160.00,2,1,0),
-> (0,'凤姐','28',150.00,4,2,1),
-> (0,'王祖贤',18,172.00,2,1,1),
-> (0,'周杰伦',36,NULL,1,1,0),
-> (0,'程坤',27,181.00,1,2,0),
-> (0,'刘亦菲',25,166.00,2,2,0),
-> (0,'金星',33,162.00,3,3,1),
-> (0,'静香',12,180.00,2,4,0),
-> (0,'郭靖',12,170.00,1,4,0),
-> (0,'周杰',34,176.00,2,5,0);
如图所示:
查询表中的数据
查看表结构
4.2向classes表中插入数据
mysql> insert into classes
-> values
-> (0,'python_01期'),
-> (0,'python_02期');