oracle 查詢資料庫的約束條件

2021-09-07 17:21:15 字數 1129 閱讀 8586

1 1、查詢表的所有索引(包括索引名,型別,構成列):23

select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 表名

4 2、查詢表的主鍵(包括名稱,構成列):

5select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'p' and au.table_name = 表名

6 3、查詢表的唯一性約束(包括名稱,構成列):

7select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'u' and au.table_name = 表名

8 4、查詢表的外來鍵(包括名稱,引用表的表名和對應的鍵名,下面是分成多步查詢):

9select * from user_constraints c where c.constraint_type = 'r' and c.table_name = 表名

10 外來鍵約束的列名:

11select * from user_cons_columns cl where cl.constraint_name = 外來鍵名稱

12 引用表的鍵的列名:

13select * from user_cons_columns cl where cl.constraint_name = 外來鍵引用表的鍵名

14 5、查詢表的所有列及其屬性:

15select t.*,c.comments from user_tab_columns t,user_col_comments c where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = 表名

Oracle 查詢資料庫的約束條件

1 查詢表的所有索引 包括索引名,型別,構成列 select t.i.index type from user ind columns t,user indexes i where t.index name i.index name and t.table name i.table name and...

oracle 資料庫的約束

為了使我們的資料符合一定的規則 約束有五種型別,主鍵約束,外來鍵約束,非空約束,唯一性約束,檢查約束 約束有兩種定義方法 第一種是在定義列的時候定義約束,叫做列級定義。第二種是所有列全部定義完後,在定義約束,該約束叫做表級定義 注意 not null只能在列級中定義 對於多個屬性構成的碼只能使用表級...

oracle資料庫之約束

一 非空約束 1 在建立表時設定非空約束 在資料型別後面加上 not null create table tablename username varchar2 20 not null,2 在修改表時新增非空約束 其實也就是修改欄位的定義,但是需要表中沒有資料 確切的說是要新增非空約束的列沒有非空資...