mysql> create table goods(gid char(8) primary key, name varchar(10),price decimal(8,2),num int);
2.mysql> create table orders(oid int primary key auto_increment,gid char(10) not null,name varchar(10),price decimal(8,2),onum int, otime date);
建立触发器,客户取消订单,恢复商品表对应商品数量
mysql> create trigger orders_after_delete_trigger after delete on orders for each row update goods set num=num+old.onum where gid=old.gid;
测试:delete from orders where oid=2;
建立存储器:
1.创建提取emp_new表所有员工姓名和工资的存储过程S1
mysql> delimiter //
mysql> create procedure s1()
-> begin
-> select name,incoming from emp_new;
-> end //
mysql> delimiter ;
mysql> call s1();