oracle batch delete record
DECLARE
batch_size NUMBER := 10000;
BEGIN
LOOP
DELETE FROM table_name
WHERE rownum <= batch_size and create_time<=timestamp'2024-10-16 22:00:00';
EXIT WHEN SQL%ROWCOUNT = 0;
COMMIT;
DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' rows');
END LOOP;
END;
-- 最后执行shrink space 压缩空间
alter table XXX_TABLE enable row movement;
alter table XXX_TABLE shrink space;
alter table XXX_TABLE disable row movement;
发布时间:2024-10-17 00:00:00
关键词:oracle batch delete record
浏览量:0