From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Rick Dayao <rickd@open-works.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Conditional test
Date: Thu, 3 Jan 2002 12:04:38 -0500 (EST)
Message-ID: <200201031704.g03H4cR15169@candle.pha.pa.us> (raw)
In-Reply-To: <4eee2f8d.0112271854.276c1152@posting.google.com>
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, Pennsylvania 19026
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pgman@candle.pha.pa.us, rickd@open-works.com
Subject: Re: Conditional test
In-Reply-To: <200201031704.g03H4cR15169@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox