ORACLE 查看系统运行情况

前端之家收集整理的这篇文章主要介绍了ORACLE 查看系统运行情况前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



1,查看系统当前连接会话数


select s.value,s.sid,a.username
from
v$sesstat S,v$statname N,v$session A
where
n.statistic#=s.statistic# and
name='session pga memory'
and s.sid=a.sid
order by s.value;


2,等待最多的用户

SELECT s.SID,s.username,SUM (a.wait_time + a.time_waited) total_wait_time
FROM v$active_session_history a,v$session s
WHERE a.sample_time BETWEEN SYSDATE - 30 / 2880 AND SYSDATE
GROUP BY s.SID,s.username
ORDER BY total_wait_time DESC;


3,查看死锁信息

SELECT (SELECT username
FROM v$session
WHERE SID = a.SID) blocker,a.SID,'is blocking',

(SELECT username
WHERE SID = b.SID) blockee,b.SID
FROM v$lock a,v$lock b
WHERE a.BLOCK = 1 AND b.request > 0 AND a.id1 = b.id1 AND a.id2 = b.id2;


4,找使用cpu多的用户session

select a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value
from v$session a,v$process b,v$sesstat c
where c.statistic#=12 and
c.sid=a.sid and
a.paddr=b.addr
order by value desc;

5,监控当前数据库谁在运行什么sql语句

select osuser,username,sql_text
sqltext b
where a.sql_address =b.address order by address,piece;

6,查询表空间的使用情况

SELECT UPPER(F.TABLESPACE_NAME) "表空间名",
  D.TOT_GROOTTE_MB "表空间大小(M)",255)">  D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",255)">  TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),'990.99') || '%' "使用比",255)">  F.TOTAL_BYTES "空闲空间(M)",255)">  F.MAX_BYTES "最大块(M)"
  FROM (SELECT TABLESPACE_NAME,255)">  ROUND(SUM(BYTES) / (1024 * 1024),2) TOTAL_BYTES,255)">  ROUND(MAX(BYTES) / (1024 * 1024),2) MAX_BYTES

  FROM SYS.DBA_FREE_SPACE
  GROUP BY TABLESPACE_NAME) F,255)">  (SELECT DD.TABLESPACE_NAME,255)">   ROUND(SUM(DD.BYTES) / (1024 * 1024),2) TOT_GROOTTE_MB
  FROM SYS.DBA_DATA_FILES DD
  GROUP BY DD.TABLESPACE_NAME) D
  WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
  ORDER BY 1;


7,查询表空间总容量

select tablespace_name,sum(bytes) / 1024 / 1024 as MB
  from dba_data_files

  group by tablespace_name;


8,查看表空间下的所有表



select table_name from all_tables where TABLESPACE_NAME='TS_SJXT' //表空间要大写


9,查看表所在的表空间

select * from user_tables where table_name= 'ORBIT_IMAGE' / /表名要大写

猜你在找的Oracle相关文章