1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| drop table t_student;
create table t_student( sno int(6) primary key auto_increment, sname varchar(5) not null, sex char(1) default '男' check(sex='男' || sex='女'), age int(3) check(age>=18 and age<=50), enterdate date, classname varchar(10), email varchar(15) unique );
insert into t_student values (null,'张三','男',21,'2023-9-1','java01班','zs@126.com'); insert into t_student values (null,'李四','男',21,'2023-9-1','java01班','ls@126.com'); insert into t_student values (null,'露露','男',21,'2023-9-1','java01班','ll@126.com');
select * from t_student;
create table t_student2 as select * from t_student; select * from t_student2;
create table t_student3 as select * from t_student where 1=2; select * from t_student3;
create table t_student4 as select sno,sname,age from t_student where sno = 2;
select * from t_student4;
delete from t_student; truncate table t_student;
|