标签:
CREATE TABLE time1 (
id SMALLINT,
time1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
time2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ;
INSERT INTO time1 VALUES(100,‘‘,‘‘),(101,NOW(),NOW());
SELECT * FROM time1;
id time1 time2
------ ------------------- ---------------------
100 0000-00-00 00:00:00 0000-00-00 00:00:00
101 2015-03-30 10:02:18 2015-03-30 10:02:18
UPDATE time1 SET id=102;
SELECT * FROM time1;
id time1 time2
------ ------------------- ---------------------
102 2015-03-30 10:03:10 0000-00-00 00:00:00
102 2015-03-30 10:03:10 2015-03-30 10:02:18
总结:
DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ---可以用于记录最后更新时间。
标签:
原文地址:http://www.cnblogs.com/afx1007/p/4377264.html