0328课上练习

 

 

 

 1 #创建表的语句
 2 create table student(
 3     id TINYINT(3) not null auto_increment primary key,
 4     `name` varchar(10),
 5     sex tinyint(2) default 2,
 6     phone varchar(11),
 7     role tinyint(2),
 8     score int(4)
 9 );
10 #添加数据
11 insert into student values (DEFAULT,'zhangsan',DEFAULT,'13837689458',1,54);
12 insert into student values (DEFAULT,'lisi',DEFAULT,'18537689458',2,90);
13 insert into student values (DEFAULT,'wangwu',1,'15937689458',3,94);
14 insert into student values (DEFAULT,'zhaoliu',DEFAULT,'13037689458',3,82);
15 #查询所有
16 select * from student;
17 #修改电话号码
18 update student set phone='18030207676'
19 where `name`='lisi';
20 #查询成绩不合格的学生
21 select `name` 姓名,score 成绩 from student
22 where score>=60;
23 #查询星密是z开头的人的数据
24 select * from student
25 where `name` like 'z%';
26 #查询role为1和3的数据
27 select id,name 姓名,sex 性别,phone 电话,role,score 成绩
28 from student
29 where role in (1,3);
30 #删除role为1的数据
31 delete from student
32 where role=1;
33 #清空这个表
34 truncate student;

 

posted @ 2019-03-28 09:05  纯属丶简单  阅读(103)  评论(0编辑  收藏  举报