-
新建数据库
-
新建表
-
student表
2.course表
3.sc表
-
修改Student 表中年龄(sage)字段属性,数据类型由int 改变为smallint
alter table student modify sage smallint;
-
为Course表中Cno 课程号字段设置索引,并查看索引
create index index_cno on course(cno); 设置索引
show table course\G 查看索引
-
设置索引
-
查看索引
-
为SC表建立按学号(sno)和课程号(cno)组合的升序的主键索引,索引名为SC_INDEX
create index index_SCINDEX on sc(sno,cno asc); 设置索引
show create table sc\G 查看索引
-
设置索引
-
查看索引
-
创建一视图 stu_info,查询全体学生的姓名,性别,课程名,成绩
create view stu_info as select student.*, score from student join sc on student.sno = sc.sno;
-
删除所有索引
drop index index_cno on course;
drop index index_SCINDEX on sc;