Skip site navigation (1) Skip section navigation (2)

Re: autoincrement question

From: "Greg Cocks" <gcocks(at)stoller(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: autoincrement question
Date: 2008-01-07 22:52:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

-----Original Message-----
From: Richard Broersma Jr [mailto:rabroersma(at)yahoo(dot)com] 
Sent: Monday, January 07, 2008 3:40 PM
To: Jack Albright; Sean Davis
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: [NOVICE] autoincrement question

--- 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.


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

If you are using an existing field with existing (unique) values, make
sure that you (re)set the SERIAL's index to the next value that you want
to use...

In response to

pgsql-novice by date

Next:From: Oeschey, Lars (I/EK-142, extern)Date: 2008-01-08 09:51:11
Subject: Problem restoring database
Previous:From: Richard Broersma JrDate: 2008-01-07 22:39:39
Subject: Re: autoincrement question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group