How to auto create a unique key for each newly added record?

Started by Jeff Luabout 25 years ago3 messagesgeneral
Jump to latest
#1Jeff Lu
jklcom@mindspring.com

Hi,

How to if it is possible to let postgresql to auto assign unique key to each
new record that is added to the database?

Thanks

#2Zak McGregor
zak@mighty.co.za
In reply to: Jeff Lu (#1)
Re: How to auto create a unique key for each newly added record?

On Mon, 26 Mar 2001 21:20:13 -0500
"Jeff" <jklcom@mindspring.com> wrote:

Hi,

How to if it is possible to let postgresql to auto assign unique key to each
new record that is added to the database?

Just set up the table with the field you are wanting to have as a unique id as type "serial".

eg:

create table auto_id (id serial, description varchar(32));

Cheers

Zak

#3Prasanth Kumar
kumar1@home.com
In reply to: Jeff Lu (#1)
Re: How to auto create a unique key for each newly added record?

Make a column of type SERIAL. See
http://www.postgresql.org/docs/aw_pgsql_book/node88.html

----- Original Message -----
From: "Jeff" <jklcom@mindspring.com>
To: <pgsql-general@postgresql.org>
Sent: Monday, March 26, 2001 6:20 PM
Subject: [GENERAL] How to auto create a unique key for each newly added
record?

Hi,

How to if it is possible to let postgresql to auto assign unique key to

each

Show quoted text

new record that is added to the database?

Thanks

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html