if exists?

From: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
To: Vincent Stoessel <vincent(at)xaymaca(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Lee Kindness <lkindness(at)csl(dot)co(dot)uk>
Subject: if exists?
Date: 2002-05-13 15:26:14
Message-ID: 15583.56086.82928.173176@kelvin.csl.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vincent Stoessel writes:
> 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.

Something like:

SELECT COUNT(relname) FROM pg_class WHERE relname = 'tablename';

Regards, Lee Kindness

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 Oliver Elphick 2002-05-13 15:31:48 Re: if exists?
Previous Message Marin Dimitrov 2002-05-13 15:25:54 Re: if exists?