如果我运行以下查询:
ALTER TABLE `price_s` ADD COLUMN `ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `price_s_id` ;
新列将填充0000-00-00 00:00:00
. 在我修改该列之前,该列中的值不会更新为当前时间戳,即ON UPDATE CURRENT_TIMESTAMP
似乎工作正常。
如果我运行:
SELECT version( ) , @@time_zone , @@system_time_zone , NOW( ) , UTC_TIMESTAMP( )
我有:
'5.5.15', '+10:00', 'EST', '2012-08-23 14:56:59', '2012-08-23 04:56:59'
我想将 UTC 时间存储在列ts
中,我该怎么做?
不确定这是否相关,我试图生成mysql.time_zone*
表格:
Miranda-Macbook: ./mysql_tzinfo_to_sql /usr/share/zoneinfo | ./mysql -p -u root mysql
Enter password: Warning: Unable to load '/usr/share/zoneinfo/+VERSION' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh87' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh88' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh89' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh87' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh88' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh89' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
感谢@Sameer 和@Marc B。现在我更了解时间戳了。(在本文的帮助下)它已经存储在UTC 中,所以我实际上需要的是:
SET time_zone = 'SYSTEM';
UPDATE tablename SET ts=now()