drop table before create

From: Mark Probert <probertm(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: drop table before create
Date: 2005-08-23 20:54:14
Message-ID: 1124830454.6792.28.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi ..

I have not been able to work out how to do this is Postgres 8
(pseudo-code)

if exists table foo
drop table foo;
end
create table foo;

If I go with

drop table foo;
create table foo;

then it barfs on an empty db. I can find the table name in pg_class but
I am not sure of where to go from there.

The assumption here is that the SQL is coming in on a script via the
programmatic interface. Slurp in a bunch of SQL commands and then fire
them at the database.

Perhaps it is just easier to 'dropdb' then 'createdb' and go from there.

Many thanks,

--
-mark. (probertm at acm dot org)

Browse pgsql-general by date

  From Date Subject
Next Message Brent Wood 2005-08-23 21:26:57 Re: Import File
Previous Message Roger Hand 2005-08-23 20:46:51 Re: plpgsql: returning multiple named columns from function *simply*