|
Home > Archive > PostgreSQL Discussion > August 2005 > drop table before create
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
drop table before create
|
|
| Mark Probert 2005-08-23, 8:24 pm |
| 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)
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
| |
| Lee Harr 2005-08-25, 8:24 pm |
| >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.
>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.
>
There are a couple of commands that may help you:
\set ON_ERROR_STOP
\unset ON_ERROR_STOP
____________________
____________________
____________________
_____
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/...1ave/direct/01/
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
| |
|
|
|
|
|