• 查看oracle当前连接数和进程数


    查询数据库当前进程的连接数:

      select count(*) from v$process;

    查看数据库当前会话的连接数:

      select count(*) from v$session;

    查看数据库的并发连接数:

      select count(*) from v$session where status='ACTIVE';

    查看当前数据库建立的会话情况:

      select sid,serial#,username,program,machine,status from v$session;

    查询数据库允许的最大连接数:

      select value from v$parameter where name = 'processes';

      或者:show parameter processes;

    查询所有数据库的连接数

      selectschemaname,count(*)fromv$sessiongroupbyschemaname;

    查询终端用户使用数据库的连接情况。

      selectosuser,schemaname,count(*)fromv$sessiongroupbyschemaname,osuser;

    #修改连接

      alter system set processes = value scope = spfile

    修改数据库允许的最大连接数:

      alter system set processes = 300 scope = spfile;

      (需要重启数据库才能实现连接数的修改)

    重启数据库:

      shutdown immediate;

      startup;

    查看当前有哪些用户正在使用数据:

      select osuser,a.username,cpu_time/executions/1000000||'s',sql_fulltext,machine

      from v$session a,v$sqlarea b

      where a.sql_address = b.address

      order by cpu_time/executions desc;

    备注:UNIX 1个用户session对应一个操作系统process,而Windows体现在线程。

    oracle中查询被锁的表并释放session

      SELECT A.OWNER,A.OBJECT_NAME,B.XIDUSN,B.XIDSLOT,B.XIDSQN,B.SESSION_ID,B.ORACLE_USERNAME, B.OS_USER_NAME,B.PROCESS, B.LOCKED_MODE,   C.MACHINE,C.STATUS,C.SERVER,C.SID,C.SERIAL#,C.PROGRAM

      FROM ALL_OBJECTS A,V$LOCKED_OBJECT B,SYS.GV_$SESSION C

      WHERE ( A.OBJECT_ID = B.OBJECT_ID ) AND (B.PROCESS = C.PROCESS ) ORDER BY 1,2

    释放session Sql:

      alter system kill session 'sid, serial#'

      alter system kill session '379, 21132'

      alter system kill session '374, 6938'

    查看占用系统io较大的session

      SELECT se.sid,se.serial#,pr.SPID,se.username,se.status,se.terminal,se.program,se.MODULE,se.sql_address,st.event,st.p1text,si.physical_reads,si.block_changes

      FROM v$session se, v$session_wait st,v$sess_io si,v$process pr

      WHERE st.sid=se.sid AND st.sid=si.sid AND se.PADDR=pr.ADDR AND se.sid>6 AND st.wait_time=0 AND st.event NOT LIKE '%SQL%' ORDER BY physical_reads DESC

    找出耗cpu较多的session

      select a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value

      from v$session a,v$process b,v$sesstat c

      where c.statistic#=12 and c.sid=a.sid and a.paddr=b.addr order by value desc

     

  • 相关阅读:
    安装yum源和gcc编译器遇到的问题
    (转)Linux下C++开发初探
    (转)求模和求余
    scanf———while(scanf ("%lu",&num) = =1)什么意思
    【Eclipse】 Alt+/ 代码提示问题解决方案
    【正则表达式】常用正则表达式
    【JAVA】Quartz中时间表达式的设置
    【Oracle】如何导库
    【JAVA】JMX简单使用方法
    【JAVA】Math.Round()函数常见问题“四舍5入”
  • 原文地址:https://www.cnblogs.com/guanghe/p/9084008.html
Copyright © 2020-2023  润新知