Oracle 5.0 Reference Manual page 864

Table of Contents

Advertisement

if all other columns are set to their current values. To prevent the column from updating when
other columns change, explicitly set it to its current value. To update the column even when
other columns do not change, explicitly set it to the value it should have (for example, set it to
CURRENT_TIMESTAMP
In addition, you can initialize or update any
assigning it a
value, unless it has been defined with the
NULL
To specify automatic properties, use the
CURRENT_TIMESTAMP
column definition, either can occur first. Any of the synonyms for
the same meaning as
CURRENT_TIMESTAMP
[926],
NOW()
LOCALTIME
[925].
LOCALTIMESTAMP()
Use of
DEFAULT CURRENT_TIMESTAMP
TIMESTAMP. The
DEFAULT
value; for example,
DEFAULT 0
Note
The following examples that use
NO_ZERO_DATE
"zero" date values (specified, for example, as
to be rejected. Be aware that the
NO_ZERO_DATE
The following rules describe the possibilities for defining the first
current timestamp for both the default and auto-update values, for one but not the other, or for neither:
• With both
DEFAULT CURRENT_TIMESTAMP
has the current timestamp for its default value and is automatically updated to the current timestamp.
CREATE TABLE t1 (
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
• With neither
DEFAULT CURRENT_TIMESTAMP
same as specifying both
CREATE TABLE t1 (
ts TIMESTAMP
);
• With a
clause but no
DEFAULT
given default value and is not automatically updated to the current timestamp.
The default depends on whether the
value. With CURRENT_TIMESTAMP, the default is the current timestamp.
CREATE TABLE t1 (
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
With a constant, the default is the given value. In this case, the column has no automatic properties
at all.
CREATE TABLE t1 (
ts TIMESTAMP DEFAULT 0
);
• With an
ON UPDATE CURRENT_TIMESTAMP
automatically updated to the current timestamp and has the given constant default value.
Date and Time Types
[918]).
TIMESTAMP
DEFAULT CURRENT_TIMESTAMP
clauses. The order of the clauses does not matter. If both are present in a
[918]. These are
[925],
LOCALTIME()
and
clause also can be used to specify a constant (nonautomatic) default
or
DEFAULT '2000-01-01
[538]
SQL mode is enabled because that mode causes
[538].
DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
DEFAULT
844
column to the current date and time by
attribute to permit
NULL
CURRENT_TIMESTAMP
CURRENT_TIMESTAMP()
[925],
LOCALTIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
00:00:00'.
do not work if the
DEFAULT 0
0 '0000-00-00
[540]
TRADITIONAL
TIMESTAMP
and
CURRENT_TIMESTAMP, the column
ON UPDATE
nor
CURRENT_TIMESTAMP, it is the
ON UPDATE
and
ON UPDATE
clause specifies
CURRENT_TIMESTAMP
clause and a constant
values.
NULL
and
ON UPDATE
[918]
[918],
[925], and
is specific to
00:00:00')
SQL mode includes
column in a table with the
CURRENT_TIMESTAMP.
clause, the column has the
or a constant
clause, the column is
DEFAULT
have

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents