Re: if exists?

From: Scott Marlowe <scott(dot)marlowe(at)ihs(dot)com>
To: Vincent Stoessel <vincent(at)xaymaca(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: if exists?
Date: 2002-05-13 17:24:48
Message-ID: Pine.LNX.4.33.0205131124220.18289-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 13 May 2002, Vincent Stoessel wrote:

> Is there an sql query that I can use on postgres that will tell
> me if a table exists? I'm writing a perl script thatr creates a table.
> But I want it to rename a table with the same name if it finds an
> existing one.

select 1 from pg_tables where tablename='tablethatmayexist';

If you get back a 1, it exists, if you get back no rows, it doesn't.

In response to

  • if exists? at 2002-05-13 13:33:38 from Vincent Stoessel

Browse pgsql-general by date

  From Date Subject
Next Message Randall Perry 2002-05-13 17:31:34 Re: Serious environment problem with 7.2 on Solaris
Previous Message Keehan Mallon 2002-05-13 17:21:00 Configure problems with readline Mandrake 8.2 and postgres 7.2.1