Creating column defaults

You can use the CREATE TABLE statement to create column defaults at the time a table is created, or the ALTER TABLE statement to add column defaults at a later time.

Example

The following statement adds a default to an existing column named ID in the SalesOrders table, so that it automatically increments (unless a client application specifies a value). Note that in the SQL Anywhere sample database, this column is already set to AUTOINCREMENT.

ALTER TABLE SalesOrders
ALTER ID DEFAULT AUTOINCREMENT;

For more information, see ALTER TABLE statement and CREATE TABLE statement.