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