-- added create trigger yqhl_htjs_b_htjbxx_insert before insert on table name for each row begin if (NEW. F_sync_update is null) or (NEW. f_sync_update = 0) then set new. f_sync_update=null; -- inserting newly added records into the Operation log table insert into data_sync_b_operator (t_name, o_type, o_date, Vkeys) values (' Table name ', 1, current_timestamp,new. HTDQBH); end if;end;-- Modify Create trigger yqhl_htjs _b_htjbxx_update before update on table name for each rowbeginif (NEW. F_sync_update is null) or (NEW. f_sync_update = 0) then -- Insert and update operations, update timestamp f_sync_date=systimestamp and f_ Sync_update=nullset&nBsp NEW. f_sync_update=null; end if;end;-- Delete Create trigger yqhl_htjs_b_htjbxx_ delete before delete on Table name for each row begin if (old. F_sync_update is null) or (old. f_sync_update = 0) then -- Insert and update operations, update timestamp f_ Sync_date=systimestamp and f_sync_update=null -- Add the primary key of the delete record to the Operation record table insert into data_sync_b_operator (T_name, o_type, o_date, vkeys) values (' Table name ', 3, current_timestamp,old. HTDQBH); end if;end;
This article is from the "write-free" blog, please be sure to keep this source http://7156680.blog.51cto.com/7146680/1790835
MySQL CREATE trigger