Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Deleting Record 3 months and older

liangtehMay 17 2009 — edited May 19 2009
Hi All,

I would like to select all record which are older than 3 months for deletion, however due to the record size of the table(20mil) I would like to delete it by batches.

1. I would select records older than 3 months
2. I would pick the oldest record to date using min(column)
3. I would add +14 days to the where condition to delete only 2 weeks of data

Is there any better ways I can rewrite my delete statement?


with record_older_than_three_months as
(
select * from table where column < add_months(sysdate, -3)
)
delete from record_older_than_three_months where column between min(column) and min(column) + 14
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2009
Added on May 17 2009
7 comments
6,377 views