(1)在源库中建目标库(fantastic)的dblink,使可以在源库中查看目标库的表
drop database link link_fantastic; --删除link
create database link link_fantastic connect to fantastic identified by "fantastic"
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST =60.30.69.73)(PORT = 31521))
)
(CONNECT_DATA =
(SERVICE_NAME =orcl)
)
)'; --新建link
select * from dba_db_links; --查看所有link
select * from users@link_fantastic; --通过link查看远程库表
merge into users@link_fantastic b using users c on (b.username=c.username)
when matched then update set b.password=c.password
when not matched then
insert values (c.username, c.password, null); --把源库中users表的数据并到fantastic中,users表
commit; --记得merge后必须commit,否则更改未能提交
注: 都是在源库中操作,操作后源库中表数据不变。