Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dependencies

Status
Not open for further replies.

uparna

Technical User
Jun 27, 2001
182
IN
HI ,
My database has a table which is referenced by several other tables. Ie all these other tables have foreign keys pointing to this table. Is it posible for me to find out what all tables are referencing this table ? This is because i am writing scripts for deletion of history data and hence , before deletion, i need to delete all the child records . Ofcourse, doing the cascade delete would appear to be the ideal solution here , but the problem is that QualityAssuarenceGroup has directed me to keep a backup of these deleted records only , so that we have no problems during whatever .
Any solutions ?
 
SELECT A.OWNER||'.'||A.TABLE_NAME "PARENT",B.OWNER||'.'||B.TABLE_NAME "CHILD",B.CONSTRAINT_NAME
FROM ALL_CONSTRAINTS A, ALL_CONSTRAINTS B
WHERE A.OWNER ='&owner'
AND A.TABLE_NAME = '&table'
AND A.CONSTRAINT_NAME = B.R_CONSTRAINT_NAME
AND B.CONSTRAINT_TYPE = 'R'
ORDER BY 2;
 
Thanks a lot sir !

i am banging my head here for not hving thought of such a simple solution !!

Regards,
Jayaram.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top