索引
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;