Thursday, February 10, 2011

Oracle: drop table if exists

something quite annoying in Oracle is that if you do

drop table MYTABLE;

and the table doesn't exist, you get an error.

A workaround can be:

BEGIN
EXECUTE IMMEDIATE 'DROP TABLE MYTABLE';
EXCEPTION WHEN OTHERS THEN NULL;
END;

No comments: