开发者

how not to update timestamp field

project is written on php.

There is timestamp field in mysql it updates automatically. In one case I don`t need update thi开发者_Go百科s field. Can I gibe instruction not to update this field in this queries without getting timestamp value.


You should change it to DEFAULT CURRENT_TIMESTAMP otherwise it will auto-update. From the manual:

In a CREATE TABLE statement, the first TIMESTAMP column can be declared in any of the following ways:

With both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP clauses, the column has the current timestamp for its default value, and is automatically updated.

With neither DEFAULT nor ON UPDATE clauses, it is the same as DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP.

With a DEFAULT CURRENT_TIMESTAMP clause and no ON UPDATE clause, the column has the current timestamp for its default value but is not automatically updated.


Edit the column in phpMyAdmin and unselect the option for "on update current timestamp."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜