THe ALTER statement is used to change the structure of an existing table.


To add or change a table comment:

ALTER TABLE table_name COMMENT [=] 'new comment'

To change a column name or comment, use the following statement:

ALTER TABLE table_name CHANGE old_col_name new_col_name [COMMENT 'new comment']

or

ALTER TABLE table_name RENAME old_col_name TO new_col_name  [COMMENT 'new comment']

If a dimension table is created without keys, the user can also use ALTER statement to set the key in the table.

The general syntax is

ALTER TABLE table_name KEY(attribute1, attribute2, ...)

The syntax to add a column to a colume-based table is:

ALTER TABLE table ADD COLUMN column_name data_type

Case Example:

If the ABC company staff want to rename "state" attribute to "Home_State" in the Customer table, he can do this with following commands:

ALTER TABLE Customer CHANGE state Home_state

or

ALTER TABLE Customer RENAME state TO Home_state