Search Postgresql Archives

rotate records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

 

 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux