Oracle Constraint Selection Query
Posted on 2014-01-20
Hello. So I'm trying to correct someone else's work on something in Oracle. This query is supposed to return a list of foreign key constraints from the database. However, it seems like this query is only partially joined up. I'm having trouble figuring out how to tie it all together. Can anyone see what is missing? (these are all system tables).
FROM user_cons_columns x,
WHERE x.constraint_name = z.constraint_name
AND y.constraint_name = z.r_constraint_name
AND z.constraint_type ='R'
AND x.table_name ='tablename
AND x.column_name ='colname'
The idea is to return foreign key (y) table and column name for the where clause's table (x) and column (x).