[Err] 1294 - Invalid ON UPDATE clause for ‘comment

[Err] 1294 - Invalid ON UPDATE clause for ‘comment,第1张

mysql版本低原因导致。


不想卸载重装的方法:创建游标

改前:
CREATE TABLE `user`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户登录表',
  `account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户账户',
  `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户密码',
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '邮箱',
  `phone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户电话',
  `user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户昵称',
  `sex` int(2) NULL DEFAULT 1 COMMENT '用户性别(0女,1男)',
  `birthday` datetime NULL DEFAULT NULL COMMENT '出生日期',
  `record_date` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '注册日期',
  `is_vip` int(2) NULL DEFAULT 0 COMMENT '是否VIP用户',
  `role_id` int(11) NULL DEFAULT 0 COMMENT '权限ID(0普通用户,1管理员)',
  PRIMARY KEY  USING BTREE (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
改后:
CREATE TABLE `user`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户登录表',
  `account` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户账户',
  `password` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户密码',
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '邮箱',
  `phone` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户电话',
  `user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '用户昵称',
  `sex` int(2) NULL DEFAULT 1 COMMENT '用户性别(0女,1男)',
  `birthday` datetime NULL DEFAULT NULL COMMENT '出生日期',
  `record_date` datetime NULL DEFAULT NULL    COMMENT '注册日期',
  `is_vip` int(2) NULL DEFAULT 0 COMMENT '是否VIP用户',
  `role_id` int(11) NULL DEFAULT 0 COMMENT '权限ID(0普通用户,1管理员)',
  PRIMARY KEY  USING BTREE (`id`)
) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
DELIMITER //
CREATE TRIGGER `user` BEFORE UPDATE ON `user` 
 FOR EACH ROW SET NEW.`record_date` = NOW()
//
DELIMITER ;
总结:

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/567764.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-09
下一篇 2022-04-09

发表评论

登录后才能评论

评论列表(0条)

保存