oracle中什么是碎片,如何整理Oracle数据库碎片

5、段的碎片整理

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

Export ()ming令有一个(压缩)标志,这个标志在读表时会引发 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值