mysql 报错 Incorrect table definit

2019-08-17  本文已影响0人  醉于麦田

执行sql报错:Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

 执行如下sql:报错

表中出现多个timestamp并设置为current_timestamp的时候报错

 Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATEclause

原因是当你给一个timestamp设置为on updatecurrent_timestamp的时候,其他的timestamp字段需要显式设定default值

但是如果你有两个timestamp字段,但是只把第一个设定为current_timestamp而第二个没有设定默认值,MySQL能成功建表,但是反过来就不行...

上一篇 下一篇

猜你喜欢

热点阅读