1、在远程库中建表:
create table T_LILO as select * from dba_objects;
insert into T_LILO select * from T_LILO;
commit;
2、在本地库上建DBLink:
create public database link dblilo connect to lilo identified by lilo using 'dblink';
3、在本地建临时表:
create global temporary table GT_LILO_TEMP (owner varchar2(200), name varchar2(200));
4、准备本地环境:
LILO@orcl>set timing on
LILO@orcl>set time on
15:39:09 LILO@orcl>show user
USER is "LILO"
15:39:15 LILO@orcl>
5、插入远程库上的表:
15:39:49 LILO@orcl>insert into GT_LILO_TEMP (owner, name) select a.owner,a.object_name from T_LILO@DBLILO a;
205608 rows created.
Elapsed: 00:00:05.96
15:39:56 LILO@orcl>
可以看到这里如果远程表中不含有CLOB类型列的话,只用了6s。
6、回滚刚刚的插入:
15:40:12 LILO@orcl>rollback;
Rollback complete.
7、分别在本地和远程增加CLOB类型列:
本地临时表:
alter table GT_LILO_TEMP add (C_LOB CLOB);
远端表:
alter table T_LILO add (C_LOB CLOB);
8、在远程表中插入CLOB类型列:
SQL> insert into T_LILO(C_LOB) select object_name from T_LILO;
102804 rows created.
SQL> commit;
9、在本地临时表中插入含有CLOB类型的列:
15:41:06 LILO@orcl>insert into GT_LILO_TEMP (owner, name,C_LOB) select a.owner,a.object_name,a.c_lob from T_LILO@DBLILO a;