a guest Oct 19th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create database trigger_tester;
  2. use trigger_tester;
  3. create table test1(id int not null AUTO_INCREMENT, name varchar(20), primary key(id));
  4. create table test2(id int not null, name varchar(20), primary key(id));
  5. create trigger after_insert after insert on test1 for each row insert into test2 (id, name) values(, concat(,' trigger'));
  6. create trigger after_delete after delete on test1 for each row delete from test2 where id =;
  7. create trigger after_update after update on test1 for each row update test2 set name = CONCAT(, ' updated') where id =;
  8. insert into test1 (name) values('new test');
  9. insert into test1 (name) values('new test2');
  10. insert into test1 (name) values('new test3');
  11. select * from test1;
  12. select * from test2;
  13. delete from test1 where id =2;
  14. select * from test1;
  15. select * from test2;
  16. update test1 set name="new test2" where id =3;
  17. select * from test1;
  18. select * from test2;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand