时间:2021-07-01 10:21:17 帮助过:5人阅读
dblink情况下,新增本地表,同步远程服务器另一张表
参考自:http://www.blogjava.net/hhhaaawwwkkk/archive/2009/05/06/269251.html
参考内容:
---创建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;
oracle触发器加条件判断、dblink
标签: