rotate records - Mailing list pgsql-general

From Natasha Galkina
Subject rotate records
Date
Msg-id C2E6BA7FD3442A4C916735460ABB064F563758@bones.invent.psi.com
Whole thread Raw
Responses Re: rotate records  (Michael Fuhr <mike@fuhr.org>)
List 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.

 

 

pgsql-general by date:

Previous
From: "Amrit Angsusing"
Date:
Subject: Re: Could DBmirror be done with the mechine using RPM installation instaed of souce code [tar.gz] ?
Next
From: Bruce Momjian
Date:
Subject: Re: How to specify infinity for intervals ?