sql - Select all tables in schema based on their parent-child hierarchy -
my requirement delete data couple of table selected dynamically based on search condition.
so cursor should fetch tables in parent-child hierarchy not give exception 'child record found' while deleting records.
lets take exable
table child of table b
table b child of table c
table d child of table g
so should delete in sequence.
a then
b or d
d or g
if use cascading foreign keys, don't have worry table order. delete top of hierarchy (table g in in example) , dependent rows in descendent tables deleted atomically.
read more cascading referential integrity constraints.
re comment:
also should generic enough handle delete if delete cascade not there , not have knowledge of dependencies.
see these questions tips on discovering constraints in oracle:
Comments
Post a Comment