Home > Database > Mysql Tutorial > ORACLE临时表空间的清理

ORACLE临时表空间的清理

WBOY
Release: 2016-06-07 15:14:00
Original
1410 people have browsed it

欢迎进入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] 

ORACLE临时表空间的清理

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template