热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

ORACLE临时表空间的清理

欢迎进入Oracle社区论坛,与200万技术人员互动交流进入ORACLE临时表空间的清理--查看使用率columnTablespaceNameformata40headingTablespaceNamecolumnTotalUsedBytesformat9,999,999,999headingFileSizes|(K)columnTotalFreeBytes

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 ORACLE临时表空间的清理 --查看使用率 column TablespaceName format a40 heading 'Tablespace Name' column TotalUsedBytes format 9,999,999,999 heading 'File Sizes|(K)' column TotalFreeBytes

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

  ORACLE临时表空间的清理

  --查看使用率

  column TablespaceName format a40 heading 'Tablespace Name'

  column TotalUsedBytes format 9,999,999,999 heading 'File Sizes|(K)'

  column TotalFreeBytes format 9,999,999,999 heading 'Free Bytes|(K)'

  column FreeRatio format 990.99 heading 'Free|(%)'

  column TotalExtensibleBytes format 9,999,999,999 heading 'Extensible|Sizes (K)'

  column TotalExtends format 9999 heading 'Ext'

  compute sum label 'Total:' of TotalFreeBytes TotalUsedBytes TotalExtensibleBytes on report

  break on report

  select b.TablespaceName,

  round(sum(b.UsedByte) / 1024) TotalUsedBytes,

  round(sum(a.FreeByte) / 1024) TotalFreeBytes,

  round(sum(b.ExtensibleByte) / 1024) TotalExtensibleBytes,

  round(sum(a.FreeByte + b.ExtensibleByte) * 100 / sum(b.UsedByte + b.ExtensibleByte), 2) FreeRatio,

  sum(a.Extend) TotalExtends

  from (select sum(bytes) FreeByte,

  count(*) Extend,

  file_id FileID,

  tablespace_name TablespaceName

  from dba_free_space

  group by file_id,

  tablespace_name

  union all

  select sum(bytes_free) FreeByte,

  count(*) Extend,

  file_id FileID,

  tablespace_name TablespaceName

  from v$temp_space_header

  group by file_id,

  tablespace_name) a,

  (select decode(autoextensible, 'YES', decode(sign(maxbytes - bytes), 1, maxbytes - bytes, 0), 0) ExtensibleByte,

  bytes UsedByte,

  file_id FileID,

  tablespace_name TablespaceName

  from dba_data_files

  union all

  select decode(autoextensible, 'YES', decode(sign(maxbytes - bytes), 1, maxbytes - bytes, 0), 0) ExtensibleByte,

  bytes UsedByte,

  file_id FileID,

  tablespace_name TablespaceName

  from dba_temp_files) b

  where b.FileID = a.FileID(+) and

  b.TablespaceName= a.TablespaceName(+)

  group by b.TablespaceName;

  正常来说,在完成Select语句、create index等一些使用TEMP表空间的排序操作后,Oracle是会自动释放掉临时段a的。但有些有侯我们则会遇到临时段没有被释放,TEMP表空间几乎满的状况,甚至是我们重启了数据库仍没有解决问题。这个问题在论坛中也常被网友问到,下面总结一下,给出几种处理方法。

  法一、重启库

  库重启时,Smon进程会完成临时段释放,TEMP表空间的清理操作,不过很多的时侯我们的库是不允许down的,所以这种方法缺少了一点的应用机会,不过这种方法还是很好用的。

  法二、Metalink给出的一个方法

  修改一下TEMP表空间的storage参数,让Smon进程观注一下临时段,从而达到清理和TEMP表空间的目的。

  SQL>alter tablespace temp increase 1;

  SQL>alter tablespace temp increase 0;

[1] [2]


推荐阅读
author-avatar
宫廷的围脖6uw_1911
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有