管理数据库对象
一、索引
1.作用:加快查询速度
2.创建
(1)创建表的同时
create table teacher
(tno char(4),
tname char(20),
index ix_tno(tno));
(2)表已经存在,创建索引
create index ix_sno on student(sno asc);
3.删除
drop index ix_tno on teacher;
4.查看
show index from teacher;
二、视图
1.定义:是从一个或者多个基本表或视图导出的虚表
2.作用
3.创建
create view boy
as
select *
from student
where ssex = ‘男’;
4.修改
alter view boy
as
select *
from student
where ssex = ‘男’
with check option;
create view cjb
as
select student.sno,sname,course.cno,cname,grade
from student join sc on student.sno = sc.sno
join course
on course.cno = sc.cno;
利用视图cjb,查找刘晨的姓名,课程号,课程名以及成绩
select sname,cno,cname,grade
from cjb
where sname=‘刘晨’;
5.查看
查看结构:desc boy;
查看内容:select语句
6.删除
三、存储过程
四、触发器