oracle 会话 死锁 执行sql 执行job的方法

前端之家收集整理的这篇文章主要介绍了oracle 会话 死锁 执行sql 执行job的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="jb51code">
<pre class="brush:sql;">
//根据用户分组会话
select t.USERNAME,count() from v$session t group by t.USERNAME
//查找某一用户正在执行的sql_id值
select
from v$session t where t.USERNAME = 'BUDGET' and t.sql_ID is not null
//查找对应sql_id的对应sql语句
select m.sql_TEXT from v$session t,v$sqlarea m where t.USERNAME ='BUDGET' and t.sql_id = m.sql_ID
//
select from v$sqlarea t where t.sql_ID = 'g92sy7kwt6mrq'
//查询死锁对象
select
from v$locked_object

1、修改Oracle最大连接数的方法

sql;"> a、以sysdba身份登陆PL/sql 或者 Worksheet b、查询目前连接数 show parameter processes; c、更改系统连接数 alter system set processes=1000 scope=spfile; d、创建pfile create pfile from spfile; e、重启Oracle服务或重启Oracle服务器 2、查询Oracle游标使用情况的方法 select * from v$open_cursor where user_name = 'TRAFFIC'; 3、查询Oracle会话的方法 select * from v$session

杀掉会话:

方法

sql> SELECT pid,spid FROM V$PROCESS WHERE ADDR IN (SELECT PADDR FROM V$SESSION where username ='SYS');
PID SPID
---------- ------------
17 13657

ps -ef |grep 13657
kill -9 13657

方法


sql> SELECT sid,serial# FROM V$SESSION WHERE sid in (SELECT distinct sid FROM V$MYSTAT);
SID SERIAL#

---------- ----------
1637 13894

alter system disconnect session '1637,13894' immediate;
执行这句会提示:ora-00031:标记要终止的会话。。。但是其实执行成功了。
如果用pl/sql登陆客户端那边会提示:ora-00028:您的会话已经被终止。

查看正在执行sql进度:
SELECT SE.SID,OPNAME,TRUNC(SOFAR / TOTALWORK * 100,2) || '%' AS PCT_WORK,ELAPSED_SECONDS ELAPSED,ROUND(ELAPSED_SECONDS * (TOTALWORK - SOFAR) / SOFAR) REMAIN_TIME,sql_TEXT
FROM V$SESSION_LONGOPS SL,V$sqlAREA SA,V$SESSION SE
WHERE SL.sql_HASH_VALUE = SA.HASH_VALUE AND SL.SID = SE.SID AND SOFAR != TOTALWORK
ORDER BY START_TIME

SELECT a.tablespace_name "表空间名",round(total/1024/1024/1024,4) 表空间大小Gb,round(free/1024/1024/1024,4) 表空间剩余大小Gb,
round((total-free)/1024/1024/1024,4) 表空间使用大小Gb,ROUND((total-free)/total,4)*100 "使用率 %"
FROM (SELECT tablespace_name,SUM(bytes) free FROM DBA_FREE_SPACE
GROUP BY tablespace_name ) a,
(SELECT tablespace_name,SUM(bytes) total FROM DBA_DATA_FILES GROUP BY tablespace_name) b
WHERE a.tablespace_name=b.tablespace_name order by 5 desc

强制停止oracle正在执行的job:



1、查看所有job;
select * from dba_jobs;
2、查看正在运行的job;
select * from dba_jobs_running;
3、根据sid查出对应的session;
select SID,SERIAL# from V$Session where SID='&SID';
4、kill对应的session;
alter system kill session '&SID,&SERIAL';
5、将job置为broken;
exec dbms_job.broken('&JOB',true);
6、sysdba用户权限删除job;
delete from dba_jobs where JOB='&JOB';
---实在无奈时启动数据库

猜你在找的Oracle相关文章