With the piece of code below it’s quite easy to first make sure your table exists before dropping it, so you’re not running into SQL Error: ORA-00942: table or view does not exist
Script explanation: It will check if the table is present before trying to drop it.
-- Drop table DECLARE l_count NUMBER; BEGIN SELECT COUNT(1) INTO l_count FROM ALL_TABLES WHERE table_name = 'TABLE_NAME' AND owner = 'USERNAME'; IF l_count > 0 THEN EXECUTE IMMEDIATE 'Drop table USERNAME.TABLE_NAME CASCADE CONSTRAINTS'; END IF; END; /
One Reply to “How to try to drop a table without raising exception ORA-00942: table or view does not exist”
Reblogged this on Sutoprise Avenue, A SutoCom Source.