问题描述
我在database1的表中有一个记录超过一百万的表。我需要用一些过滤器填充database2中的另一个表。
不允许批量插入,因为这些是远程数据库。
我需要建议来填充远程数据库表,成功的记录在database2中,而erros被捕获在另一个表或文件中。
性能是一个主要限制,因为forall不能使用,因为它们是远程数据库填充。请建议有价值的知识
不允许批量插入,因为这些是远程数据库。
我需要建议来填充远程数据库表,成功的记录在database2中,而erros被捕获在另一个表或文件中。
性能是一个主要限制,因为forall不能使用,因为它们是远程数据库填充。请建议有价值的知识
专家解答
最简单的方法是只插入:
如果源数据处于PLSQL结构中,则将其插入到全局临时表中,然后将其用作要插入的源。
-- -- db1 -- SQL> create table t 2 as 3 select owner, object_name, object_type 4 from dba_Objects 5 where 1=0; Table created. -- -- db2 -- SQL> create table t 2 as 3 select owner, object_name, object_type 4 from dba_Objects; Table created. SQL> SQL> SQL> insert into t@np12 2 select * from t; 79078 rows created. SQL> commit; Commit complete.复制
如果源数据处于PLSQL结构中,则将其插入到全局临时表中,然后将其用作要插入的源。
SQL> create or replace 2 type the_row as object ( 3 owner varchar2(128), 4 object_name varchar2(128), 5 object_type varchar2(128) 6 ); 7 / Type created. SQL> SQL> create or replace 2 type the_list as table of the_row; 3 / Type created. SQL> SQL> create global temporary table tmp ( 2 owner varchar2(128), 3 object_name varchar2(128), 4 object_type varchar2(128) 5 ); Table created. SQL> SQL> declare 2 t the_list := the_list(); 3 begin 4 -- 5 -- load up my source 6 -- 7 select the_row(owner, object_name, object_type) 8 bulk collect into t 9 from dba_objects; 10 11 -- copy to GTT 12 insert into tmp 13 select * from table(t); 14 15 -- use GTT 16 insert into t@np12 17 select * from tmp; 18 end; 19 / PL/SQL procedure successfully completed.复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。