C/C++教程

Oracle数据库多个表空间使用情况查询

本文主要是介绍Oracle数据库多个表空间使用情况查询,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

-- 1. 统计数据表空间
select a.tablespace_name,a.total_tbs,b.one_tbs,f_data_div(one_tbs,total_tbs) from
(select tablespace_name,round(sum(bytes)/1024/1024,0) total_tbs from dba_data_files
where tablespace_name in ('xxxx_TABLESPACE','xxxx','xxxx_TABLESPACE')
group by tablespace_name) a
LEFT JOIN
(select tablespace_name,round(sum(bytes)/1024/1024,0) one_tbs from dba_segments
where tablespace_name in ('xxxx_TABLESPACE','xxxx','xxxx_TABLESPACE')
group by tablespace_name) b
ON a.tablespace_name = b.tablespace_name
order by f_data_div(one_tbs,total_tbs) desc;

-- 2. 查看正在执行的SQL脚本
select b.sql_text,a.* from gv$session a,gv$sqlarea b
where a.sql_id = b.sql_id
and b.sql_text <> 'SELECT sysdate FROM dual' ;

-- 3. 查询死锁
select c.sid,
c.SERIAL#,
a.OBJECT_ID,
a.ORACLE_USERNAME,
a.OS_USER_NAME,
b.object_name,
d.sql_text
from gv$locked_object a, dba_objects b, gv$session c,gv$sqlarea d
where a.OBJECT_Id = b.object_id
and a.SESSION_ID = c.SId
and c.sql_id=d.sql_id ;

-- 4. 查询当前数据库连接数(1节点1690;2节点230,如果1节点超过2000,需要预警)
select inst_id,count(*)  from gv$session
group by inst_id;

这篇关于Oracle数据库多个表空间使用情况查询的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!