Re: autoincrement question

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Jack Albright <jack(at)mobiusnm(dot)com>, Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: autoincrement question
Date: 2008-01-07 22:39:39
Message-ID: 305351.87756.qm@web31808.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

--- On Mon, 1/7/08, Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> wrote:


> create table junktable (
> pk1 serial primary key
> );
>
> will get you what you want. Check out the docs for the
> "serial" column type.

Also, if the table and column already exist, you can alter the table's column to become an auto-incrementing column.

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

You can substitute the create table statement with an appropriate alter table alter column statement from the example demonstrated in the above link.

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Greg Cocks 2008-01-07 22:52:45 Re: autoincrement question
Previous Message Sean Davis 2008-01-07 21:12:36 Re: autoincrement question