Re: Serial Data Type - Mailing list pgsql-general

From Tom Lane
Subject Re: Serial Data Type
Date
Msg-id 23207.1207198841@sss.pgh.pa.us
Whole thread Raw
In response to Re: Serial Data Type  ("Adam Rich" <adam.r@sbcglobal.net>)
List pgsql-general
"Adam Rich" <adam.r@sbcglobal.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: PG 8.3.x doesn't get build
Next
From: Alban Hertroys
Date:
Subject: Re: Problem with planner choosing nested loop