Oracle 建立索引語法

2021-08-19 19:43:47 字數 1135 閱讀 8466

oracle 的索引可分為5種,它們包括唯一索引、組合索引、反向鍵索引、位圖索引和基於函式的索引。

1、建立索引的標準語法

以下為引用內容: 

create index 索引名 on 表名 (列名)

tablespace 表空間名;

例如:

以下為引用內容: 

create index idx_of_imsi on uim_auth_file(imsi) tablespace users;

2、建立唯一索引

以下為引用內容: 

create unique index 索引名 on 表名 (列名)

tablespace 表空間名;

例如:

以下為引用內容: 

create unique index idx_of_imsi on uim_auth_file(imsi) tablespace users;

3、建立組合索引

以下為引用內容: 

create index 索引名 on 表名 (列名1,列名2)

tablespace 表空間名;

例如:

以下為引用內容: 

create index idx_of_imsi on uim_auth_file(iccid,imsi) tablespace users;

4、建立反向鍵索引

以下為引用內容: 

create index 索引名 on 表名 (列名) reverse

tablespace 表空間名;

例如:

以下為引用內容: 

create index idx_of_imsi on uim_auth_file(imsi) reverse tablespace users;

5、oracle中檢視某個表的索引是否有效

select status,t.* from user_indexes t

where table_name='table1'

6、檢視表中哪個屬性是索引

select * from user_ind_columns where index_name = '***'

oracle建立索引語句

oracle 單索引create index 索引名稱 on table column 刪除索引 drop index 索引名稱 復合索引 create index wbsindex on project info wbs,is delete 查詢某張表中所有索引 select from all i...

mysql索引語法 MySQL建立索引的語法

建立表時建立索引 語法 create table 表名 屬性名 資料型別 完整性約束條件 unique fulltext spatial index key 別名 屬性名 1 長度 asc desc 1 建立普通索引 create table index1 id int,name varchar 2...

mysql索引語句 mysql建立索引語句格式

專案需要將某個表的某兩個字段新增唯一索引,保證這兩個欄位的值不能同時重複。alter table 表名 add unique index 索引名 欄位1,欄位2 當表中已經存在重複資料的時候,新增的時候就會報錯,這時候需要將資料去重。1 先查出來重複的資料 select from select 字段...