数据库索引

Posted by-lhc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据库索引相关的知识,希望对你有一定的参考价值。

一、建立索引

建立索引的一般格式:

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;

  

以上是关于数据库索引的主要内容,如果未能解决你的问题,请参考以下文章