开发者

MySQL Default DATETIME value

开发者 https://www.devze.com 2022-12-13 18:48 出处:网络
I\'d like to accomplish something like the following in a MySQL Create table action 开发者_高级运维date_created datetime NOT NULL DEFAULT CURRENT_DATETIME,

I'd like to accomplish something like the following in a MySQL Create table action

开发者_高级运维date_created datetime NOT NULL DEFAULT CURRENT_DATETIME,  
date_updated datetime NOT NULL ON UPDATE CURRENT_DATETIME,

Once again, this is a MySQL create table action and these are two of the fields in my table.


Have a look at this

TIMESTAMP Properties

From the link you can use

CREATE TABLE t (ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
                             ON UPDATE CURRENT_TIMESTAMP);
CREATE TABLE t (ts TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
                             DEFAULT CURRENT_TIMESTAMP);
0

精彩评论

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