索引
1.作用:提升查询效率
-
创建索引
create index 索引名 on 表名(字段名)
create index index_student_sid on student(sid);
- 删除索引
drop index 索引名
2.特点:
- 显示的创建,隐式的执行
- oracle新建表会将该表的主键自动创建索引
视图
1.创建视图
create or replace view 视图名 as 查询语句(对外提供的内容) from 真实表名
视图名映射了一个查询语句
create or replace view stu as select sid 学号,sname 姓名 from student;
2.删除视图 drop view 视图名
drop view stu;
3.视图的特点
- 保护真实表,隐藏核心字段的数据
- 在视图中的操作会映射执行到真实表中
- 可以收到开启视图只读模式 使用关键字 with read only
create or replace view stu2 as select sid,sname from student with read only;