| From: | Bruce Momjian <bruce(at)momjian(dot)us> |
|---|---|
| To: | David Johnston <polobo(at)yahoo(dot)com> |
| Cc: | pgsql-docs(at)postgresql(dot)org |
| Subject: | Re: Create Table ... Like Including Default & Sequences |
| Date: | 2014-01-25 19:33:21 |
| Message-ID: | 20140125193321.GB9750@momjian.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-docs |
On Thu, Jun 13, 2013 at 07:20:05PM -0700, David Johnston wrote:
> 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.
Oh, that is something I had not considered. I have applied the attached
doc patch for 9.4.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
| Attachment | Content-Type | Size |
|---|---|---|
| like.diff | text/x-diff | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vik Fearing | 2014-01-29 14:20:11 | Re: Links for upgraders |
| Previous Message | Bruce Momjian | 2014-01-23 03:27:29 | Re: Missing date_trunc docs |