Change column from NOT LOGGED to LOGGED
Question
I have a database DAT1 running on DB2 version 10.5.
I want to enable logging for all CLOB and BLOB columns of my table TAB1.
The table was initially created with those columns as NOT LOGGED
but now I need to change it to LOGGED
.
I know there is the procedure ALTOBJ
that should be able to change this attribute. However I learned form the documentation that this procedure do the following:
The procedure backs up the data of the table being altered, then drops the original table and creates a new version using the DDL statement; the final step loads the stored data back into the new table.
I need to modify many tables and the size of each table normally reaches about 10GB or even more. This means that this operation may require a very large amount of free disk space plus the time needed to create the new table and copy back the data.
I'm wondering if this operation can be achieved also with a simple ALTER TABLE
or another command which doesn't involve creating or copying new data.
Solution
You cannot alter the LOGGED
attribute of a LOB column. However, you can alter the table by adding a new LOGGED
LOB column, update the new column from the existing column, then drop the original column. It may require less wasted disk space but is unlikely to be faster than using ALTOBJ
.