如何在ORACLE数据库的字段上建立索引

2025-04-28 20:20:41
推荐回答(2个)
回答1:

Oracle中建立索引,会提高查询速度:
create index 索引名 on 表名(列名);
例如:
create index index_userid on tbl_detail(userid);

回答2:

索引建立代码:

CREATE INDEX命令语法:
 
CREATE INDEX
CREATE [unique] INDEX [user.]index
ON [user.]table (column [ASC | DESC] [,column
[ASC | DESC] ] ... )
[CLUSTER [scheam.]cluster]
[INITRANS n]
[MAXTRANS n]
[PCTFREE n]
[STORAGE storage]
[TABLESPACE tablespace]
[NO SORT]
Advanced
 
其中:
   schema ORACLE模式,缺省即为当前帐户
   index 索引名
   table 创建索引的基表名
   column 基表中的列名,一个索引最多有16列,long列、long raw
              列不能建索引列
   DESC、ASC 缺省为ASC即升序排序
   CLUSTER 指定一个聚簇(Hash cluster不能建索引)
   INITRANS、MAXTRANS 指定初始和最大事务入口数
   Tablespace 表空间名
   STORAGE 存储参数,同create table 中的storage.
   PCTFREE 索引数据块空闲空间的百分比(不能指定pctused)
   NOSORT 不(能)排序(存储时就已按升序,所以指出不再排序)