oracle查詢約束
查詢約束型別
select distinct constraint_type fromdba_constraints;
Type Code |
Type Description |
Acts On Level |
C |
Check on a table |
Column |
O |
Read Only on a view |
Object |
P |
Primary Key |
Object |
R |
Referential AKA Foreign Key |
Column |
U |
Unique Key |
Column |
V |
Check Option on a view |
Object |
查詢各種約束
user_constraints all_constraints dba_constraints
select * from user_constraints where constraint_type='R'
select * fromALL_constraints where constraint_type='P'
select * from dba_constraintswhere constraint_type='C'
我們關心的檢視以下列字首命名:
·USER_ :當前使用者模式下建立的物件
·ALL_ :當前使用者模式下建立的物件加上當前使用者能訪問的其他使用者建立的物件。ALL檢視常常包含一個"OWNER"列,反映出能夠訪問的物件的所有者。在USER_TABLES表中不能看到OWNER列是因為你就是在這個檢視中所有表的所有者;在ALL_TABLES中有一個OWNER欄位。
·DBA_ :它提供了整個資料庫的資訊。包括資料庫中所有表的名字和擁有者——包括SYS模式下的基本表
這些字首在限制我們想看到的、需要看到的、應當被允許看到的範圍上是一個幫助。檢視當前模式下建立的表,查詢USER_TABLES;
修改約束
alter table 表名 enable/disable/dropconstraint 約束名;