oracle通过DBLink访问远程数据库的LOB字段报ORA-22992的解决方法

来源:互联网 发布:php 异步请求类 编辑:程序博客网 时间:2024/05/19 23:27

 

oracle通过DBLink访问远程数据库的LOB字段报ORA-22992的解决方法

 
最近在做数据库迁移,从一个数据库导入表到另外一个数据库,同时为了更换表空间,在导入的过程中出现包含BLOB类型的表不能导入,(字段是BLOB类型),如果本地数据库直接通过select语句查询远程数据库的表数据,则会报ORA-22992: cannot use LOB locators selected from remote tables的错误,网上查了一下解决方法,记录下来以便以后查看。
方法一:   
本地建一个包含大字段(BLOB)的表,然后通过inser into … select … from …@dblink把数据插入到本地的库表中,直接操作本地库表即可。如:
 
创建表:
[sql] 
SQL>create table inner_table select *from outer_table@dblink  
插入数据:
 
[sql] 
SQL>insert into inner_table select *from outer_table@dblink  
这样就把远程表outer_table中的数据写到本地表inner_table中了。
 
 
方法二:
 
在本地创建一张和dblink远程端相同的全局临时表,然后在查询临时表:
 
--创建临时表:
 
[sql] 
SQL>create global temporary table tem_table( … ) on commit delete rows;  
插入数据:
 
[sql] 
SQL> insert into tem_table select * fromouter_table@dblink;   
xxx rows created.  
 
这样就把数据写到临时表了,不过提交之后数据就被删除了(临时表的特性)。 
其实这两种方法都差不多,只不过一个是用的临时表,一个是用的是永久性的表。

 

0 0
原创粉丝点击