public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Johnston <[email protected]>
To: [email protected]
Subject: Create Table ... Like Including Default & Sequences
Date: Thu, 13 Jun 2013 19:20:05 -0700 (PDT)
Message-ID: <[email protected]> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>
In the documentation for "Create Table" the following paragraph appears under
the definition for LIKE:
"Default expressions for the copied column definitions will only be copied
if INCLUDING DEFAULTS is specified. The default behavior is to exclude
default expressions, resulting in the copied columns in the new table having
null defaults."
I would like to suggest adding a sentence between the first and second:
Defaults created via the "serial" and "bigserial" construct - or that use
"nextval(...)" generally - are copied as-is resulting in both tables sharing
the same underlying sequence.
Note that this is technically contrary to the statement:
Unlike INHERITS, the new table and original table are completely decoupled
after creation is complete.
I'm working in 9.0 and noticed this incidentally when a FK constraint failed
but the expected ID was somewhere in the 10s while the actual was somewhere
upward of 80,000 which clued me into the fact that the original sequence was
being used.
As an aside it may be worth noting (or linking to) a quick way to change the
default on the new table if this is done in error and a correction is
desired. For my purposes I'll likely just leave it alone.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/Create-Table-Like-Including-Default-Sequences-tp5759108.html
Sent from the PostgreSQL - docs mailing list archive at Nabble.com.
--
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: Create Table ... Like Including Default & Sequences
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox