MySQL/TIMESTAMP:修订间差异
来自康健生活
| 第8行: | 第8行: | ||
time_zone SYSTEM | time_zone SYSTEM | ||
</syntaxhighlight>||mysql>}} | </syntaxhighlight>||mysql>}} | ||
设置为东八区(中国时区) | |||
{{shc|<syntaxhighlight lang="bash"> | |||
SET GLOBAL time_zone = '+8:00'; | |||
</syntaxhighlight>||mysql>}} | |||
== 自动时间管理 == | |||
<syntaxhighlight lang="mysql"> | |||
CREATE TABLE example ( | |||
id INT AUTO_INCREMENT PRIMARY KEY, | |||
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- 插入时自动填充当前时间 | |||
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP -- 插入和更新时均自动填充 | |||
);</syntaxhighlight> | |||
== 时区转换 == | == 时区转换 == | ||