We tried to deploy an application to a customer’s test system yesterday and needed to clean up the full database. We agreed before that they have to delete the schema and the user with all table etc. but they missed to notify their ORACLE adminstrators. We had only the permissions to work in, but not with the schema. So how to drop a few hundred tables?
DROP TABLE * CASCADE CONSTRAINTS!?
No. No such statement is possible. The solution of my workmate was a little funny:
- Open ORACLE SQL Developer and connect to the database / schema.
- Mark all tables to delete.
- Choose “edit / copy full path” from the applications menu.
- Paste the stuff into the script editor. You get something like “TABLE MySchema.MyTable@MyDb”.
- Open Search/replace and replace “TABLE MySchema” with “DROP TABLE MySchema”.
- Replace also “@MyDb” with “ CASCADE CONSTRAINTS;”.
- Run the script.
