---
title: "orcl Index base"
author: "vortexchoo"
date: "2013-07-08T11:19:52Z"
tags: []
categories: ["数据库"]
slug: "orcl-index-base"
draft: false
lastmod: "2013-07-15T13:12:27Z"
id: 1901254
url: "https://vortexchoo.iteye.com/blog/1901254"
---

1\. 聚簇索引  
2\. B-tree索引  
3\. 位图索引 

\---------------------------  
聚簇索引 - 少用  
\--建立簇  
create cluster test\_clst(t\_c varchar2(20)) ;  
\--为簇加索引  
create index cin on cluster test\_clst;  
\--为表增加  
create table t (  
id varchar2(20),  
name varchar2(20)  
)  
cluster test\_clst(id);

---------------------------   
B-tree索引 - 常用  
   
![](http://dl2.iteye.com/upload/attachment/0086/6603/a745eac4-8657-3342-a8fa-116c16d0815a.jpg)  
   
典型的树形结构，自上而下递减，自左向右递增。  
 create index &lt;name&gt; on table\_name(column\_names split by ','|desc/asc);

 alter table table\_name add index index\_name(column\_names split by ','|desc/asc) ;  
\---------------------------   
位图索引  
 我们目前大量使用的索引一般主要是B\*Tree索引,在索引结构中存储着键值和键值的RowID,并且是一一对应的.

而位图索引主要针对大量相同值的列而创建(例如：类别，操作员，部门ID,库房ID等),索引块的一个索引行中存储键值和起止Rowid,以及这些键值的位置编码,位置编码中的每一位表示键值对应的数据行的有无.一个位图索引块可能指向的是几十甚至成百上千行数据的位置.  
create bitmap index index\_name(column\_names split by ','|desc/asc) ;