Creating a heirarchy of tables in a schema based on FK
Date: Wed, 18 Nov 2009 13:00:27 +0530
Hi List members
Would like your help/inputs in a problem I am facing here.
I want to clear out records from a huge bunch of selected tables (1000+) which have interdependencies established using FK constraints. Of course, just creating a "delete * from table" doesn't work because of the FK constraints.
What I want to do is to identify the "child" tables which can be deleted first and then create the hierarchy of tables so that the parent tables can then be cleared out, and so on.
Can anyone point me to any reference or script which can generate this hierarchy based on the foreign key constraints? Based on that I can then make the delete script pretty quickly.
I thought of disabling the constraints and re-enabling them after the "delete * from table" script, but would like to try the cleaner approach of starting from the bottom of the dependency tree for these tables.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List. In the US, we're called MAJESCOMASTEK
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
Received on Wed Nov 18 2009 - 01:30:27 CST