特点:对某列中的数据进行排序或归类,生成独立的索引表,查询条件包含该列时,Oracle 会自动引用该索引,先从索引表中查询出符合条件记录的 ROWID
作用:优化数据库查询的效率
缺点:
1、浪费空间来存储索引表
2、当数据量较少时,使用索引反而更慢
3、可提高查询效率,但数据增删改需更新索引
4、语法结构
create unique index 索引名称
on 原表名称(原列名称1,原列名称2)tablespace tab_name --tablespace表示索引存储的表空间pctfree n1 --索引块的空闲空间n1storage --存储块的空间 ( initial 64K --初始64k next 1M minextents 1 maxextents unlimited);举例:
create index cm_link_syon cm_link(device_id)
tablespace USERS pctfree 10 initrans 2 maxtrans 255 storage ( initial 64K next 1M minextents 1 maxextents unlimited );5、查看索引: select * from all_indexes t where t.indexe.name='SYS_C0013374';
重命名索引:alter index old_name rename to new_name
删除索引:drop index name;