I have an Oracle table which contains event log messages for an application. We don't want this table to grow out of control and eat up too much space, so we'd like to set a cap on the number of rows that it can contain to some big number like one million.
So we'd like to tell Oracle that when the table grows too large, it should delete the oldest rows to make space for new rows.
Is there any way to do this? I imagine we could do this with a trigger or by making all inserts with a stored procedure, but is there anything simpler?
EDIT: A couple of answers have suggested solutions that involve partitions. We do not currently partition this table, although we have the ability to do so if necessary. However, from looking into the matter, it seems that even if we partition the table, we'd still need for some kind of a scheduled job to drop the old partitions, etc. So we've decided to forgo partitions in favor of a scheduled job to check the row count and delete old rows as necessary once per day.
Thanks for the help, everyone.