Oracle 創建索引語法,oracle 如何查看當前用戶的表空間名稱

racle 的索引可分爲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;

 

oracle 如何查看當前用戶的表空間名稱

 --查詢語法--
 select default_tablespace from dba_users where username='登錄用戶'
   

如,我的登錄用戶是TMS21,那麼查詢語法是

 /* 查看用戶所屬的表空間 */
 select default_tablespace from dba_users where username='TMS21';

相關查詢的用法,也順便記錄一下

1)查詢當前用戶表空間

 /* 查看用戶所屬的表空間 */
 select default_tablespace from dba_users where username='TMS21';

2)查詢所有表空間

  /*查看所有的表空間 */
   -- 1 )方式1:dba_tablespaces --
   select * from dba_tablespaces;
    --2 )方式2:v$tablespace --
   select * from v$tablespace;   

3)查詢用戶下所有表

  /* 查看用戶下面的所有的表 */ 
  -- 1 )方式1:user_tables --
   select * from user_tables;
   --2 )方式2: dba_tables --
   select * from dba_tables where owner='TMS21';

4)查詢表空間下的用戶

  /*查看錶空間下有多少用戶,tablespace_name表空間 的名字一定要大寫 */
   select distinct s.owner from dba_segments s where s.tablespace_name ='TMS21';  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章