首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

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

2012-05-09 
各位大侠们好,小弟的触发器总是报错,帮忙看看吧,谢谢啦各位大侠们好,小弟第一次用mysql,写了个触发器,但总

各位大侠们好,小弟的触发器总是报错,帮忙看看吧,谢谢啦
各位大侠们好,小弟第一次用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; 

热点排行