oracle查看临时表空间使用情况的方法
来源:网络收集 点击: 时间:2024-04-16打开PLSQL Developer工具软件,并登录要查看临时表空间的数据库。

点击【文件】菜单下的【新建】选项,选择【SQL窗口】,新建一个窗口。

要查询数据库的表空间使用情况,必须借助两个系统视图,一个叫dba_temp_files,主要存储临时表空间的文件信息,输入select * from dba_temp_files 语句并执行查询,显示例子的数据库中存在两个临时表空间文件及相关信息。

接着用group by语句将dba_temp_files 视图按tablespace_name对bytes字段进行汇总,即统计临时表空间总的字节数大小。执行如下语句:
select tablespace_name, sum(bytes) bytes
from dba_temp_files group by tablespace_name

另一个系统视图叫v$temp_extent_pool 记录临时表空间的存储空间信息。执行语句select * from v$temp_extent_pool 可查出本例中两个临时表空间的相关信息。

同样用group by 语句按tablespace_name对bytes_cached字段进行汇总,即按表空间名统计表空间的总使用字节数。执行如下语句可查询:
select tablespace_name, sum(bytes_cached) bytes_used
from v$temp_extent_pool group by tablespace_name

现在临时的总大小有了,总的使用数也有了,可以将步骤4和步骤6的两个汇总查询作为子查询连接起来查,计算使用百分比,执行以下语句:
select a.tablespace_name,
to_char(a.bytes / 1024 / 1024, 99,999.999) total_bytes,
to_char(b.bytes_used / 1024 / 1024, 99,999.999) use_bytes,
to_char(b.bytes_used * 100 / a.bytes, 99.99) || % use
from (select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes_cached) bytes_used
from v$temp_extent_pool
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
计算用tablespace_name关联计算表空间的使用率并除以两次1024换算成M。

版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_520346.html