From: Andrzej Mazurkiewicz <andrzej.mazurkiewicz@polkomtel.com.pl>
To: 'Carolyn Wong' <carolyn@kss.net.au>
Cc: pgsql-sql@postgresql.org
Subject: RE: [SQL] SQL Script Question
Date: Wed, 23 Feb 2000 11:06:13 +0100
Message-ID: <13288F4408ADD11186FF0060B06A431303648C5C@MSGWAW1> (raw)
Hello.
You can utilize quick and dirty approach, i. e.
BEGIN WORK;
DROP TABLE ...
COMMIT WORK;
If table is not present it will not drop it but you will have consistent
state of transactions.
The other solution is to use pgtclsh or perl with Pg library. As far as I
know psql gives no control constructs (IF, CASE, WHILE ...).
Regards,
Andrzej Mazurkiewicz
www.mazurkiewicz.org
> -----Original Message-----
> From: Carolyn Wong [SMTP:carolyn@kss.net.au]
> Sent: 23 lutego 2000 07:33
> To: pgsql-sql@postgresql.org
> Subject: [SQL] SQL Script Question
>
> I'm trying to write SQL script to create tables as follows:
>
> --------------------------------
> drop table xxx;
> create table xxx (
> ......
> );
> grant all on xxx to public;
> --------------------------------
>
> Before dropping the table, I'd like to check if the table exists as the
> following psuedo code:
>
> if <table exists>
> drop table xxx;
>
> How can i write this 'if' condition? Or are there any other ways to
> check this??
>
> Thanks in advance.
>
> ************
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: andrzej.mazurkiewicz@polkomtel.com.pl, carolyn@kss.net.au
Subject: Re: [SQL] SQL Script Question
In-Reply-To: <13288F4408ADD11186FF0060B06A431303648C5C@MSGWAW1>
References: <13288F4408ADD11186FF0060B06A431303648C5C@MSGWAW1>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox