2

我想节省用户注册的时间。这是我的表格数据

nic    name    age   time
190    ali      27   2012-04-13 17:31:19
217    bilal    32   2012-04-15 02:00:40
382    hamza    21   2012-04-17 20:59:29

我在 MYSQL 中手动创建了时间属性

Column : time
Type TIMESTAMP
Default : CURRENT_TIMESTAMP
attributes: on update CURRENT_TIME

现在我想永久保存这个时间。。当注册用户更新他的个人资料时,时间会自动更新。

有什么方法可以不更改更新时间,我只想在用户注册时永久保存时间,而不是在任何更新时更改它

4

1 回答 1

3

不要指定ON UPDATE CURRENT_TIMESTAMP. 相反,仅依赖于并从您的语句中DEFAULT CURRENT_TIMESTAMP省略该列。INSERT

通过包含ON UPDATE规范,您将强制时间戳列在行更改时更改。你不需要那个。

/* Omit the time column on insert: time will get the default value. */ 
INSERT INTO user (nic, name, age) VALUES ('newuser', 'New user Name', 33);
于 2012-04-17T16:18:25.253 回答