MySQL trigger for data synchronization learning

Source: Internet
Author: User

Tag: where AC TPS varchar implements new logs event trigger log

Trigger implementation: (Increment, delete, change operation Event trigger data one-way synchronization)
Database triggers tutorial: https://www.cnblogs.com/phpper/p/7587031.html
Sync Code:

DELIMITER $DROP TRIGGER IF EXISTS insertdata; CREATE TRIGGER InsertData after INSERT on Repair.user for each rowbegindeclare S1 INT ( One);D eclare S2 VARCHAR ( -); SET S1=new.id; SET S2=New.name;insert into Sale.user (id,name) VALUES (S1,S2); END $DELIMITER $DROP TRIGGER IF EXISTS updatedata; CREATE TRIGGER UpdateData after UPDATE on Repair.user for each rowbegindeclare S1 INT ( One);D eclare S2 VARCHAR ( -); SET S1=old.id; SET S2=New.name; UPDATE Sale.user a SET a.name=s2 WHERE a.id=S1; END $DELIMITER $DROP TRIGGER IF EXISTS deletedata; CREATE TRIGGER DeleteData after DELETE on Repair.user for each rowbegindeclare S1 INT ( One);D eclare S2 VARCHAR ( -); SET S1=old.id; SET S2=Old.name;delete from Sale.user WHERE ID=S1; END $

MySQL trigger for data synchronization learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.