You can use the CREATE TABLE statement
to create column defaults when a table is created, or the ALTER
TABLE statement to add column defaults later.
You can also specify a default
value when creating a user-defined domain (data type) using the CREATE
DOMAIN statement.
The stored procedure sp_iqcolumn returns
information abut all columns for all tables. One of the column returned
by the result set of sp_iqcolumn is
called “default,” and shows the particular default
value for that column.
- Create a table named tab1 with the default
special value LAST USER specified for the
CHARACTER column c1:
CREATE TABLE tab1(c1 CHAR(20) DEFAULT LAST USER)
- Add a condition to an existing column named id in the
sales_order table, so that the value of the column
automatically increments (unless a client application specifies a value):
ALTER TABLE sales_order MODIFY id DEFAULT AUTOINCREMENT
- Define a domain named dom1 with a data type of
INTEGER and a default value of 45:
CREATE DOMAIN dom1 INTEGER DEFAULT 45