Hitachi

Hitachi Advanced Database Setup and Operation Guide


11.1.2 Adding a column to a base table

To add a column to a base table, execute the ALTER TABLE definition SQL statement.

The HADB user who defined the base table can use the ALTER TABLE statement to add a column.

Only a single column can be added, and it is added after the last column in the base table. Null values are stored in the added column.

The following shows a specification example of adding a column to a base table.

Specification example

The column name EMAIL_ADDRESS is added to the shop table (SHOPSLIST). The data type of the column name EMAIL_ADDRESS is set to VARCHAR(100).

ALTER TABLE "SHOPSLIST"
    ADD COLUMN "EMAIL_ADDRESS" VARCHAR(100)

[Figure]

When you execute the ALTER TABLE statement, you can also specify NOT NULL or BRANCH for the column definition. For details about the specification format and rules for the ALTER TABLE statement, see ALTER TABLE (alter table definition) in Definition SQL in the manual HADB SQL Reference.

You cannot use the ALTER TABLE statement to add a column in the following situations:

If a column cannot be added because one of the preceding cases applies, see 15.8.2 When a column cannot be added to a base table.

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).