Re: primary key generation

From: Wieger Uffink <wieger(at)usmedia(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: primary key generation
Date: 2001-12-11 18:45:14
Message-ID: 1008096314.1964.2.camel@barcelona.usmedia.nep
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

You need to create a sequence and set the default value of the primary
key on the next value in the sequence.

An easy way to do this is to define the primary key integer field as
type SERIAL ( instead of integer) at time of table creation.
Postgres will automaticly create the sequence it needs, and set the
default value of the key to the proper value.

HTH,
Wieger

On Mon, 2001-12-10 at 22:58, Ned Matson wrote:
> Does postgres have any built-in methods for auto-generating unique integer
> primary keys or is managing this task the responsibility of the user?
>
> Thanks in advance...
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-12-11 18:55:36 Re: Need SQL help, I'm stuck.
Previous Message Doug McNaught 2001-12-11 18:42:41 Re: primary key generation