我不确定这个问题是否显而易见。我需要删除大量数据。删除是昂贵的。我需要截断表格但不完全截断,以便释放内存并更改水印。
是否有任何功能可以让我根据选择行的条件截断表格?
取决于你的餐桌是如何组织的。
1)如果您的(大)表是基于类似条件进行分区的(例如,您要删除上个月的数据并且您的表按月分区),您可以只截断该分区,而不是整个表。
2) 如果您有一些停机时间,另一种选择是将要保留的数据插入到临时表中,截断原始表,然后将数据加载回来。
insert into <table1>
select * from <my_table>
where <condition>;
commit;
truncate table my_table;
insert into my_table
select * from <table1>;
commit;
--since the amount of data might change considerably,
--you might want to collect statistics again
exec dbms_stats.gather_table_stats
(ownname=>'SCHEMA_NAME',
tabname => 'MY_TABLE');