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

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

各位大侠们好,小弟第一次用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;


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

相关文章:

你感兴趣的文章:

标签云: