索引與視圖

索引

1.作用:提升查詢效率

  1. 創建索引

    create index 索引名 on 表名(字段名)

create index index_student_sid on student(sid);
  1. 刪除索引
    drop index 索引名

2.特點:

  1. 顯示的創建,隱式的執行
  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.視圖的特點

  1. 保護真實表,隱藏核心字段的數據
  2. 在視圖中的操作會映射執行到真實表中
  3. 可以收到開啓視圖只讀模式 使用關鍵字 with read only
 create or replace view stu2 as select sid,sname from student with read only;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章