Re: CREATE SCHEMA IF NOT EXISTS
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: David E. Wheeler <david@justatheory.com>
Cc: Dickson S. Guedes <listas@guedesoft.net>, fabriziomello <fabriziomello@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2012-10-02T19:52:15Z
Lists: pgsql-hackers
Excerpts from David E. Wheeler's message of mar oct 02 16:37:30 -0300 2012:
> On Oct 2, 2012, at 12:30 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
>
> > How about call this for precedent:
> >
> > mkdir -p /tmp/foo/bar
> > mkdir -p /tmp/foo/baz
> >
> > In this case you end up with directory "foo" and at least two subdirs in
> > it, bar and baz. This works even if /tmp/foo existed previously and
> > even if there was some other stuff in it.
>
> Well, what about this, then?
>
> create schema if not exists foo create table second (a int);
> create schema if not exists foo create table second (b int);
Yes, exactly -- what about this case? This is precisely the reason we
don't have CREATE TABLE IF NOT EXISTS.
I don't know what the best answer is. Most people seem to think that
the answer ought to be that you end up with a single column second.a,
and the second command errors out.
So if you do this:
create schema if not exists foo create table first (a int);
create schema if not exists foo create table first (b int),
create table second (a int);
you end up with *only* the first table, because the second command
errors out when the first table is observed to exist.
Now, what if you were to do this instead:
create schema if not exists foo
create table if not exists first (a int);
create schema if not exists foo
create table if not exists first (b int),
create table if not exists second (a int);
The you end up with first.a and second.a.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Document the lack of reading the PGDATABASE environment variable in
- 483c2c1071c4 9.3.0 cited