2017-05-12 12 views

答えて

0

あなたは、テーブルの列と対応する制約を参照するデータ・ディクショナリは、具体的にUSER_CONS_COLUMNSビューを照会する必要があります。テーブルの上に制約を見つけるには

SELECT * FROM user_cons_columns WHERE table_name = '<your table name in caps>'; 
1

を:

select constraint_name, constraint_type 
from user_constraints 
where table_name = 'YOUR_TABLE' 

一致する辞書があります。他のスキーマの表に対する制約を検出する必要がある場合は、ALL_およびDBA_を使用します。

4つの制約型である

  • P主キー
  • Uユニーク
  • R外部キー(参照)
  • Cチェック

チェック制約には、NOT NULLなどの制約として直ちに考えないものが含まれます。だから、

、テーブルの主キーを見つけるために...

select constraint_name, constraint_type 
from user_constraints 
where table_name = 'YOUR_TABLE' 
and c.constraint_type = 'P' 

外部キーで参照される表を検索するには:

select c.constraint_name as foreign_key 
     , c.r_constraint_name as referenced_constraint 
     , p.table_name 
from user_constraints c 
    join user_constraints p 
     on p.constraint_name = c.r_constraint_name 
where c.table_name = 'YOUR_TABLE' 
and c.constraint_type = 'R' 
/
0

それあなたがに関する情報を見つけようとしていますデータモデルでは、ジョブ用に構築されたツールを使用します。

Download SQL Developer

関連する問題