Re: CREATE DATABASE IF NOT EXISTS in PostgreSQL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: CREATE DATABASE IF NOT EXISTS in PostgreSQL
Date: 2022-02-27 17:53:00
Message-ID: 2374553.1645984380@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Japin Li <japinli(at)hotmail(dot)com> writes:
> Why don't support CREATE DATABASE IF NOT EXISTS syntax in PostgreSQL?

FWIW, I'm generally hostile to CREATE IF NOT EXISTS semantics across
the board, because of its exceedingly squishy semantics: it ensures
that an object by that name exists, but you have exactly no guarantees
about its properties or contents. The more complex the object, the
bigger that problem becomes ... and a whole database is the most
complex sort of object we have. So IMV, the fact that we don't have
this "feature" is a good thing.

We do have DROP DATABASE IF EXISTS, and I think using that followed
by CREATE is a much better-defined approach.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2022-02-27 18:07:16 Re: Commitfest manager for 2022-03
Previous Message Tom Lane 2022-02-27 17:42:56 Re: support for MERGE