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

Re: Auto-incrementing field

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Jim Steil <jim(dot)steil(at)customcall(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Auto-incrementing field
Date: 2002-07-29 14:34:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
On Fri, Jul 26, 2002 at 14:49:30 -0500,
  Jim Steil <jim(dot)steil(at)customcall(dot)com> wrote:
> Is there a data type in PostgreSQL that will 'auto-increment'?  I have used
> this in MS SQL Server in the past and would like to continue to do so with
> PostgreSQL.  Thanks for any help...

You probably want to use sequences. There is even a psuedo type "serial"
that makes using them easier.
Note that sequences provide unique values, but they can skip over values.
Normally this is OK for keys, but if you really want a counter then
you need to do something different.

In response to

pgsql-novice by date

Next:From: Jillian CarrollDate: 2002-07-29 16:14:32
Subject: Altering psqlodbc.h
Previous:From: WimDate: 2002-07-29 12:58:35
Subject: Still problems with pg_dump ad \dt...

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