读书人

各位大侠们好,小弟的触发器总是报错

发布时间: 2012-05-09 12:13:59 作者: rapoo

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

读书人网 >Mysql

热点推荐