15.8.2 When a column cannot be added to a base table
This subsection explains the steps to take when a column cannot be added to a base table by using the ALTER TABLE definition SQL statement.
In the following situations, you cannot add a column to a base table:
-
The target base table is non-updatable.
-
The target base table is a FIX table, and the segments for storing rows have been assigned to the table.
-
Segments for storing rows are assigned to the target base table for which the CREATE TABLE statement was executed with BRANCH ALL specified.
-
For a base table to which segments for storing rows are assigned, NOT NULL is specified in the column definition of the ALTER TABLE statement.
If a base table is non-updatable, release it from non-updatable status based on the explanation in 15.8.1 Steps to take when a base table becomes non-updatable. Then, re-execute the ALTER TABLE statement.
In other cases, add a column by performing the steps described in the following procedure.
- ■ Steps to take when a column cannot be added to a base table
-
-
Output data in the base table to a file.
Use the adbexport command to output all data from the base table to a file. An output data file is created. The output data file created here becomes the input data file used in steps 4 and 5.
-
Delete all row data from the base table.
Execute the TRUNCATE TABLE statement to delete all row data from the base table.
-
Add a column to the base table.
Add a column to the base table by re-executing the ALTER TABLE statement.
-
Edit the input data file.
Add the data to be stored in the column added in step 3 to the input data file created in step 1.
-
Store data in the base table.
Execute the adbimport command to store in the base table the data in the input data file that was edited in step 4.
-
- Note
-
For details about the status in which segments for storing rows are assigned, see 5.3.1 Notes on defining B-tree indexes (unfinished status of B-tree indexes).