The column attribute change definition (CHANGE column-name) of the ALTER TABLE definition SQL statement cannot be used to change a column to a compressed column. Instead, you must use the procedure below to convert columns in an existing table to compressed columns.
To convert columns to compressed columns:
- Unload the existing table.
Unload the existing table.
- Delete the existing table.
Use DROP TABLE to delete the existing table.
- Redefine the table.
Use CREATE TABLE to redefine the table with the compression specification made for each column that is to be changed to a compressed column. Do not make any changes other than to add the compression specification.
- Reload the table.
Reload the unload data file that was unloaded in step 1 to the table that was redefined in step 3.
For details about unloading and reloading data, see the manual HiRDB Version 9 Command Reference.
- Reference note
- When the column to be changed to a compressed column is the last column of a table, steps 2 and 3 above can be replaced with the following step:
- Delete the existing column and add a compressed column
Use PURGE TABLE to remove all data from the table and then the column deletion definition (DROP column-name) of ALTER TABLE to delete the column that is to be changed to a compressed column. Next, use the column addition definition (ADD column-name) of ALTER TABLE to redefine (add) the table using the compression specification for the column that was deleted.