mysql 缺省日期列

来源:互联网 发布:x64dll编程 编辑:程序博客网 时间:2024/05/16 23:57

经常有这种需求

某日期列要缺省保持最新时间:

create table testtimestamp1(u varchar(100),updatetime timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);


mysql> insert into testtimestamp1 (u) values ('uiui');
Query OK, 1 row affected (0.09 sec)


mysql> select * from  testtimestamp1;
+-------+---------------------+
| u| updatetime          |
+-------+---------------------+
| uiui  | 2016-12-15 16:53:31 |
+-------+---------------------+
1 row in set (0.00 sec)


修改也一样可行。



此建表语句在mac 的navicat 上总是失败。

如果你是 DBA ,仍然建议你用命令行来写语句。

0 0
原创粉丝点击