From: | "Natasha Galkina" <natasha(at)platsolns(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | rotate records |
Date: | 2006-02-25 00:31:48 |
Message-ID: | C2E6BA7FD3442A4C916735460ABB064F563758@bones.invent.psi.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello.
I'm using Postgresql 7.3 on Linux.
I created sequence
CREATE SEQUENCE event_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 5
START 1
CACHE 1
CYCLE;
And I created table which uses this sequence as primary key.
CREATE TABLE hw_messages
(
event_id INT PRIMARY KEY DEFAULT nextval(event_id_seq ') NOT NULL,
device_name varchar(50) NOT NULL
CONSTRAINT hw_messages_pkey PRIMARY KEY (event_id)
)
WITH OIDS;
My question is how I can rotate the records in the table. I have maximum
number of records in the table defined by sequence. Every time when I
try to insert a new record, I get an error about duplicate key. Even if
I manually delete a record somewhere from the middle I still might get
this error. If I state CYCLE attribute in the sequence, doesn't it mean
that while inserting new records into database if the maximum is met the
old records should be deleted? If it is not correct, how can I rotate
the records in the table?
Thanks you in advance,
Natasha.
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Winter | 2006-02-25 02:25:26 | Another perplexity with PG rules |
Previous Message | Jean-Christophe Roux | 2006-02-25 00:14:40 | "...unknown user name or bad password" error during install |