mysql,要在我建立的表中建立一个触发器,但是触发器建立后无法插入数据,一插入就是错误
代码如下createtableproduct(idint(10)notnulluniqueprimarykey,namevarchar(20)notnull,functi...
代码如下
create table product (
id int(10) not null unique primary key,
name varchar(20) not null,
function varchar(50),
company varchar(20) not null,
address varchar(50)
);
create table operate(
op_id int(10) not null unique primary key auto_increment,
op_name varchar(20) not null,
op_time time not null
);
create trigger tproduct_bf_insert before insert on product for each row
insert into operate values('null','insert product','now()');
create trigger tproduct_af_update after update on product for each row
insert into operate values('null','update product','now()');
create trigger tproduct_af_del after delete on product for each row
insert into operate values('null','delete product','now()');
insert into product
values ('1','abc','专治感冒','上海abc制药','上海市分厂');
然后就错误,显示错误
incorrect integer value null for column op_id at row 1 展开
create table product (
id int(10) not null unique primary key,
name varchar(20) not null,
function varchar(50),
company varchar(20) not null,
address varchar(50)
);
create table operate(
op_id int(10) not null unique primary key auto_increment,
op_name varchar(20) not null,
op_time time not null
);
create trigger tproduct_bf_insert before insert on product for each row
insert into operate values('null','insert product','now()');
create trigger tproduct_af_update after update on product for each row
insert into operate values('null','update product','now()');
create trigger tproduct_af_del after delete on product for each row
insert into operate values('null','delete product','now()');
insert into product
values ('1','abc','专治感冒','上海abc制药','上海市分厂');
然后就错误,显示错误
incorrect integer value null for column op_id at row 1 展开
2个回答
展开全部
单引号加多了,整型和函数都成了字符串,有意义的数还好,null就自动转型失败了。
更多追问追答
追问
你好,能不能告诉一下该如何改动呢,举个代码实例
追答
values(null,'insert',now())
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
数据裤
追问
数据库已经建立了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询