Skip site navigation (1) Skip section navigation (2)

drop table if exists

From: Kevin Coyner <kevin(at)rustybear(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: drop table if exists
Date: 2003-03-05 19:09:03
Message-ID: 20030305190903.GA20607@rustybear.com (view raw or flat)
Thread:
Lists: pgsql-novice
In MySQL, when I create a new table from a .sql file, I usually start
with:

DROP TABLE IF EXISTS sometable;
CREATE TABLE sometable(


This doesn't work in Postgres and I haven't been able to find the
equivalent in the docs.  If I try to drop a table that doesn't exist, I
get an error message, so having that modifier "... if exists ..." is
nice.  

Is there an equivalent to "IF EXISTS" in Postgres?

Hoping someone can steer me in the right direction.

Thanks
Kevin

-- 
Kevin Coyner
mailto: kevin(at)rustybear(dot)com
GnuPG key: 1024D/8CE11941

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2003-03-05 21:38:00
Subject: Re: ALTER TABLE DROP COLUMN
Previous:From: glennDate: 2003-03-05 18:03:02
Subject: ALTER TABLE DROP COLUMN

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group