1. 程式人生 > >數據庫索引

數據庫索引

rop asc cor under blog net spa sql esc

一、建立索引

建立索引的一般格式:

creat [unique][cluster] index <索引名稱>

on <表名>(<列名>[<次序>][,<列名>[<次序>]]...);

unique表明此索引的每一個索引值只對應唯一的數據記錄;

cluster表名要建立的索引是聚簇索引(聚簇索引查詢效率相對更好,但是對於經常更新的列不宜建立聚簇索引且一個基本表上最多只能建立一個聚簇索引)

--聚簇索引
creat cluster index student_sname on studnet(sname);
--unique索引
creat unique index student_sno on student(sno);
creat unique index sc_no on sc(sno asc,cno desc);

二、刪除索引

刪除索引的一般格式:

drop index <索引名稱>;

--刪除索引
drop index student_sname;

  

數據庫索引