I know this subject has come up many times but I am not finding what I
am looking for after a couple days of searching. I know some months
ago I saw an indirect solution for this but I cant seem to find it now
that I need it.
This is DB2 UDB V8.2 on AIX 5.3
I need to create a script (ksh) to update a large number of records.
This could be a million records so I need to do it in smaller chunks to
avoid the logging problem. I cant seem to find a way in DB2 to limit
the number of records I am deleting at a time. The tables do not have
a recnum type column that I can use to select by. I cannot add a new
column just for this purpose either since the tool is just to be used
to do some testing cleanup.
What I want to do is pretty basic:
db2 "UPDATE table1 SET column2 = -1" //for all records
or to reduce further:
db2 "UPDATE table1 SET column2 = -1 WHERE column2 <-1" //to only do
the ones that are not already set to that value
But I would like to do it in increments of 1000 records and commit. I
dont see a way to LIMIT 1000 or FIND FIRST 1000 in DB2.
I could SELECT all records by primarykey (this is a char value) and put
it in a file then do individual updates on each record, committing
every 1000 count but this seems like a very tedious, ineffecient way to
do it.
So...anyone have a better way?