Search Postgresql Archives

Re: CREATE TABLE LIKE and SERIAL

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

 



Tom Lane wrote:

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.

That's entirely fair, and the manual section dealing with types is very careful to start off with "The data types serial and bigserial are not true types".

However I think that the description of CREATE TABLE ... LIKE really could do with a "health warning" for this case.

Looking at this very slightly deeper and assuming that the user is aware of the pitfalls, it's obviously easy for him to create a new sequence and to use it as the default value. But what if he wants the new sequence to inherit the current state of an existing one: might I suggest CREATE SEQUENCE ... LIKE would be appropriate here?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
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