In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Distribute synchronization data through triggers
Create table tab (id int not null primary key,name varchar 20, age int,address varchar 200)
Create table tab0 (id int not null primary key,name varchar 20, age int,address varchar 200)
Create table tab1 (id int not null primary key,name varchar 20, age int,address varchar 200)
Create table tab2 (id int not null primary key,name varchar 20, age int,address varchar 200)
Insert into tab values (1, recorder, recorder,)
Insert into tab values (2 recordings jiangzhongjia 40 phianghai`)
Insert into tab values (3 recordings wangzhongpai 31 phianghai`)
Delimiter / /
Create trigger tri_sync_insert
After insert on tab
For each row
Begin
Declare
V_result int
Set v_result=mod (new.id,3)
If v_result = 0 then
Insert into tab0 (id,name,age,address) values (new.id,new.name,new.age,new.address)
Elseif v_result = 1 then
Insert into tab1 (id,name,age,address) values (new.id,new.name,new.age,new.address)
Else
Insert into tab2 (id,name,age,address) values (new.id,new.name,new.age,new.address)
End if
End
/ /
Delimiter
Delimiter / /
Create trigger tri_sync_update
After update on tab
For each row
Begin
Declare
V_result int
Set v_result=mod (new.id,3)
If v_result = 0 then
Replace into tab0 (id,name,age,address) values (new.id,new.name,new.age,new.address)
Elseif v_result = 1 then
Replace into tab1 (id,name,age,address) values (new.id,new.name,new.age,new.address)
Else
Replace into tab2 (id,name,age,address) values (new.id,new.name,new.age,new.address)
End if
End
/ /
Delimiter
Delimiter / /
Create trigger tri_sync_delete
After delete on tab
For each row
Begin
Declare
V_result int
Set v_result=mod (old.id,3)
If v_result = 0 then
Delete from tab0 where id=old.id
Elseif v_result = 1 then
Delete from tab1 where id=old.id
Else
Delete from tab2 where id=old.id
End if
End
/ /
Delimiter
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.