作为DBA需要对oracle的连接情况和内存使用情况了如指掌,不能等出问题的时候再去排除问题,平时也需要做好监控。下面分享下怎么通过sql去查看oracle的连接情况和内存使用情况。
select machine,count(*) from v$session group by machine;
select machine,status,count(*)from v$sessiongroup by machine,statusorder by status;
select ‘SGA’ AS NAME,ROUND(sum(value)/1024/1024,2)||’M’ AS “SIZE(M)” from v$sga;
select ‘PGA’ AS NAME,ROUND(value/1024/1024,2)||’M’ AS “SIZE(M)” from v$pgastatwhere name=’total PGA allocated’;
select ‘TOTAL’ AS NAME,((SELECT ROUND(sum(value)/1024/1024,2)from v$sga)+(select ROUND(value/1024/1024,2)from v$pgastatwhere name=’total PGA allocated’))||’M’ AS “SIZE(M)” FROM DUAL;
SELECT NAME,TO_CHAR(VALUE)FROM V$PGASTATWHERE NAME=’process count’;
SELECT * FROM V$PROCESS_MEMORY;
SELECT PROGRAM, PGA_USED_MEM, PGA_ALLOC_MEM, PGA_FREEABLE_MEM, PGA_MAX_MEM FROM V$PROCESS;
大家有什么好的sql也可以一起分享下哦,共勉。