To add a column to an existing table, use:
alter table table_name add column_name datatype [default {constant_expression} | user | null}] {[{identity | null | not null}] | [constraint constraint_name {constraint_clause}] [, column_name]
Where:
table_name is the table to which you are adding a column.
column_name is the column you are adding.
constant_expression is the constant to place in the row if a user does not specify a value (this value must be in quotes, unless the character type is an exact numeric type).
constraint_name is the constraint you are adding to the table.
constraint_clause is the full text of the constraint you are adding. You can add any number of columns using a single alter table statement.
For example, the following adds a non-null column named author_type, which includes the constant “primary_author” as the default value, and a null column named au_publisher to the authors table:
alter table authors add author_type varchar(20) default "primary_author" not null, au_publisher varchar(40) null
Copyright © 2005. Sybase Inc. All rights reserved. |