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:
[EMAIL PROTECTED] 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;
        }

  

Reply via email to