db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lance J. Andersen" <Lance.Ander...@Sun.COM>
Subject Re: Equivalent of SQL "DROP TABLE IF EXISTS MY_TABLE" ?
Date Mon, 26 Sep 2005 12:56:09 GMT
Having this type of functionality in some form (see the MS or Sybase 
docs) is beneficial.  I get this question constantly from internal users.

Bernt M. Johnsen wrote:

>>>>>>>>>>>>>wolfgang127us@yahoo.co.jp wrote (2005-09-26
18:11:26):
>>>>>>>>>>>>>                          
>>>>>>>>>>>>>
>>Hi there,
>>
>>To initialize my database, I want to use an SQL 
>>equivalent of "DROP TABLE IF EXISTS MY_TABLE" .
>>
>>I've tried it but of course didn't work
>>
>>Does Derby support this kinda SQL or Is there any workaround
>>I can drop a table if it exists ??
>>    
>>
>
>One way could be:
>        try {
>            stmt.executeUpdate("DROP TABLE MY_TABLE");
>        } catch (SQL_Exception e) {
>            if (!e.getSQLState().equals("proper SQL-state for table does not exist"))
>                throw e;
>        }
>
>  
>

Mime
View raw message