在PL/SQL中 建立索引是为了加快查询速度,但如果索引过多或设置不合理可能会降低查询速度
一般来说只对在数据量比较大的表中,对于需要经常查询较少修改的列建立索引
--创建单一索引 (在emp表上的sal列创建名为sal_index的索引)
create index sal_index on emp(sal);
--创建复合索引(在emp表上的sal,ename列创建名为com_index [size=1em]的复合索引)
create index com_index on emp(sal,ename);
--创建唯一索引(在emp表上的ename列创建名为ename_unqiue_index [size=1em]的唯一索引
--如果要建立唯一索引的列已经有重复项则不能建立唯一索引
create unique index ename_unqiue_index on emp(ename);
--删除索引
drop index 索引名;
--显示当前用户的所有索引
select * from user_indexes;