错误消息显示“字段'product_id'没有默认值”

时间:2019-09-30 04:51:19

标签: mysql

我想为quantity_order列插入100到3行的值,但是错误消息不断弹出。

create table product_table(
product_id varchar(10) not null,
product_desc varchar(50) not null,
quantity int(11) not null,
timing timestamp not null,
primary key (product_id, product_desc));

insert into product_table(
product_id, product_desc, quantity, timing)
values ('00001', 'Chill Methol Cigarettes', '100', current_timestamp),
('00002', 'Pocky - Chocolate', '100', current_timestamp),
('00003', 'Pocky - Strawberry', '100', current_timestamp);
alter table product_table
add (quantity_order int(11) not null, quantity_sold int(11) null, quantity_new int(11) null);
alter table product_table
drop quantity;

create trigger `calc_newquantity`
before insert
on `product_table`
for each row
set new.quantity_new = new.quantity_order - new.quantity_sold;

insert into product_table (quantity_order)
values (100, 100, 100);

0 个答案:

没有答案