本文介绍了再Oracle中创建索引的方法及策略。Oracle索引和对应的表应该位于不同的表空间中,Oracle能够并行读取位于不同硬盘上的数据,可以避免产生I/O冲突B树索引:在B树的叶节点中存储索引字段的值与ROWID.唯一索引和不唯一索引都只是针对B树索引而言。
Oracle最多允许包含32个字段的复合索引。
1、Oracle索引创建策略
(1)导入数据后再创建索引
(2)不需要为很小的表创建索引
(3)对于取值范围很小的字段(比如性别字段)应当建立位图索引
(4)限制表中的索引的数目
(5)为索引设置合适的PCTFREE值
(6)存储索引的表空间最好单独设定
2、创建不唯一索引
create index emp_ename on employees(ename)
tablespace users
torage(……)
pctfree 0;
3、创建唯一索引
create unique index emp_email on employees(email)
tablespace users;
4、创建位图索引
create bitmap index emp_sex on employees(sex)
tablespace users;
5、创建反序索引
create unique index order_reinx on orders(order_num,order_date)
tablespace users
reverse;
6、创建函数索引(函数索引即可以是普通的B树索引,也可以是位图索引)
create index emp_substr_empno on employees(substr(empno,1,2))
新闻热点
疑难解答