Received: from candle.pha.pa.us (216-55-132-35.dsl.san-diego.abac.net [216.55.132.35]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g03H4fm51955 for ; Thu, 3 Jan 2002 12:04:42 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g03H4cR15169; Thu, 3 Jan 2002 12:04:38 -0500 (EST) From: Bruce Momjian Message-Id: <200201031704.g03H4cR15169@candle.pha.pa.us> Subject: Re: Conditional test In-Reply-To: <4eee2f8d.0112271854.276c1152@posting.google.com> To: Rick Dayao Date: Thu, 3 Jan 2002 12:04:38 -0500 (EST) CC: pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL96 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200201/21 X-Sequence-Number: 6112 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