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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -