日期:2014-05-16  浏览次数:20383 次

DBLINK访问LOB问题
DBLINK访问LOB问题(2008-02-15 15:19:28)转载
http://blog.csdn.net/hailang99/archive/2007/09/20/1793405.aspx


在本地用select语句访问远程,如果远程表有CLOB字段的话则会有错:ora-22992;
如果真的想看到clob字段的内容的话就得在本地建立一个表,用下面两条语句:
我刚才试验insert into table select * from remote table成功
remote table含有CLOB
总结:在我的环境中成功
(1)create table aaa select * from remote table
(2)insert into table select * from remote table


不过网上也有以下说法,虽然有错,不过也是一种方法,

通过临时表从DBLink中获取Blob对象2006-12-05 20:37做系统集成时,通过Database Link共享数据是不错的选择。不过真正使用DBLink时却碰到一个不小的问题:从远程数据库上查询Blob字段时总返回ORA-22992错误,如下:

select blobcolumn from remoteTable@dl_remote;

ORA-22992: 无法使用从远程表选择的 LOB 定位器

查找了一下解决方法,有人提出了采用物化视图可以解决这个问题。物化视图唯一的缺陷在于同步机制的问题,如果同步时间设置过短,则占用大量的系统资源,给服务器带来极大的压力;如果设置时间过长,前台用户不可接受。

后来还是AskTom给出了极好的解决方案:使用全局临时表。

SQL> create global temporary table foo

  2  (

  3    X BLOB

  4  )

  5  on commit delete rows;

Table created

SQL> insert into foo select blobcolumn from remoteTable@dl_remote where rownum = 1;

1 row inserted

SQL>

插入本地临时表之后,在本地的操作就没有任何问题了。

至于为什么临时表可以直接插入,而永久表为什么不能插入,本人未做具体研究?/