---创建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;