数据库作业d7
要求:
操作1
DELIMITER //
CREATE TRIGGER product_bf_insert
BEFORE INSERT ON product
FOR EACH ROW
BEGIN
INSERT INTO operate (Op_type, Op_time) VALUES ('INSERT', NOW());
END;
//
DELIMITER ;
DELIMITER //
CREATE TRIGGER product_af_update
AFTER UPDATE ON product
FOR EACH ROW
BEGIN
INSERT INTO operate (Op_type, Op_time) VALUES ('UPDATE', NOW());
END;
//
DELIMITER ;
DELIMITER //
CREATE TRIGGER product_af_del
AFTER DELETE ON product
FOR EACH ROW
BEGIN
INSERT INTO operate (Op_type, Op_time) VALUES ('DELETE', NOW());
END;
//
DELIMITER ;
操作2
INSERT INTO product (Id, Name, Function, Company, Address)
VALUES (1, '产品A', '主要功能A', '厂家A', '地址A');
UPDATE product SET Name = '产品A更新' WHERE Id = 1;
DELETE FROM product WHERE Id = 1;
删除
DROP TRIGGER product_bf_insert;
DROP TRIGGER product_af_update;
原文地址:https://blog.csdn.net/MapleRUA/article/details/140380782
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!