Oracle 5.0 Reference Manual page 866

Table of Contents

Advertisement

The following table contains several
CREATE TABLE t
(
ts1 TIMESTAMP NULL DEFAULT NULL,
ts2 TIMESTAMP NULL DEFAULT 0,
ts3 TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
);
A
TIMESTAMP
except under one of the following conditions:
• Its default value is defined as
CURRENT_TIMESTAMP
into the column
In other words, a
includes
DEFAULT
CREATE TABLE t (ts TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP);
If the
TIMESTAMP
CURRENT_TIMESTAMP, you must explicitly insert a value corresponding to the current date and time.
Suppose that tables
CREATE TABLE t1 (ts TIMESTAMP NULL DEFAULT '0000-00-00 00:00:00');
CREATE TABLE t2 (ts TIMESTAMP NULL DEFAULT NULL);
To set the
TIMESTAMP
that value. For example:
INSERT INTO t1 VALUES (NOW());
INSERT INTO t2 VALUES (CURRENT_TIMESTAMP);
11.1.5.6. Fractional Seconds in Time Values
A trailing fractional seconds part is permissible for temporal values in contexts such as literal values,
and in the arguments to or return values from some temporal functions. Example:
mysql>
SELECT MICROSECOND('2010-12-10 14:12:09.019473');
+-------------------------------------------+
| MICROSECOND('2010-12-10 14:12:09.019473') |
+-------------------------------------------+
|
+-------------------------------------------+
However, when MySQL stores a value into a column of any temporal data type, it discards any
fractional part and does not store it.
11.1.5.7. Conversion Between Date and Time Types
To some extent, you can convert a value from one temporal type to another. However, there may be
some alteration of the value or loss of information. In all cases, conversion between temporal types
is subject to the range of legal values for the resulting type. For example, although DATE, DATETIME,
and
TIMESTAMP
have the same range of values.
'2038-01-19 03:14:07'
or
DATE
DATETIME
Conversion of
• Conversion to a
value contains no time information.
DATE
• Conversion to a
Date and Time Types
TIMESTAMP
column that permits
NULL
CURRENT_TIMESTAMP
[918]
or any of its synonyms such as
column defined to permit
TIMESTAMP
CURRENT_TIMESTAMP:
column permits
NULL
and
have these definitions:
t1
t2
column in either table to the current timestamp at insert time, explicitly assign it
values all can be specified using the same set of formats, the types do not all
TIMESTAMP
UTC. This means that a date such as '1968-01-01', while legal as a
value, is not valid as a
values:
DATE
or
DATETIME
TIMESTAMP
value is not useful; the result is '00:00:00'.
TIME
columns that permit
values does not take on the current timestamp at insert time
[918]
and no value is specified for the column
values auto-initializes only if its definition
NULL
values but its definition does not include
19473 |
values cannot be earlier than
value and is converted to 0.
TIMESTAMP
value adds a time part of
846
values:
NULL
[926]
is explicitly inserted
NOW()
DEFAULT
UTC or later than
1970
because the
'00:00:00'

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents