ORACLE常用
数据库  /  管理员 发布于 4年前   285
select count(*) from v$session;
SELECT substr(v$lock.sid,1,4) "SID",
substr(username,1,12) "UserName",osuser,machine,
substr(object_name,1,25) "ObjectName",
v$lock.type "LockType",
decode(rtrim(substr(lmode,1,4)),
'2','Row-S (SS)','3','Row-X (SX)',
'4','Share', '5','S/Row-X (SSX)',
'6','Exclusive', 'Other' ) "LockMode",
substr(v$session.program,1,25) "ProgramName"
FROM V$LOCK,SYS.DBA_OBJECTS,V$SESSION
WHERE (OBJECT_ID = v$lock.id1
AND v$lock.sid = v$session.sid
AND username IS NOT NULL
AND username NOT IN ('SYS','SYSTEM')
AND SERIAL# != 1);
语句 execute DBMS_UTILITY.ANALYZE_DATABASE('COMPUTE',10000,NULL,'');
select table_name,num_rows,blocks,empty_blocks,avg_space,chain_cnt,avg_row_len,last_analyzed from all_tables where owner='RMS'
分析单表 analyze table rms.user_port compute statistics
select index_name,blevel,leaf_blocks,distinct_keys,avg_leaf_blocks_per_key,avg_data_blocks_per_key,clustering_factor,last_analyzed from all_indexes where owner='RMS';
select 'analyze table rms.'||segment_name||' compute statistics ;'segment_name,sum(bytes)/1024/1024 MB from user_segments,all_tables
where all_tables.owner='RMS' and all_tables.table_name= segment_name GROUP BY segment_name
语句 select table_name,chain_cnt from user_tables order by chain_cnt desc
select table_name,chain_cnt from all_tables where owner='RMS' order by chain_cnt desc
语句 "select 1-(phy.value/(cur.value+con.value)) from v$sysstat cur,v$sysstat con,v$sysstat phy
where cur.name='db block gets' and con.name='consistent gets'
and phy.name='physical reads'"
db block gets 4709479237
consistent gets 22146942
physical reads 8931785
命中率 0.998112322 1-physical reads/(db block gets+consistent gets)
建议 达到0.90或以上认为是好的
" column c0 heading 'Owner' format a15
column c1 heading 'Object|Name' format a30
column c2 heading 'Number|of|Buffers' format 999,999
column c3 heading 'Percentage|ofData|Buffer' format 999,999,999
select
owner c0,
object_name c1,
count(1) c2,
(count(1)/(select count(*) from v$bh)) *100 c3
from
dba_objects o,
v$bh bh
where
o.object_id = bh.objd
and
o.owner not in ('SYS','SYSTEM')
group by
owner,
object_name
order by
count(1) desc
;"
语句 SELECT SUM(pins-reloads)/SUM(pins) from v$librarycache
建议 低于0.99需要试着改善它,可以增加共享池的规模来改善它,如果有很多可用空间那就得从改善我们的程序
查看当前未使用的共享池 "select to_number(v$parameter.value) value, v$sgastat.BYTES,
(v$sgastat.bytes/v$parameter.value)*100 ""percent free""
from v$sgastat, v$parameter
where v$sgastat.name= 'free memory'
and v$parameter.name = 'shared_pool_size'
and v$sgastat.pool='shared pool'"
ALTER SYSTEM FLUSH SHARED_POOL;
语句 select sum(gets-getmisses-usage-fixed)/sum(gets) from v$rowcache
建议 达到0.85或以上认为是可以接受的
语句 select sum(gets),sum(waits),sum(waits)/sum(gets) from v$rollstat
建议 大于1%需要处理,可以通过更多回滚段来降低争用
查看回滚段的使用情况,哪个用户正在使用回滚段的资源,如果有用户最好更换时间(特别是生产环境)。
"
select s.username, u.name from v$transaction t,v$rollstat r,
v$rollname u,v$session s where s.taddr=t.addr and
t.xidusn=r.usn and r.usn=u.usn order by s.username;
"
"SELECT a.name , b.xacts ""活动事务个数"", b.writes ""写入的字节数"", b.extents as ""区个数""
FROM v$rollname a, v$rollstat b
WHERE a.usn=b.usn;"
语句 select name,shrinks from v$rollstat,v$rollname where V$rollstat.usn=v$rollname.usn
select name,value from v$sysstat where name ='redo buffer allocation retries'
select 'ALTER TABLE '||TABLE_NAME||' DISABLE CONSTRAINT '||CONSTRAINT_NAME||';' from all_constraints where owner='RMS' AND CONSTRAINT_TYPE<>'P'
发现表链接行
select table_name,chain_cnt from user_tables order by chain_cnt desc;
"SELECT UPPER(F.TABLESPACE_NAME) ""表空间名"",
D.TOT_GROOTTE_MB ""表空间大小(M)"",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES ""已使用空间(M)"",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,
123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号