I need to drop tables that are not used somewhere else in my database (mainly views). I have listed a series of DROP TABLE...
commands but I can't run them at once because an error message is issued each time a used table is found. I would need a command that ignore such messages (and then do not remove the used tables) and jump to the next command.
For instance:
DROP TABLE schema1.table1 ;
DROP TABLE schema1.table2 ;
DROP TABLE schema1.table3 ;
DROP TABLE schema1.table4 ;
DROP TABLE schema1.table5 ;
In this example, say table1
and table3
are used in views whereas tables 2, 4 and 5 are not. If I run the script, I have an error message for table1
. I have then to comment the line and run the script again. Then, table2
is dropped properly and I get an error message again for table3
. I then have to comment this line and run the script again. I eventually get the 2 last tables dropped.
The point is that I have hundreds of such tables, used and not used mixed together...