Re: SQL: how to find if a table exists?

From: Richard Huxton <dev(at)archonet(dot)com>
To: Jean-Christian Imbeault <totsubo2001(at)netscape(dot)net>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL: how to find if a table exists?
Date: 2002-09-09 14:43:50
Message-ID: 200209091543.51581.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday 07 Sep 2002 2:36 pm, Jean-Christian Imbeault wrote:
> I need to programmatically create a table if it does not already exists.
>
> Is there an SQL statement that will allow me to query a DB to see if a
> table exists?

select * from pg_tables

is about what you want. There are a bunch of other useful system-tables - see
the manual for details. Also you might want to start psql with -E and see
what \dt does.

- Richard Huxton

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2002-09-09 14:47:03 Re: Literal dash in regular expression brackets
Previous Message Joe Murphy 2002-09-09 14:43:42 Re: Vacuum and indexes problem