oracle使用bulk collect insert实现大数据快速迁移
来源:互联网 发布:淘宝口红哪家是正品 编辑:程序博客网 时间:2024/06/06 19:31
在Oracle 数据库中,将一张表的部分字段转换导入到另外一张表的部分字段中,如"insert into t_target(owner,object_name) from t_source;" 。
这也是解决此类数据迁移的的常规操作方法。
如果源表记录数不是很多,操作操作也无妨。但是若源表记录数一旦超过百万千万,执行时间就长了,占用的回滚段也大。不小心执行失败,又要全部回滚。有没有更好的方法,加hint 如nologging append, 甚至parallel。这些我认为都不是很好的方法,有有一种方法,称之为bulk collect into 。使用它可以减少操作时间。这是基于数据块的插入方式。
目标表的结构如下:
源表为dba_objects ,表结构在数据库中可以查到。
需要将源表dba_objects 中两个字段object_name,owner 两个字段的值复制到t_target 表中。
1.Explicit cursors doing a BULK COLLECT into a local collection (with an appropriate LIMIT) and using FORALL to write back to the database.
2.Implicit cursors doing a BULK COLLECT for you behind the scenes along with single-row writes back to the datbase.
3.Explicit cursors that are not doing a BULK COLLECT and not taking advantage of PL/SQL collections.
这也是解决此类数据迁移的的常规操作方法。
如果源表记录数不是很多,操作操作也无妨。但是若源表记录数一旦超过百万千万,执行时间就长了,占用的回滚段也大。不小心执行失败,又要全部回滚。有没有更好的方法,加hint 如nologging append, 甚至parallel。这些我认为都不是很好的方法,有有一种方法,称之为bulk collect into 。使用它可以减少操作时间。这是基于数据块的插入方式。
目标表的结构如下:
create table t_target (id number, owner varchar2(30), object_name varchar2(128), object_id number, xx date, yy varchar2(10))
源表为dba_objects ,表结构在数据库中可以查到。
需要将源表dba_objects 中两个字段object_name,owner 两个字段的值复制到t_target 表中。
declare type t_array is table of t_target%rowtype; t_data t_array; cursor c is select null id, owner, object_name, null object_id, null xx, null yy from dba_objects; begin open c; loop fetch c bulk collect into t_data limit 100; forall i in 1 .. t_data.count insert into t_target values t_data (i); exit when c%notfound; end loop; close c; commit; end;Fastest
1.Explicit cursors doing a BULK COLLECT into a local collection (with an appropriate LIMIT) and using FORALL to write back to the database.
2.Implicit cursors doing a BULK COLLECT for you behind the scenes along with single-row writes back to the datbase.
3.Explicit cursors that are not doing a BULK COLLECT and not taking advantage of PL/SQL collections.
转载于http://mikixiyou.iteye.com/blog/1626906
0 0
- oracle使用bulk collect insert实现大数据快速迁移
- 使用bulk collect insert实现大数据快速迁移
- oracle 利用bulk collect into 批量insert
- Oracle的bulk collect使用
- 使用 BULK INSERT 或 OPENROWSET(BULK...) 导入大容量数据
- oracle forall,bulk collect的使用
- 使用Bulk Collect提高Oracle查询效率
- Oracle 游标处理II - 使用BULK COLLECT
- 使用bulk collect实现cursor 批量fetch
- 使用bulk collect实现cursor 批量fetch
- Oracle数据库BULK COLLECT
- oracle bulk collect用法
- Oracle Bulk Collect 学习
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据【转】
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据(转载)
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据
- 局域网内服务器入侵的防范措施
- 圣行故事-----奔公甲格西
- 基础加强-java反射
- 第五周项目1.3
- 表单元素详解
- oracle使用bulk collect insert实现大数据快速迁移
- Image Matting(抠图)技术介绍:序言
- 颜色名称及色样表(HTML版)
- 【数据库优化】面向程序员的数据库访问性能优化法则
- 基础加强-泛型
- android 上下左右手势判断
- linux上安装jdk
- Qt图形视图框架(一)
- CentOS 6.4 安装mysql 5.5 rpm 的libaio问题的解决