今天上午准备利用databaselink(TO_ORATEST.US.ORACLE.COM)从远程数据库向本地数据库 INSERT数据时,因远程表中含有BLOB字段,在SELECT 和 INSERT INTO操作时,报"ORA-22992: 无法使用从远程表选择的 LOB 定位器"错误,通过创建临时表并从临时成功把数据插入到目的表中。具体解决办法如下(以下操作都是在PL/SQL Developer中进行):
1.在本地数据库创建临时表:
create global temporary tablegtemp as select * from ys_bcxy where 1=2 ;
2.利用databaselink把远程数据先插入到临时表中(注意:INSERT后先不要commit,否则commit后临时表中数据就会丢失)
insert into gtemp select *from ys_bcxy@TO_ORATEST.US.ORACLE.COM;
3.在上一操作所在PL/SQL Developer的SQL窗口里输入以下命令:
insert into ys_bcxy select *from gtemp;
commit;
4.查询本地表,数据已经成功插入。
select * from ys_bcxy;
自己测试通过:
在uatb上通过dblink查询uatc上表中数据:
create global temporary table zljtmp asselect * from afs_drp_ws_receive_log where 1=2 ;
insert into zljtmp select * fromafs_drp_ws_receive_log@uatc.regress.rdbms.dev.us.oracle.com where id in('20160810000055176708','20160810000055176709','20160810000055176710');
insert into afs_drp_ws_receive_log select *from zljtmp;
commit;