Reputation: 615
I have a very simple table, on Oracle 10g, that keeps the log messages from a process. This table generates about 1 GB per day. I would like to keep just 1 week of data.
What is the best approach to accomplish this? Create a procedure that continuously delete the old data? Do I need to use partitions?
I can delete/truncate/drop the entire table if necessary.
This is the table:
CREATE TABLE "TABLE_LOGS"
(
"TABLE_ID" VARCHAR2(200 BYTE),
"TABLE_NUMBER" NUMBER(19,0),
"DESCRIPTION" VARCHAR2(2000 BYTE),
"DATE" TIMESTAMP (6),
"TYPE" VARCHAR2(100 BYTE),
"LEVEL" NUMBER(*,0)
)
Upvotes: 0
Views: 108
Reputation: 414
delete table_logs where date > sysdate - 7;
commit;
This should take less than 1 minute, if you DB is well tuned.
Upvotes: 2
Reputation: 4424
It's not mandatory, but partitioning can be an effective strategy. The term Information Lifecycle Management (ILM) is often used. If you create the table range partitioned by day, then you can simply truncate/drop the oldest partition, so that you only have 7 (or 8) active partitions. The advantages of this are
Upvotes: 2