• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

各位大侠们好,小弟的触发器总是报错,帮忙看看吧,多谢啦

mysql 搞代码 7年前 (2018-06-02) 147次浏览 已收录 0个评论

各位大侠们好,小弟的触发器总是报错,帮忙看看吧,谢谢啦
各位大侠们好,小弟第一次用mysql,写了个触发器,但总是报错,查了半天的官网帮助文档也没找到原因。代码如下:
CREATE TRIGGER article_channel_trigger before delete ON xlChannel
  for each row
  begin
  delete from xlArticle where channelId=OLD.id;
  end;

创建表的sql语句:
create table xlArticle(
  id bigint primary key auto_increment,
  groupId int comment ‘允许浏览会员组’,
  channelId int not null comment ‘栏目ID’,
。。。。。

create table xlChannel(
  id int primary key auto_increment,
  parentId int comment ‘父栏目’,
  name varchar(100) comment ‘栏目名称’,
  content longtext comment ‘栏目内容’,
  priority int not null default 100 comment ‘
。。。。

alter table xlarticle add constraint FK_VITEM_TOPIC foreign key (channelId)
  references xlChannel (id) on delete restrict on update restrict;
创建表和外键约束的语句没有问题的。

——解决方案——————–
错误提示是什么?

——解决方案——————–
改成如下

SQL code

 CREATE TRIGGER article_channel_trigger before delete ON xlChannel for each row delete from xlArticle where channelId=OLD.id;

欢迎大家阅读《各位大侠们好,小弟的触发器总是报错,帮忙看看吧,多谢啦》,跪求各位点评,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:各位大侠们好,小弟的触发器总是报错,帮忙看看吧,多谢啦
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址