嘗試以下sql語句:
獲得母公司所有子表和列,
SELECT distinct confk.constraint_name,
confk.constraint_type,
confk.table_name child_table,
fkcon.column_name child_column,
conpk.table_name parent_table,
pkcon.column_name parent_column
FROM dba_constraints confk,
dba_constraints conpk,
dba_cons_columns pkcon,
dba_cons_columns fkcon
WHERE confk.r_constraint_name = conpk.constraint_name
AND conpk.constraint_name = pkcon.constraint_name
AND confk.constraint_name = fkcon.constraint_name
AND confk.constraint_type = 'R'
AND pkcon.owner = 'Your schema name'
AND pkcon.table_name ='your parent table name'
AND pkcon.column_name ='your parent column name';
獲取父表名和孩子的名字和列列,
SELECT distinct confk.constraint_name,
confk.constraint_type,
confk.table_name child_table,
fkcon.column_name child_column,
conpk.table_name parent_table,
pkcon.column_name parent_column
FROM dba_constraints confk,
dba_constraints conpk,
dba_cons_columns pkcon,
dba_cons_columns fkcon
WHERE confk.r_constraint_name = conpk.constraint_name
AND conpk.constraint_name = pkcon.constraint_name
AND confk.constraint_name = fkcon.constraint_name
AND confk.constraint_type = 'R'
AND fkcon.owner = 'Your schema name'
AND fkcon.table_name ='your child table name'
AND fkcon.column_name ='your child column name';
編輯得到刪除多餘的列 –
ORA-00923:在預期的位置找不到FROM關鍵字 00923. 00000 - 「在預期的位置找不到FROM關鍵字」 *原因: *操作: –
確定。這個SQL是用於SQL Server的,絕對不會在Oracle中運行!而且你確實在它上面放了一個Oracle標籤,所以不要浪費你的時間... –