例如,表A引用了表B,但没有此类表引用该表A。我需要使用系统表(例如用户约束)来解决此问题
答案 0 :(得分:1)
例如:
SELECT u.table_name
FROM user_tables u
WHERE u.table_name NOT IN (SELECT c.table_name
FROM user_constraints rc
JOIN user_constraints c
ON c.constraint_name =
rc.r_constraint_name
WHERE rc.constraint_type = 'R');
或者,如果您更喜欢(NOT) EXISTS
:
SELECT u.table_name
FROM user_tables u
WHERE NOT EXISTS
(SELECT NULL
FROM user_constraints rc
JOIN user_constraints c
ON c.constraint_name = rc.r_constraint_name
WHERE rc.constraint_type = 'R'
AND u.table_name = c.table_name);