drop trigger if exists testtTrigger;
CREATE TRIGGER testtTrigger after INSERT ON temp
FOR EACH ROW
INSERT INTO author
(AuthorID, AuthorFname, AuthorLname) values (new.aID, new.afname, new.alname)
INSERT INTO book
(`Book ID`, book_Title) values (new.bID, new.btitle);
//我也被告知要在存储过程中运行此代码,但是当我在存储过程中运行它时,它运行没有任何问题,但它不能为我做这个triger,只是我没有为我完成存储过程代码的工作
DELIMITER $$
CREATE TRIGGER testtTrigger BEFORE INSERT ON temp
FOR EACH ROW BEGIN
INSERT INTO author (AuthorID, AuthorFname, AuthorLname) values (new.aID, new.afname, new.alname);
INSERT INTO book (`Book ID`, book_Title) values (new.bID, new.btitle);
END;
答案 0 :(得分:0)
drop trigger if exists testtTrigger;
DELIMITER //
CREATE TRIGGER testtTrigger after INSERT ON temp
FOR EACH ROW
BEGIN
INSERT INTO author(AuthorID, AuthorFname, AuthorLname) values (new.aID, new.afname, new.alname);
INSERT INTO book
(`Book ID`, book_Title) values (new.bID, new.btitle);
END; //
DELIMITER;
除此之外,应该使用外键和CASCADE
选项。