Re: Conditional test - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: Conditional test
Date
Msg-id 200201031704.g03H4cR15169@candle.pha.pa.us
Whole thread Raw
In response to Conditional test  (rickd@open-works.com (Rick Dayao))
List pgsql-sql
Rick Dayao wrote:
> I am trying to solve this problem:
> 
> If a table exists, drop the table, otherwise continue processing.
> 
> For example, if table X exists, then drop table X.  How would I do
> this in SQL?  I can query the pg_tables table to see which tables
> exist, but I'm looking for an If-Else construct in SQL.

You can drop the table and ignore the error if returned.  We will have
CREATE OR REPLACE in 7.2, but no conditional DROP.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Retrieving information from System Tables
Next
From: Stephan Szabo
Date:
Subject: Re: How to union tables and have a field with UNIQUE constraint?