Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 59864 invoked from network); 26 Sep 2005 12:56:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Sep 2005 12:56:31 -0000 Received: (qmail 81353 invoked by uid 500); 26 Sep 2005 12:56:29 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 81333 invoked by uid 500); 26 Sep 2005 12:56:29 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 81321 invoked by uid 99); 26 Sep 2005 12:56:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2005 05:56:29 -0700 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_60_70,HTML_MESSAGE,HTML_TITLE_EMPTY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.42.14] (HELO nwkea-mail-2.sun.com) (192.18.42.14) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Sep 2005 05:56:35 -0700 Received: from phys-bur-1 ([129.148.9.72]) by nwkea-mail-2.sun.com (8.12.10/8.12.9) with ESMTP id j8QCu6HT025536 for ; Mon, 26 Sep 2005 05:56:07 -0700 (PDT) Received: from conversion-daemon.bur-mail1.east.sun.com by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0INF00J01D2I9U@bur-mail1.east.sun.com> (original mail from Lance.Andersen@Sun.COM) for derby-user@db.apache.org; Mon, 26 Sep 2005 08:56:06 -0400 (EDT) Received: from [127.0.0.1] (vpn-129-150-66-72.East.Sun.COM [129.150.66.72]) by bur-mail1.east.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTPA id <0INF00B2GD9HVF@bur-mail1.east.sun.com> for derby-user@db.apache.org; Mon, 26 Sep 2005 08:56:06 -0400 (EDT) Date: Mon, 26 Sep 2005 08:56:09 -0400 From: "Lance J. Andersen" Subject: Re: Equivalent of SQL "DROP TABLE IF EXISTS MY_TABLE" ? In-reply-to: <20050926100926.GB30511@atum01.norway.sun.com> To: Derby Discussion Message-id: <4337EFE9.3030208@sun.com> MIME-version: 1.0 Content-type: multipart/alternative; boundary="Boundary_(ID_cC+I7bm/RZ9D17JhcLoRmQ)" X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) References: <20050926175743.AFC1.WOLFGANG127US@yahoo.co.jp> <20050926100926.GB30511@atum01.norway.sun.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --Boundary_(ID_cC+I7bm/RZ9D17JhcLoRmQ) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT 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; > } > > > --Boundary_(ID_cC+I7bm/RZ9D17JhcLoRmQ) Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7BIT 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;
        }

  
--Boundary_(ID_cC+I7bm/RZ9D17JhcLoRmQ)--