Re: primary key generation - Mailing list pgsql-general

From Wieger Uffink
Subject Re: primary key generation
Date
Msg-id 1008096314.1964.2.camel@barcelona.usmedia.nep
Whole thread Raw
In response to primary key generation  ("Ned Matson" <ned@go.com>)
List 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
>



pgsql-general by date:

Previous
From: "Gregory Wood"
Date:
Subject: Re: Help with inner/outer join
Next
From: Doug McNaught
Date:
Subject: Re: primary key generation