MySQL Variables timestamp 数据库 参数变量解释及正确配置使用

本站中文解释

MySQL的timestamp参数用于控制时间戳列。当在表中定义一个时间戳列时,它将自动设置为当前时间(或者最新更新时间)。对于其他类型(比如INT),不会自动更新,除非我们手动更新它。

它的设置可以通过MySQL的CREATE TABLE语句来完成,如下所示:

CREATE TABLE tablename (
ColumnOne timestamp,
ColumnTwo INT
);

官方英文解释

timestamp

System Variable timestamp
Scope Session
Dynamic Yes
Type Numeric
Default Value UNIX_TIMESTAMP()
Minimum Value 1
Maximum Value 2147483647

Set the time for this client. This is used to get the original
timestamp if you use the binary log to restore rows.
timestamp_value should be a Unix
epoch timestamp (a value like that returned by
UNIX_TIMESTAMP(), not a value
in 'YYYY-MM-DD
hh:mm:ss
'
format) or
DEFAULT.

Setting timestamp to a
constant value causes it to retain that value until it is
changed again. Setting
timestamp to
DEFAULT causes its value to be the current
date and time as of the time it is accessed. The maximum value
corresponds to '2038-01-19 03:14:07' UTC,
the same as for the TIMESTAMP
data type.

timestamp is a
DOUBLE rather than
BIGINT because its value includes a
microseconds part.

SET timestamp affects the value returned by
NOW() but not by
SYSDATE(). This means that
timestamp settings in the binary log have no effect on
invocations of SYSDATE(). The
server can be started with the
--sysdate-is-now option to
cause SYSDATE() to be a synonym
for NOW(), in which case
SET timestamp affects both functions.


数据运维技术 » MySQL Variables timestamp 数据库 参数变量解释及正确配置使用