I am trying to delete from a table that has few thousands of rows. I will like to commit the delete after each 1000. How would I specify that in my delete statement?
Originally posted by akwete Commit after every 1000 row delete from table.
I am trying to delete from a table that has few thousands of rows. I will like to commit the delete after each 1000. How would I specify that in my delete statement?
I think just doing the straight delete and using cursor are right answers. But here's another one. Find a numerical column that is well distributed with data.
example:
delete from tab1 where MOD(numeric_col_with_diverse_values,3) = 0;
3333 rows deleted
commit;
delete from tab1 where MOD(numeric_col_with_diverse_values,3) = 1;
3333 rows deleted
commit;
delete from tab1 where MOD(numeric_col_with_diverse_values,3) = 2;
3334 rows deleted
commit;
Ya' see what I mean about the numeric column being distributed evenly? You would not want:
9998 rows deleted
1 rows deleted
1 rows deleted
Search for delete_commit procedure in Metalink. It does exactly what you are looking for . It is also very helpfull to have and index on the fields which are used in delete statement because based on frequency of commits and number of rows it can take a long time to do full scans.
One, who thinks that the other one who thinks that know and does not know, does not know either!
We successfully deleted the rows using the delete_commit procedure found on Metalink (Note:37777.1: delete_commit procedure and
Note:1073480.6: How to Delete Blocks of records Using COMMIT).
Bookmarks