July 28th, 2010 by depesz | Tags: conditional, create table, ddl, if not exists, pg91, postgresql, sql | 1 comment »
On 25th Robert Haas committed patch which adds first of ‘CREATE IF NOT EXISTS’ commands:
Log Message:
-----------
CREATE TABLE IF NOT EXISTS.
Reviewed by Bernd Helmle.
Example is of course trivial:
$ create table if not exists tesit (x text);
CREATE TABLE
$ create table if not exists tesit (x text);
NOTICE: relation "tesit" already exists, skipping
CREATE TABLE
As you can see there is no error – just a friendly notice.
Now. With some luck we’ll get the same for schemata, indexes, views and other db objects, and we’ll no longer need ugly workarounds.

One comment
Thank you Mr Haas!
one down a few more to go.