首 页IT知识库翔宇问吧收藏内容
当前位置:翔宇亭IT乐园IT知识库数据库Oracle

如何整理Oracle数据库碎片

减小字体 增大字体 作者:不详  来源:华军资讯  发布时间:2010-02-06 21:01:00

  4、zi you范围的碎片整理

  1)表空间的 pctincrease 值为非 0。

  可以将表空间的缺省存储参数 pctincrease 改为非 0 。一般将其设为 1 ,如:

  alter tablespace temp   default storage(pctincrease 1);

  这样 SMON 便会将zi you范围自动合并。也可以手工合并zi you范围: alter tablespace temp coalesce
  
   5、段的碎片整理

  我们知道,段由范围组成。在有些情况下,有必要对段的碎片进行整理。要查看段的有关信息,可查看数据字典 dba_segments ,范围的信息可查看数据字典 dba_extents 。如果段的碎片过多,将其数据压缩到一个范围的最简单方法便是用正确的存储参数将这个段重建,然后将旧表中的数据插入到新表,同时删除旧表。这个过程可以用 Import/Export (输入 / 输出)工具来完成。

  Export ()命令有一个(压缩)标志,这个标志在读表时会引发 Export 确定该表所分配的物理空间量,它会向输出转储文件写入一个新的初始化存储参数 -- 等于全部所分配空间。若这个表关闭, 则使用 Import ()工具重新生成。这样,它的数据会放入一个新的、较大的初始段中。例如:

  exp user/password file=exp.dmp compress=Y grants=Y indexes=Y   tables=(table1,table2);

  若输出成功,则从库中删除已输出的表,然后从输出转储文件中输入表:

  imp user/password file=exp.dmp commit=Y buffer=64000 full=Y

  这种方法可用于整个数据库。

  以上简单分析了 Oracle 数据库碎片的产生、计算方法及整理,仅供参考。数据库的性能优化是一项技术含量高,同时又需要有足够耐心、认真细致的工作。 对数据库碎片的一点探讨,

  下面是一种如何自动处理表空间碎片的代码,希望对上大家看上文有用

  Coalesce Tablespace Automatically

  This technique comes from Sandeep

  Naik, a database administrator

  for GSXXI, Inc. in New York City, New York

  Here is a handy script which can be

  scheduled to automatically run

  and coalesces the tablespaces.

  This script is designed to run in NT

  but can be run in any operating system

  by slight modifications in the path where the file spools

  from the SQLPLUS environment.

  It assumes that the user who runs the script

  has priviledges to view the data dictionary.

  Start of code

  --------------------------------------

  sqlplus /

  prompt this script will coalesce the

  tablespace automatically

  set verify off;

  set termout off;

  set head off;

  spool c: empcoalesce.log

  select alter tablespace

  ||TABLESPACE_NAME|| coalesce ;

  from DBA_FREE_SPACE_COALESCED where

  PERCENT_EXTENTS_COALESCED <100

  or PERCENT_BLOCKS_COALESCED<100 ;

  spool off;

  @ c: empcoalesce.log

  set head on;

  set termout on;

  set verify on;

  prompt Tablespaces are coalesced successfully

上一页  [1] [2] 

微信搜索“优雅的代码”关注本站的公众号,或直接使用微信扫描下面二维码关注本站公众号,以获取最新内容。

个人成长离不开各位的关注,你的关注就是我继续前行的动力。

知识评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
愿您的精彩评论引起共鸣,带来思考和价值。
用户名: 查看更多评论
分 值:100分 90分 80分 70分 60分 40分 20分
内 容:
验证码:
关于本站 | 网站帮助 | 广告合作 | 网站声明 | 友情连接 | 网站地图
本站部分内容来自互联网,如有侵权,请来信告之,谢谢!
Copyright © 2007-2022 biye5u.com. All Rights Reserved.