Re: Create unique field.. - Mailing list pgsql-novice

From Giorgio A.
Subject Re: Create unique field..
Date
Msg-id 002b01c0ef9c$955535a0$0201a8c0@casa
Whole thread Raw
In response to Create unique field..  ("Williams, Travis L, NPONS" <tlw@att.com>)
List pgsql-novice
try this:

CREATE SEQUENCE "a_name_for_the_seq" start 1 increment 1 maxvalue 2147483647
minvalue 1  cache 1 ;

and when creating a table, add as the first column the following:

"id" int4 DEFAULT nextval('a_name_for_the_seq'::text) NOT NULL

the value of this column will be unique and autoincremental. Plz note that
you won't specify the value of this column when you'll do your INSERT.

hope this helps
bye
Giorgio A.

----- Original Message -----
From: "Williams, Travis L, NPONS" <tlw@att.com>
To: <pgsql-novice@postgresql.org>
Sent: Thursday, June 07, 2001 9:58 PM
Subject: [NOVICE] Create unique field..


> All,
> I'm not sure if I'm on the right track here.. I want to create a
> column that is automatically filled in with a unique number when a row is
> created.. I thought that creating a sequence would do this.. and then
> creating a column with a default of nextval('seqname') but it isn't doing
> anything.. any help is appreciated...
>
> Thanks,
> Travis L. Williams
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl


pgsql-novice by date:

Previous
From: "Williams, Travis L, NPONS"
Date:
Subject: Create unique field..
Next
From: Jason Earl
Date:
Subject: Re: Create unique field..