oracle问题处理sql

前端之家收集整理的这篇文章主要介绍了oracle问题处理sql前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

select * from DBA_HIST_SYSMETRIC_SUMMARY;
select sum(inserts) inserts,sum(UPDATES) UPDATES,sum(DELETES) DELETES from dba_tab_modifications where TABLE_OWNER=‘ZXJPT‘;
desc dba_tab_modifications;


SELECT *
FROM (SELECT *
FROM V$SYSTEM_EVENT
WHERE EVENT NOT LIKE ‘sql%‘
ORDER BY TOTAL_WAITS DESC)
WHERE ROWNUM <= 5;
desc BJ_LOCKSALEORDER;
select name from v$database;

select * from dba_users

select sql_id from v$session a where a.STATUS=‘ACTIVE‘ and a.LAST_CALL_ET>1 and a.username is not null

select * from dba_datapump_sessions

select * from v$sql where sql_id in (select sql_id from v$session a where a.STATUS=‘ACTIVE‘ and a.LAST_CALL_ET>1 and a.username is not null)

 

---tx锁
select last_call_et,v.event,
s.sql_id,
s.sql_FULLTEXT,
s.sql_TEXT,
v.USERNAME,
s.cpu_TIME,
s.ELAPSED_TIME,
v.PROGRAM,
‘kill -9 ‘ || p.spid,
v.CLIENT_INFO,
v.sql_HASH_VALUE,
v.sql_ADDRESS,
v.MACHINE,
v.TERMINAL,
‘alter system kill session ‘‘‘ || v.sid || ‘,‘ || v.serial# || ‘‘‘ immediate;‘,
s.DISK_READS,s.BUFFER_GETS,s.SORTS,s.SHARABLE_MEM,s.PERSISTENT_MEM,s.RUNTIME_MEM,s.ROWS_PROCESSED
from v$session v,v$process p,v$sql s
where v.last_call_et > 1
and v.status = ‘ACTIVE‘
and v.username != ‘SYS‘
and p.addr = v.paddr
and s.ADDRESS = v.sql_ADDRESS
and s.HASH_VALUE = v.sql_HASH_VALUE
order by last_call_et desc;

select segment_name,status from dba_rollback_segs;--???OFFLINE

select s.sid blocker,
s.event hevent,
w.event wevent,
w.sid blocked
from v$session s,v$session w
where w.blocking_session = s.sid
and w.blocking_session_status=‘VALID‘;

-----有问题sql

select t1.nnum,
t1.nmny,
t1.ntaxmny,
t1.ndiscountmny,
t1.ndiscounttaxmny,
t1.csaleorderbid,
v.*
from me_saleorderpro t1
left outer join (select sum(t2.nnum) over(partition by t2.csaleorderbid) sumout,
sum(nvl(t2.naccumwastnum,0)) over(partition by t2.csaleorderbid) sumwast,
sum(t2.ndiscountmny) over(partition by t2.csaleorderbid) sumdismny,
sum(t2.ndiscounttaxmny) over(partition by t2.csaleorderbid) sumtaxdismny,
t2.csaleorderbid,
t2.ntaxprice,
t2.nprice,
sum(t2.nmny) over(partition by t2.csaleorderbid) summny,
sum(t2.ntaxmny) over(partition by t2.csaleorderbid) sumtaxmny
from me_saleoutpro t2
where t2.csaleorderbid in
(‘1001S21000000005TSAT‘,‘1001S21000000005TTG3‘)) v on v.csaleorderbid =
t1.csaleorderbid
and v.ntaxprice =
t1.ntaxprice
where t1.csaleorderbid in (‘1001S21000000005TSAT‘,‘1001S21000000005TTG3‘)


--修改
select count(*),csaleorderbid from me_saleoutpro group by csaleorderbid
不同的多吗


--解释计划窗口
可以查看sql执行耗时情况

--创建索引create index Mesalcsaleorder on me_saleoutpro(csaleorderbid);create index Mesaleordercsaleorderbid on me_saleorderpro(csaleorderbid);

猜你在找的Oracle相关文章