Обсуждение: RE: [SQL] SQL Script Question

Поиск
Список
Период
Сортировка

RE: [SQL] SQL Script Question

От
Andrzej Mazurkiewicz
Дата:
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.
> 
> ************