oracle问题处理sql

Posted Qtong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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问题处理sql的主要内容,如果未能解决你的问题,请参考以下文章

Oracle查询语句导致CPU使用率过高问题处理

如何在 oracle-sql 中计算周一待处理票的总数?

如何在 Oracle SQL 中处理单引号

从 bat 文件(oracle、批处理)运行 sql 脚本

PL/SQL Oracle 错误处理

Oracle SQL 运行批处理