Tuesday 27 April 2010

db2 updates large number of records

Disable Logging while executing updates for large number of records:
alter table activate not logged initially;
update set column=value where ;

but with caution  :
take a backup of the table by exporting the table  before executing the above query . If anything goes wrong (that is if your transaction rolls back for any other reason) you will have to drop the table and loose all the data.
I have faced a problem when I didn't exercise caution and eventually I needed to restore the whole database which was such a pain in the neck!
Error message was like you cannot access the table as NOT Logged Initially disable the logging and when the query took longer than expected I killed the query and consequentially table was not accessible.

No comments:

Post a Comment