Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Ensuring Data Integrity » Using column defaults

Using column defaults Next Page

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.