首页 > Script:partition table into rowid extent chunks

Script:partition table into rowid extent chunks

以下脚本可以用于将表按照rowid范围分区,获得指定数目的rowid Extent区间(Group sets of rows in the table into smaller chunks), 以便于非分区表利用rowid来实现并行删除或更新:  
REM  rowid_ranges should be at least 21
REM  utilize this script help delete large table
REM  if update large table  Why not online redefinition or CTAS
-- This script spits desired number of rowid ranges to be used for any parallel operations.
-- Best to use it for copying a huge table with out of row lob columns in it or CTAS/copy the data over db links.
-- This can also be used to simulate parallel insert/update/delete operations.
-- Maximum number of rowid ranges you can get here is 255.
-- Doesn't work for partitioned tables, but with minor changes it can be adopted easily.-- Doesn't display any output if the total table blocks are less than rowid ranges times 128.-- It can split a table into more ranges than the number of extents
From Saibabu Devabhaktuni  http://sai-oracle.blogspot.com/2006/03/how-to-split-table-into-rowid-ranges.htmlset verify off
undefine rowid_ranges
undefine segment_name
undefine owner
set head off
set pages 0
set trimspool onselect 'where rowid between ''' ||sys.dbms_rowid.rowid_create(1, d.oid, c.fid1, c.bid1, 0) ||''' and ''' ||sys.dbms_rowid.rowid_create(1, d.oid, c.fid2, c.bid2, 9999) || '''' ||';'from (select distinct b.rn,first_value(a.fid) over(partition by b.rn order by a.fid, a.bid rows between unbounded preceding and unbounded following) fid1,last_value(a.fid) over(partition by b.rn order by a.fid, a.bid rows between unbounded preceding and unbounded following) fid2,first_value(decode(sign(range2 - range1),1,a.bid +((b.rn - a.range1) * a.chunks1),a.bid)) over(partition by b.rn order by a.fid, a.bid rows between unbounded preceding and unbounded following) bid1,last_value(decode(sign(range2 - range1),1,a.bid +((b.rn - a.range1 + 1) * a.chunks1) - 1,(a.bid + a.blocks - 1))) over(partition by b.rn order by a.fid, a.bid rows between unbounded preceding and unbounded following) bid2from (select fid,bid,blocks,chunks1,trunc((sum2 - blocks + 1 - 0.1) / chunks1) range1,trunc((sum2 - 0.1) / chunks1) range2from (select /*+ rule */relative_fno fid,block_id bid,blocks,sum(blocks) over() sum1,trunc((sum(blocks) over()) / &&rowid_ranges) chunks1,sum(blocks) over(order by relative_fno, block_id) sum2from dba_extentswhere segment_name = upper('&&segment_name')and owner = upper('&&owner'))where sum1 > &&rowid_ranges) a,(select rownum - 1 rnfrom dualconnect by level <= &&rowid_ranges) bwhere b.rn between a.range1 and a.range2) c,(select max(data_object_id) oidfrom dba_objectswhere object_name = upper('&&segment_name')and owner = upper('&&owner')and data_object_id is not null) d/

更多相关:

  • 这个课程的参考视频在youtube。     主要学到的知识点有: Create new project, choose Java Application.one .jar file/ package(.jar name with the same as package), one package can contains mutip...

  • 分享SLAM包含了两个主要的任务:定位与构图,在移动机器人或者自动驾驶中,这是一个十分重要的问题:机器人要精确的移动,就必须要有一个环境的地图,那么要构建环境的地图就需要知道机器人的位置。本系列文章主要分成四个部分:在第一部分中,将介绍Lidar SLAM,包括Lidar传感器,开源Lidar SLAM系统,Lidar中的深度学习以...

  • 参观临时城市中心 想象一下新兴的后世界末日城市中心,这里有大量的临时住所、建筑群、小屋、道具和固定装置。用一系列非常详细的废弃街区快速构建您的场景,并用波纹铁、水箱、折叠椅和劣质电线进一步修饰它们。从足球场到摇摇欲坠的码头,每一个摇摇欲坠的单元都制作独特,可以无限定制。 大小解压后:4.29G 格式:FBX 含贴图素材 模型...

  • 6、TEXT PROCESSING SERVICES :文本处理服务 6.1、re 8、DATA TYPES : 数据类型 8.1、datetime 8.2、collections 8.3、copy 9、 NUMERIC AND MATHEMATICAL MODULES : 数字和数学模块 9.1、random 10、FUNCTIO...

  • Start the computer and start pressing F1 and get into set up. In setup press F9 for default settings and press F10 for svae and exit. Problem solved. 转载于:https://www...

  • 响应式布局简明示例,响应式布局最好同时也是自适应布局,然后再配合css3媒体查询,来达到完美的响应式布局。css3的媒体查询ie9一下是不支持的,这太遗憾了,不过幸运的是有大神已经为前端屌丝们写好了用于IE9以下的媒体查询脚本文件,引用方式如下: