drop table before create - Mailing list pgsql-general

From Mark Probert
Subject drop table before create
Date
Msg-id 1124830454.6792.28.camel@localhost.localdomain
Whole thread Raw
List 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)


pgsql-general by date:

Previous
From: "Roger Hand"
Date:
Subject: Re: plpgsql: returning multiple named columns from function *simply*
Next
From: Ron Mayer
Date:
Subject: Re: ctid access is slow