1.oracle中查询某个表中的主键被哪些表引用的sql语句:
SELECT c.TABLE_NAME FROM all_constraints p,all_constraints c WHERE p.table_name = '表名' AND p. OWNER = SYS_CONTEXT ('USERENV','CURRENT_SCHEMA') AND c. OWNER = SYS_CONTEXT ('USERENV','CURRENT_SCHEMA') AND c.constraint_type = 'R' AND p.CONSTRAINT_NAME = c.R_CONSTRAINT_NAME
注:表名要带上单引号
2.oracle中查询该表中的外键来源于哪些表的sql语句:
SELECT cl.table_name FROM user_cons_columns cl LEFT JOIN user_constraints c ON cl.constraint_name = c.r_constraint_name WHERE c.constraint_type = 'R' AND c.table_name = '表名'原文链接:https://www.f2er.com/oracle/206980.html