RE: [SQL] SQL Script Question - Mailing list pgsql-sql

From Andrzej Mazurkiewicz
Subject RE: [SQL] SQL Script Question
Date
Msg-id 13288F4408ADD11186FF0060B06A431303648C5C@MSGWAW1
Whole thread Raw
List pgsql-sql
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.
> 
> ************


pgsql-sql by date:

Previous
From: Carolyn Wong
Date:
Subject: SQL Script Question
Next
From: Kovacs Zoltan Sandor
Date:
Subject: Re: [SQL] SQL Script Question