[Err] 1293 - there can be only one TIMESTAMP column with CURRENT_TIME in DEFAULT or ON UPDATE clause
2017-08-03 09:50
531 查看
[Err] 1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
一个表中出现多个时间戳字段的定义,并设置了其中一个默认为Current_timestamp会报此类错误。
原因是当你给一个timestamp设置为on update current_timestamp的时候,其他的timestamp字段需要显式设定default值。
但是如果你有两个timestamp字段,但是只把第一个设定为current_timestamp而第二个没有设定默认值,MySQL也能成功建表,但是反过来就不行;
所以,有两种解决办法:
方法一:给所有的时间戳TIMESTAMP设置默认值DEFAULT值;
方法二:升级Mysql,将Mysql升级到5.7版本以上就不会出现类似的问题了。
方法三:将设定为CURRENT_TIMESTAMP的时间戳字段放在所有没有设定默认值的时间戳字段前面,则可以建表成功(实际上CURRENT_TIMESTAMP时间戳默认值只能设置一个或者不设置,不能有两个以上)。
如下表所示:将设置了CURRENT_TIMESTAMP的时间戳create_Time字段设置在其他时间戳(start_time和end_time)前面,则创建成功。
一个表中出现多个时间戳字段的定义,并设置了其中一个默认为Current_timestamp会报此类错误。
原因是当你给一个timestamp设置为on update current_timestamp的时候,其他的timestamp字段需要显式设定default值。
但是如果你有两个timestamp字段,但是只把第一个设定为current_timestamp而第二个没有设定默认值,MySQL也能成功建表,但是反过来就不行;
所以,有两种解决办法:
方法一:给所有的时间戳TIMESTAMP设置默认值DEFAULT值;
方法二:升级Mysql,将Mysql升级到5.7版本以上就不会出现类似的问题了。
方法三:将设定为CURRENT_TIMESTAMP的时间戳字段放在所有没有设定默认值的时间戳字段前面,则可以建表成功(实际上CURRENT_TIMESTAMP时间戳默认值只能设置一个或者不设置,不能有两个以上)。
如下表所示:将设置了CURRENT_TIMESTAMP的时间戳create_Time字段设置在其他时间戳(start_time和end_time)前面,则创建成功。
相关文章推荐
- msyql同步的时候报错 : 错误代码: 1293 Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- 数据库建表 there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT
- 1293 - Incorrect table definition; there can be only oneTIMESTAMP column with CURRENT_TIMESTAMP
- Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAUL
- Mysql 1293 - Incorrect table definition; there can be only one TIMESTAMP column with C
- error : Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in
- Mysql [Err] 1293 there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- mysql单表多timestamp报错#1293 - Incorrect table definition; there can be only one TIMESTAMP column with C
- [Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as
- MySql创建表时插入自动更新时间戳报错:SQL执行错误#1293:Incorrect table definition;there can be only one TIMESTAMP ...
- [Err] 1075 - Incorrect table definition; there can be only one auto column and it must be defined as
- iOS使用XIB文件报错:reason: 'A view can only be associated with at most one view controller at a time!
- Only one expression can be specified in the select list when the subquery is not introduced with EXI
- 1075-Incorrect table definition;there can be only one auto column and it must be defined as a key
- Only one expression can be specified in the select list when the subquery is not introduced with EXI