ASA SQL User's Guide
Working with Database Objects
Working with tables
Altering tables
You can alter tables in Interactive SQL using the ALTER TABLE statement.
To alter an existing table (SQL)
Connect to the database with DBA authority.
Execute an ALTER TABLE statement.
The following command adds a column to the skill table to allow space for an optional description of the skill:
ALTER TABLE skill ADD skill_description CHAR( 254 )
This statement adds a column called skill_description that holds up to a few sentences describing the skill.
You can also modify column attributes with the ALTER TABLE statement. The following statement shortens the skill_description column of the sample database from a maximum of 254 characters to a maximum of 80:
ALTER TABLE skill MODIFY skill_description CHAR( 80 )
Any current entries that are longer than 80 characters are trimmed to conform to the 80-character limit, and a warning appears.
The following statement changes the name of the skill_type column to classification:
ALTER TABLE skill RENAME skill_type TO classification
The following statement deletes the classification column.
ALTER TABLE skill DROP classification
The following statement changes the name of the entire table:
ALTER TABLE skill RENAME qualification
These examples show how to change the structure of the database. The ALTER TABLE statement can change just about anything pertaining to a table—you can use it to add or delete foreign keys, change columns from one type to another, and so on. In all these cases, once you make the change, stored procedures, views and any other item referring to this table will no longer work.
For more information, see ALTER TABLE statement, and Ensuring Data Integrity.