Re: IF EXISTS

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "P(dot)M" <pmdanger(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: IF EXISTS
Date: 2005-11-14 21:35:34
Message-ID: 20051114213534.GB6003@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 14, 2005 at 13:20:59 -0800,
"P.M" <pmdanger(at)yahoo(dot)com> wrote:
> Hi,
>
> I would like to know if "IF EXISTS" exists under
> postgresql ?
> because i did not find it.
>
> before to create users or database, i would like to be
> sure that they do not exist already.
>
> so how can i test it and do something like :
>
> IF EXISTS database "test" DROP database "test";

I don't believe there is a feature like that for users (roles) or databases.
The normal thing to do would be to have the application try to delete the
object and ignore the problem if things fail. If this is happening in a larger
transaction that you don't want rolled back, then you can use savepoints.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jaime Casanova 2005-11-14 21:51:51 Re: IF EXISTS
Previous Message P.M 2005-11-14 21:20:59 IF EXISTS