Re: Serial Data Type

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'Naz Gassiep'" <naz(at)mira(dot)net>, "'pgSQL - General'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Serial Data Type
Date: 2008-04-03 03:22:11
Message-ID: 0a3901c89539$e8432c50$b8c984f0$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> 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

> It'll maintain the
> transactional safety of a serial created default, right? I.e., it'll
> not rollback seq values on a transaction abortion will it?

Yes

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2008-04-03 04:18:53 Re: Serial Data Type
Previous Message Naz Gassiep 2008-04-03 03:12:37 Serial Data Type