Monday, March 11, 2013

Query to find child tables



A simple select query to find child table of a particular table:


SELECT parent.table_name AS "PARENT TABLE", child.table_name AS "CHILD TABLE", child.R_CONSTRAINT_NAME, cols.column_name 
FROM user_constraints parent, user_constraints child, user_cons_columns cols 
WHERE parent.constraint_type = 'P' AND 
child.constraint_name = cols.constraint_name and 
parent.CONSTRAINT_NAME = child.R_CONSTRAINT_NAME AND  
child.CONSTRAINT_TYPE = 'R' AND  
parent.table_name = <table_name> 

No comments:

Post a Comment

Convert Java SQL String to Oracle SQL Format in TOAD

At times Toad might reset the capability to strip off / convert the the SQL in Java string format to SQL format. You can have that back...