【空间管理】检测表空间空间的使用情况以及碎片

       检测表空间的使用情况以及碎片,要到两个数据字典表:dba_data_files和dba_free_space.其中dba_data_files描述了每个数据文件的信息,而dba_free_space则描述了表空间中每一段连续空闲空间的情况,为此可以透过看空闲空间的数量来初步估算表空间的碎片情况。

SQL> col "表空间" format A20;
SQL> set linesize 100 pagesize 100;
SQL> select df.tablespace_name "表空间",
  2         df.total           "最大空间M",
  3         df.allocated       "已分配空间M",
  4         df.unallocated     "未分配空间M",
  5         df.allocated-ds.freespace "已使用空间M",
  6         round((df.allocated-ds.freespace)/df.allocated*100,2) "使用率%",
  7         ds.fragment "碎片量"
  8  from
  9  (select tablespace_name,
 10          round(sum(maxbytes/1024/1024),2) total,
 11          round(sum(bytes/1024/1024),2) allocated,
 12          round(sum((maxbytes-bytes)/1024/1024),2) unallocated
 13   from dba_data_files group by tablespace_name) df,
 14  (select tablespace_name,
 15          round(sum(bytes/1024/1024),2) freespace,
 16          count(*) fragment
 17   from dba_free_space group by tablespace_name)ds
 18  where df.tablespace_name=ds.tablespace_name;

表空间                最大空间M 已分配空间M 未分配空间M 已使用空间M    使用率%     碎片量
-------------------- ---------- ----------- ----------- ----------- ---------- ----------
SYSAUX                 32767.98         600    32167.98      568.19       94.7          1
UNDOTBS1               32767.98         100    32667.98       24.12      24.12          3
USERS                  32767.98       33.75    32734.23       31.19      92.41          2
SYSTEM                 32767.98         690    32077.98      687.75      99.67          2
EXAMPLE                32767.98         100    32667.98       78.75      78.75          3
TEST01                       25          19           6           1       5.26          1

已选择6行。

SQL>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值