| 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: | 2009-10-30 21:20:15 |
| Message-ID: | 22056.1256937615@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgadmin-hackers pgsql-general |
Thom Brown <thombrown(at)gmail(dot)com> 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thom Brown | 2009-10-30 21:37:05 | Re: CREATE TABLE LIKE and SERIAL |
| Previous Message | Thom Brown | 2009-10-30 19:17:05 | Re: CREATE TABLE LIKE and SERIAL |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2009-10-30 21:25:43 | Re: Rewriting select statements |
| Previous Message | Scott Bailey | 2009-10-30 20:09:30 | Re: Absolute value of intervals |