Search Postgresql Archives

Re: CREATE TABLE LIKE and SERIAL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thom Brown <thombrown@xxxxxxxxx> writes:
> I can see why you wouldn't expect it to end up sharing the same
> sequence.  If you were to manually create a sequence and wanted to use
> it on a column, you probably wouldn't bother using the SERIAL
> datatype, but use integer instead.  So really since we know the first
> table has a datatype of SERIAL on one of its columns, we might instead
> wish to have it create a new implicit sequence instead of merely
> converting it to an INTEGER datatype and adding a default constraint
> to the same sequence as the original table.

Thinking of SERIAL as a type is your first mistake ;-).  It is not a
type.  It is a shorthand for making a sequence and sticking a suitable
default on a plain integer column.  So what LIKE sees is an integer
column with a default, and it copies that.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux