Add Columns Appends Column IDs

alter table adds a column to the table with a column ID that is one greater than the current maximum column ID.

For example, this table lists the default column IDs of the salesdetail table:

Column Name

stor_id

ord_num

title_id

qty

discount

Col ID

1

2

3

4

5

This command appends the store_name column to the end of the salesdetail table with a column ID of 6:

alter table salesdetail
add store_name varchar(40) 
default
"unknown" not null

If you add another column, it will have a column ID of 7.

Note: Because a table’s column IDs change as columns are added and dropped, your applications should never rely on them.