Re: Serial Data Type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
Cc: "'Naz Gassiep'" <naz(at)mira(dot)net>, "'pgSQL - General'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Serial Data Type
Date: 2008-04-03 05:00:41
Message-ID: 23207.1207198841@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Adam Rich" <adam(dot)r(at)sbcglobal(dot)net> writes:
>> I have just created a table using SELECT INTO however the PK was
>> supposed to be a serial. It is now an integer. To make it a serial I
>> just create the seq and set the default to be the nextval() of that
>> sequence right? is there anything else I need to do?

> You'll want to do this:
> ALTER SEQUENCE table_col_id_seq OWNED BY table.col_id;
> http://www.postgresql.org/docs/8.3/interactive/sql-altersequence.html

That's correct as far as it goes, but the OP might benefit more from
reading the description of what a "serial" column really is:

http://www.postgresql.org/docs/8.3/interactive/datatype-numeric.html#DATATYPE-SERIAL

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2008-04-03 06:34:29 Re: Problem with planner choosing nested loop
Previous Message Tom Lane 2008-04-03 04:37:59 Re: PG 8.3.x doesn't get build