mysql觸發器是非常重要的概念,下面為您介紹的是mysql觸發器的三個狀態,供您參考,希望讓您對mysql觸發器能夠有更深的認識。
- CREATE
- TRIGGER `user1_user2` AFTER INSERT ON `user1`
- FOR EACH ROW insert into user2 SELECT * from user1 order by id desc limit 1
- WHERE id>=LAST_INSERT_ID()
- AND id <=LAST_INSERT_ID()+ROW_COUNT()
- CREATE
- TRIGGER `update_user` AFTER UPDATE ON `user1`
- FOR EACH ROW update user2 set name=new.user,info=new.pwd where id=old.id;
- CREATE
- TRIGGER `del_user` AFTER DELETE ON `user1`
- FOR EACH ROW delete from user2 where id=old.id
- =================復雜的insert
- CREATE TRIGGER `test`.`insert_user2` AFTER INSERT ON `test`.`user1`
- FOR EACH ROW INSERT INTO user2
- SET `id` = NEW.id,
- `name` = NEW.user,
- `info` = NEW.pwd,
- `date2` = UNIX_TIMESTAMP( NEW.date1 ) ,
- `enum2` = NEW.enum1 -1,
- `aid`=(select aid from protype where id=NEW.type_id)
以上mysql觸發器的三個狀態介紹。
mysql觸發器的三個示例
mysql建主從服務器的實現方法
Mysql聚合函數簡介
MySQL字符串大小寫轉換函數
MySQL concat函數的使用