In a DB2 federated database (based on remote servers and nicknames), I need to clean up the model and recreate it from another database. I need to delete every database object except those servers and nicknames.
I know how to retrieve the list of objects from the SYSCAT schema. Now I need to run the DROP statements on each. Obviously the dependencies will get in the way.
The brute force approach would be to run the DROPs in a loop until all have succeeded, but depending on the order (lucky or not), it could take a very long time.
Would you know a way to efficiently order the DROP statement so that the total time for the deletion is the shortest possible?
A perfect solution is not expected. A reasonably clever solution is good enough.
Thank you
This query is able to order the statements according to the total number of elements they depend on. The resulting order works almost without a glitch, the second pass of the “brute force” approach contains only a handful of objects (out of several thousands objects to delete).
Problem, it is very slow…EDIT : There was a typo in the query that made it return more or less correct data but very very slowly.