DEFAULT Specification (default_spec)
A DEFAULT
specification (default_spec
)
is formed by specifying the keyword DEFAULT
and
a DEFAULT
value. The maximum length of a default
value is 254 characters.
Syntax
<default_spec> ::=
DEFAULT <literal>
| DEFAULT NULL
| DEFAULT USER
| DEFAULT USERGROUP
| DEFAULT SYSDBA
| DEFAULT DATE
| DEFAULT TIME
| DEFAULT TIMESTAMP
| DEFAULT UTCDATE
| DEFAULT UTCDIFF
| DEFAULT TIMEZONE
| DEFAULT TRUE
| DEFAULT FALSE
| DEFAULT TRANSACTION
| DEFAULT STAMP
| DEFAULT SERIAL[<unsigned_integer>]SQL Tutorial, Number Generator for a Single Column of a Table
If a DEFAULT
specification has been
made for a column, the default value (<literal>
, NULL
, USER
,...) must be a value that can be inserted in the column.
DEFAULT Specification |
Explanation |
|---|---|
|
The literal must be comparable with the data type of the column. |
|
Returns the name of the current database user and can only be specified for columns that have the data type [VAR]CHAR(n) or CHAR(n) (n >= 32) |
|
Returns the user group name for members of a user group, or the
user name for database users that do not belong to a user group. This |
|
Returns the name of the database administrator and can only be
specified for columns of the data type |
|
Returns the current date and
can only be specified for columns of the data type |
|
Returns the current time and
can only be specified for columns of the data type |
|
Returns the current time
stamp and can only be specified for columns of the data type |
|
Returns the current |
|
Returns the time difference (in hours) between your local time
and |
|
Returns the time difference in the format hhmmss between your local
time and |
|
Can only be specified for columns of the data type BOOLEAN. |
|
Returns the identification of the current transaction and can only be specified for columns of the data type |
|
Returns a value of eight characters in length that is unique within
the database system and can only be specified for columns of the data type If a table is defined without a key column, the database system
creates a key column |
|
Delivers a number generator for positive integers and can only
be specified for columns that have the data type INTEGER, SMALLINT,
and The first value generated by the generator can be defined by specifying
an unsigned integer ( If the value 0 is inserted in this column by an Each table may not contain more than one column with the |
Specifying the DEFAULT
specification DEFAULT
SERIAL(n)
or the data type SERIAL(n)
causes
a number generator to be generated that creates positive whole numbers implicitly
from 1 or from a prespecified value starting with n.
The data type SERIAL(n)
can be used
as a DEFAULT
specification for columns which
can only contain fixed point numbers or decimal places, as SERIAL(n)
is
mapped to FIXED(10) DEFAULT SERIAL(n)
.
The maximum number generator value generated is (10**m)-1
if
the default specification DEFAULT SERIAL
is
defined for a column of the data type FIXED(m)
.
SERIAL
columns can only be assigned
a value when a row is inserted. The values of a SERIAL
column
cannot be changed with an UPDATE
statement.
A SERIAL
column, therefore, can be used to
determine the insertion sequence and identify a row in a table uniquely.