Oracle 5.0 Reference Manual page 865

Table of Contents

Advertisement

CREATE TABLE t1 (
ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
);
• With an
ON UPDATE CURRENT_TIMESTAMP
automatically updated to the current timestamp. The default is 0 unless the column is defined with
the
NULL
CREATE TABLE t1 (
ts TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
CREATE TABLE t2 (
ts TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP -- default NULL
);
It need not be the first
current timestamp. However, to specify automatic initialization or updating for a different
column, you must suppress the automatic properties for the first one. Then, for the other
column, the rules for the
column, except that if you omit both clauses, no automatic initialization or updating occurs.
To suppress automatic properties for the first
• Define the column with a
• Specify the
you cannot assign the current timestamp by setting the column to NULL. Assigning
column to NULL.
Consider these table definitions:
CREATE TABLE t1 (
ts1 TIMESTAMP DEFAULT 0,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
CREATE TABLE t2 (
ts1 TIMESTAMP NULL,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
CREATE TABLE t3 (
ts1 TIMESTAMP NULL DEFAULT 0,
ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
The tables have these properties:
• In each table definition, the first
• The tables differ in how the
assigning it a value of
assigning it a value of
and
t2
t3
is also
NULL
explicit default of 0.
Initialization and the
TIMESTAMP
By default,
TIMESTAMP
assigns the current timestamp. To permit a
it with the
NULL
a
DEFAULT
specify
NULL
DEFAULT NULL
NULL, not to the current timestamp.
attribute, in which case the default is NULL.
TIMESTAMP
DEFAULT
DEFAULT
attribute. This also causes the column to permit
NULL
ON UPDATE CURRENT_TIMESTAMP);
ON UPDATE CURRENT_TIMESTAMP);
ON UPDATE CURRENT_TIMESTAMP);
TIMESTAMP
column handles
ts1
sets it to the current timestamp. For
NULL
sets it to NULL.
NULL
differ in the default value for ts1. For t2,
in the absence of an explicit
Attribute
NULL
columns are
attribute. In this case, the default value also becomes
clause that specifies a different default value.
as the default value. (For a
is illegal.) If a
TIMESTAMP
Date and Time Types
clause but no
-- default 0
column in a table that is automatically initialized or updated to the
and
clauses are the same as for the first
ON UPDATE
TIMESTAMP
clause that specifies a constant default value.
column has no automatic initialization or updating.
values. For t1,
NULL
ts1
clause. For t3,
DEFAULT
NULL, cannot contain
NOT
column to contain NULL, explicitly declare
TIMESTAMP
DEFAULT NULL
column not declared with the
TIMESTAMP
column permits
845
clause, the column is
DEFAULT
column, do either of the following:
values, which means that
NULL
is
ts1
NOT NULL
and t3,
t2
ts1
is defined to permit NULL, so the default
permits
ts1
values, and assigning
NULL
unless overridden with
NULL
can be used to explicitly
values, assigning
NULL
TIMESTAMP
TIMESTAMP
TIMESTAMP
sets the
NULL
and
permits
and
NULL
but has an
NULL
NULL
attribute,
NULL
sets it to
NULL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents