sql plsql note2





1. 求当前会话的SID,SERIAL#

SELECT sid,
       serial#
FROM v$session
WHERE sid = sys_context(‘userenv’, ’sid’);

–view
  v$session

–core
  select sys_context(‘userenv’,’sid’) from dual;
–function
  sys_context
  userenv

–parameter
  sessionid
  session_user
  ip_address
  ….

–see also
  1. context
     Security Guide — 6 Using Application Contexts to Retrieve User Information
2. 查询session的OS进程ID

SELECT p.spid    "OS Thread",   
       s.program "Program",     
       s.sid     "Session_id",  
       s.osuser  "OS User",     
       s.machine "Host Name"    
FROM   v$process p,             
       v$session s              
WHERE  p.addr = s.paddr         
AND    (s.sid=&1 or p.spid=&1); 

–view
  v$process
  v$session

–core
  v$process.addr = v$session.paddr
  s.sid=&1

–see also
  1. Substitution Variables &(ampersand)
     SQL*Plus? User’s Guide and Reference – 5 Using Scripts in SQL*Plus – Using Substitution Variables




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

only 1 comment untill now

  1. madly@agreement.litigation” rel=”nofollow”>.…

    tnx for info!…

Add your comment now

无觅相关文章插件