クエリーテーブルの外部キー関係
質問
指定されたテーブル'foo'については親権者の方の同意が必要でクエリを生成するテーブルのセットとして海外のキーポイントfoo.を使用していOracle10G.
解決
この仕事(もり):
select table_name
from all_constraints
where constraint_type='R'
and r_constraint_name in
(select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='<your table here>');
他のヒント
以下の書類をすべての子孫.って試験を実施し、Oracle10データベースです。
SELECT level, main.table_name parent,
link.table_name child
FROM user_constraints main, user_constraints link
WHERE main.constraint_type IN ('P', 'U')
AND link.r_constraint_name = main.constraint_name
START WITH main.table_name LIKE UPPER('&&table_name')
CONNECT BY main.table_name = PRIOR link.table_name
ORDER BY level, main.table_name, link.table_name
こちらの方をマイクのクエリを一歩進め、 カラム名 からの制約は名前:
select * from user_cons_columns
where constraint_name in (
select constraint_name
from all_constraints
where constraint_type='R'
and r_constraint_name in
(select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='<your table name here>'));
ているの データ辞書の見方.その接頭辞:
- ユーザー
- すべての
- DBA
サンプル
select * from dictionary where table_name like 'ALL%'
継続的マイクのすす生成スクリプトを有効/無効にするには。だけを変更した'select'最初のです。
select 'alter table ' || TABLE_NAME || ' disable constraint ' || CONSTRAINT_NAME || ';'
from all_constraints
where constraint_type='R'
and r_constraint_name in
(select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='<your table here>');
いでちょっと遅めの答えによらずに答えてくれず、一部の回答は、非常に複雑であるここでは簡単になります。
`SELECT a.table_name child_table, a.column_name child_column, a.constraint_name, b.table_name parent_table, b.column_name parent_column FROM all_cons_columns a JOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name join all_cons_columns b on c.owner = b.owner and c.r_constraint_name = b.constraint_name WHERE c.constraint_type = 'R' AND a.table_name = 'your table name'`
select distinct table_name, constraint_name, column_name, r_table_name, position, constraint_type
from (
SELECT uc.table_name,
uc.constraint_name,
cols.column_name,
(select table_name from user_constraints where constraint_name = uc.r_constraint_name)
r_table_name,
(select column_name from user_cons_columns where constraint_name = uc.r_constraint_name and position = cols.position)
r_column_name,
cols.position,
uc.constraint_type
FROM user_constraints uc
inner join user_cons_columns cols on uc.constraint_name = cols.constraint_name
where constraint_type != 'C'
)
start with table_name = '&&tableName' and column_name = '&&columnName'
connect by nocycle
prior table_name = r_table_name
and prior column_name = r_column_name;
ダウンロード、オラクルリファレンスガイド10Gのデータ辞書です。
その答えは良いのですがチェックの他のテーブルと密接に関与していると考える。
SELECT * FROM DICT WHERE TABLE_NAME LIKE '%CONS%';
最後に、ツールのような道路またはSQLデベロッパーで閲覧できるものは、UI、覚えておく必要があるのテーブルをご利用くださいUIもございます
所属していません StackOverflow