oracle查詢約束

2021-06-03 16:43:20 字數 1478 閱讀 5033

查詢約束型別

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 約束名;

oracle查詢約束

select distinct constraint type from dba constraints type code type description acts on level c check on a table column o read only on a view object p...

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建立約束 刪除約束

1.定義not null 約束not null 約束只能在列級定義,不能在表級定義 例 create table emp01 eno int not null,name varchar2 10 constraint nn name2 not null,salary number 6,2 2.定義un...