• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delete operation as small chunks on records?

 
ramakanth boga
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table consists of 10000 records. i want to delete these records, if i tried to delete those records at a time, database fail out of log space.
So, I want to delete these 10000 records as smaller chunks.
i am using DB2.

Can anyone help me to delete the records in smaller chunks?

thanks,
ramakanth
[ July 01, 2006: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34202
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramakanth,
In general:
You could add a where clause to your delete statement on the primary key. For example,
delete from table where myPrimaryKey < X. Then increment X in groups of whatever the database can handle.

In db2:
There is a way of telling the database to commit after a certain number of operations for a bulk operation. I've used it when importing a large data file from the control center. (There's a textfield for the # of records to commit after.) I'm sure this translates into SQL somehow. Try looking in the db2 document for the syntax.
 
ramakanth boga
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the response.
delete from table where myPrimaryKey < X. the value of X is needs to increment untill it reaches the end. do have any syntax to increment the value of X.

bye
ramakanth boga
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34202
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramakanth,
The value of X depends on the logic for your primary key.

For example, assuming you are using a numeric primary key: You could first do a query to find the maximum value of that key. Then you could increment X in groups of 1000 until you get to that maximum.
 
ramakanth boga
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the response. i'll try to do it if any problems comes then i c u.
ramakanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic