RE: [SQL] SQL Script Question

From: Andrzej Mazurkiewicz <andrzej(dot)mazurkiewicz(at)polkomtel(dot)com(dot)pl>
To: "'Carolyn Wong'" <carolyn(at)kss(dot)net(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: RE: [SQL] SQL Script Question
Date: 2000-02-23 10:06:13
Message-ID: 13288F4408ADD11186FF0060B06A431303648C5C@MSGWAW1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)kss(dot)net(dot)au]
> Sent: 23 lutego 2000 07:33
> To: pgsql-sql(at)postgresql(dot)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.
>
> ************

Browse pgsql-sql by date

  From Date Subject
Next Message Kovacs Zoltan Sandor 2000-02-23 12:24:34 Re: [SQL] SQL Script Question
Previous Message Carolyn Wong 2000-02-23 06:32:51 SQL Script Question