oracle--索引--

oracle索引:
优点:
a 大大提高查询速度。
b 使用唯一索引保证某个字段值的唯一
缺点:
a 占用磁盘 
b 插入和删除数据时速度变慢。需要重建索引。
创建索引:
1)、单列索引

单列索引是基于单个列所建立的索引
语法:create index 索引名 on 表名(列名);

eg、create index nameIndex on custor(name);


2)、复合索引

复合索引是基于两列或是多列的索引。在同一张表上可以有多个索引,但是要求列的组合必须不同,比如:

create index emp_idx1 on emp(ename, job);

create index emp_idx1 on emp(job, ename);

以上这两个索引是两个不同的索引。
使用原则:
1)、在大表上建立索引才有意义

2)、在where子句或是连接条件上经常引用的列上建立索引


3)、索引的层次不要超过4层

  

原文地址:https://www.cnblogs.com/ipetergo/p/6336722.html