Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAUL

mysql数据库创建表时,对时间字段的定义,

DROP TABLE IF EXISTS `pro_favorite`;
CREATE TABLE `pro_favorite` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `user_id` int(11) unsigned NOT NULL COMMENT '用户ID',
  `pro_id` int(11) unsigned NOT NULL COMMENT '商品ID',
  `status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '0:取消  1:确认',
  `favoritetype` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '收藏类型(预留)',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `fav_userIdx_idx` (`user_id`),
  CONSTRAINT `fav_userIdx` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='产品收藏';

 

其中把两个timestamp设置为当前时间,不支持,只能设置一个为当前时间,删除其中的一个默认值即可

posted on 2018-06-14 09:39  让代码飞  阅读(243)  评论(0)    收藏  举报

导航

一款免费在线思维导图工具推荐:https://www.processon.com/i/593e9a29e4b0898669edaf7f?full_name=python