Creation of a unique id

From: brian(dot)walsh(at)ss8(dot)com
To:
Subject: Creation of a unique id
Date: 2002-01-11 17:38:53
Message-ID: 88256B3E.0060C498.00@notes.centigram.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Seem to be getting some error messages back regarding this message so just
resending it.
---------------------- Forwarded by Brian Walsh/US/Centigram on 01/11/2002
09:41 AM ---------------------------

Brian Walsh 01/10/2002 05:02 PM
(Embedded image moved to file: pic13896.pcx)

To: pgsql-general(at)postgresql(dot)org(dot)
cc:
Subject: Creation of a unique id

Hi,
I am using the "CREATE SEQUENCE" combined with nextval() to generate a
unique id as below.

create sequence brian_seq minvalue 32000 maxvalue 32005 CACHE 5 CYCLE;

create table btest
(bar INT PRIMARY KEY DEFAULT nextval('brian_seq'), name TEXT);

My problem comes from the re-use of id's from deleted records.
Lets say Ihave records 1-5 and during the first loop I do the following

INSERT 1...
INSERT 2...
INSERT 3...
DELETE 2...
INSERT 4
INSERT 5

How do I get the database to know the next available msgid available is now
2?
Regards,

Brian

Attachment Content-Type Size
pic13896.pcx application/octet-stream 4.7 KB

Browse pgsql-general by date

  From Date Subject
Next Message Frank Joerdens 2002-01-11 18:38:01 Does pg_dumpall do BLOBs too?
Previous Message Tom Lane 2002-01-11 17:28:43 Re: problem making postgresql