如何快速删除oracle表一段时间之前的数据

1、首先 将这个月的数据导出到一个临时表中(这些数据是自己希望保留的)
create table tempTable as select id,name from table1 where sj>to_date('2013-7-31 23:59:59','yyyy-mm-dd hh24:mi:ss');
2、然后将2500万数据整个删除(这个是我在有备份情况下才用的)
truncate table table1;
3、然后将整个表删除(因为事先从网上查了下,有网友说truncate后,直接把数据从临时表导回来事个数据文件没有变小,自己没有试)
drop table table1;
4、将数据从临时表全部导回来
create table table1 as select id,name from tempTable;
5、然后删除临时表
drop table tempTable;
这样整个过程用了大概10分钟左右就完成了。

posted @ 2021-09-26 13:01  赵大豆  阅读(2070)  评论(0编辑  收藏  举报