oracle
触åå¨å°æ°æ®æå
¥å°å¦ä¸ä¸ªæå¡å¨çoracleæ°æ®åºä¸è¦ç¨dblinkå®ç°ä¸¤å°æå¡å¨çæ°æ®å
±äº«ã
oracle db_link å触åå¨å®ç°ä¸åæ°æ®åºè¡¨çåæ¥
---å建dblink,dblink_testå称ï¼ï¼è¢«åæ¥æ°æ®åºça_testï¼ST10766
ç¨æ·åï¼epå¯ç ï¼ass100è¿æ¥
å符串create public database link dblink_test
ãã connect to ST10766 identified by ep
ãã using 'ass100';
---å é¤dblink
----drop public database link dblink_test;
----建ç«è¡¨
create table a_test (id int,name varchar(20),pass varchar(20))
select * from a_test;
insert into a_test (id,name,pass) values (1,'zzn','shanshan')
insert into b_test (id,username,password) values('1','zxl','xiaolan')
----å¨ç®çæ°æ®åºä¸ï¼æµè¯dblinkï¼æ¥è¯¢çæ¯æºæ°æ®åºç表
select * from a_test@dblink_orc10;
select * from a_test;
----å建触åå¨
create or replace trigger a_b_test
after insert or update or delete
on a_test
for each row
begin
if deleting then
delete from b_test where id=:old.id;
end if;
if inserting then
insert into b_test(id,username,password) //b_test表çå段
values(:new.id,:new.name,:new.pass); //a_test表çå段
end if;
if updating then
update b_test set username=:new.name,password=:new.pass where id=:old.id;
end if;
end a_b_test;