Re: Conditional Statement - Mailing list pgsql-general

From Marshall Spight
Subject Re: Conditional Statement
Date
Msg-id a64cep$24ht$1@jupiter.hub.org
Whole thread Raw
In response to Conditional Statement  (Samik Raychauhduri <samik@cae.wisc.edu>)
List pgsql-general
"Samik Raychauhduri" <samik@cae.wisc.edu> wrote in message news:3C82CA4C.6030205@cae.wisc.edu...
> I am trying to write a piece of SQL code, which will first check if a
> table exist, drop it and then recreate it. I didn't see any 'IF' syntax
> in pgsql. Is there any other alternative? I tried to use 'case'
> structure, but didn't succeed.

The way you do that is to say:

drop table foo
create table foo ...


That's all you need. Nothing fancy. The 'drop table' will print a message
if the table didn't exist already, but it doesn't matter.


Marshall




pgsql-general by date:

Previous
From: Ymir
Date:
Subject: Arrays
Next
From: rrozboril@goldmann.sk (Robert)
Date:
Subject: Stored procedure in PostgreSQL