Databases :: Oracle :: "drop table if exists" in Oracle ? ORA-00933 |
|||
| By: Bernard |
Date: 07/09/2005 23:44:11 |
Points: 20 | Status: Answered Quality : Excellent |
|
is it feasible like in MySql ? drop table if exists toto; create table toto (...DDL...); |
|||
| By: VGR | Date: 07/09/2005 23:49:28 | Type : Answer |
|
| Hello, This is closely linked to the already-answered PAQed question ["if not exists" SQL statement in Oracle ?] but you can have a new answer anyway ;-) You have to use PL/SQL to write some kind of stored procedure : Begin execute immediate 'Drop table toto'; Exception when others then null; End; / create table toto (...DDL...); or you can also use this kind of code : DECLARE exists PLS_INTEGER; BEGIN select count(*) into exists from user_tables where table_name = 'toto'; if exists = 1 then execute immediate 'drop table toto'; end if; END; / create table toto ( ...DDL...); |
|||
|
Do register to be able to answer |
|||
| Add This Article To: | |||
| |
|
|
|
| |
|
|
|








