MySQL数据库基础练习题

MySQL数据库基础练习题_第1张图片

1.create table student(id char() primary key not null,name char(),come_from char(),math_scores int());

2.insert into student(id, name, from, math_scores) values (200604,'王五','山东',89)

3. delete from student1 where name like '%海%';    # 删除名字中有海字的信息

4.select count(*) from student1 where come_from='山东';    # 汇总是山东的同学数量

5.select * from student1 order by math_scores desc;    # 按成绩升序

6.alter table student1 add phone varchar(20);    # 增加列

7.select id,name from student1 limit 3;    # 查询前三行数据

8.update student1 set math_scores=math_scores+10 where math_scores<60;    # 为成绩低于60分的同学增加10分  也可以用于更新数据

9.create unique index student_id_idx on student(id[ASC]);  # 建立唯一索引的列上不能有重复的值,即该列要满足not null和unique约束,默认是升序,降序则写[DESC]

10.drop table student1;    # 删除表

11.alter table student2 drop column home;    # 删除列


 

你可能感兴趣的:(数据库,mysql,sql)