visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
294 experts, 1172 registered users, 1625 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


The DDRK link is back online.
We got a one week service interruption, sorry.
(23-30/01/2010)

Databases :: Oracle :: "drop table if exists" in Oracle ? ORA-00933


By: Bernard France  Date: 07/09/2005 23:44:11  English  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 English  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:
 del.icio.usDel.icio.us  diggDigg  googleGoogle  spurlSpurl
 blinkBlink  wongWong  simpySimpy  yahooY! MyWeb 
EContact
browser fav
page generated in 63.606020 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page