Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: FIFO table question
Alex Tait wrote:
>
> Is it possible to set up a table whereby, once a predefined number of rows
> has been added, the first row is deleted?
> There are no relations to the table, it's simply an event log.
> --
> Alex Tait
> Force12 Solutions Ltd
> ajt_at_force12.com
An approach that I have used is to create the log table with a simple
numeric key and and pre-populate it with the maximum number of rows you
are ever going to have (N).
Keep a counter (in a separate single-row sequence table) of the number
of real rows inserted so far (n).
No new rows are inserted into the log table, since each new log entry
actually updates the (n+1)th (next) row in the table and updates the
single-row sequence table, rolling over at N (=> 0)
BTW, I used this to store logged values at a rate far exceeding that which I could achieve with separate insert statements, since the only index used was on the simple primary key, which was never updated.
HTH
-- Chrysalis FABRICATI DIEM, PVNC ('To Protect and to Serve') Terry Pratchett : "Guards Guards"Received on Thu Oct 16 1997 - 00:00:00 CDT