Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: CREATE TABLE LIKE and SERIAL


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: Thom Brown <thombrown(at)gmail(dot)com>
  • Cc: Mark Morgan Lloyd <markMLl(dot)pgsql-general(at)telemetry(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org
  • Subject: Re: CREATE TABLE LIKE and SERIAL
  • Date: Fri, 30 Oct 2009 17:44:02 -0400
  • Message-id: <22535.1256939042@sss.pgh.pa.us> <text/plain>

Thom Brown <thombrown(at)gmail(dot)com> writes:
> Well I realise SERIAL is a convenience rather than a datatype in its
> own right, but I'm surprised that LIKE can't differentiate between a
> column created with integer and one created with serial.  The table
> continues to report a serial datatype after its creation.

Really?

regression=# create table foo (f1 serial);
NOTICE:  CREATE TABLE will create implicit sequence "foo_f1_seq" for serial column "foo.f1"
CREATE TABLE
regression=# \d foo
                         Table "public.foo"
 Column |  Type   |                    Modifiers                     
--------+---------+--------------------------------------------------
 f1     | integer | not null default nextval('foo_f1_seq'::regclass)

regression=# 

We used to try to treat serial as more like a real type (in particular
pg_dump used to try to dump the results of this using "serial") but we
found out that that was actively a bad idea, because there were too
many corner cases where it did the wrong thing.  I doubt we'll want
to go back in that direction.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group