oracle - sqlplus how to find details of the currently connected database session -


i have started work on oracle databases. have many sqlplus windows open different oracle databases. when switching 1 sqlplus session another, how can view current session details each sqlplus session ? appreciated!

take @ 1 (c) tanel poder. may either run glogin.sql (so these settings update each time connect, or run manually. notice host title command - changes sql*plus console window title session information - extremely useful many windows open simultaneously.

-- script  def   mysid="na" def _i_spid="na" def _i_cpid="na" def _i_opid="na" def _i_serial="na" def _i_inst="na" def _i_host="na" def _i_user="&_user" def _i_conn="&_connect_identifier"  col i_username head username a20 col i_sid head sid a5 new_value mysid col i_serial head serial# a8 new_value _i_serial col i_cpid head cpid a15 new_value _i_cpid col i_spid head spid a15 new_value _i_spid col i_opid head opid a5 new_value _i_opid col i_host_name head host_name a25 new_value _i_host col i_instance_name head inst_name a12 new_value _i_inst col i_ver head version a10 col i_startup_day head started a8 col _i_user noprint new_value _i_user col _i_conn noprint new_value _i_conn col i_myoraver noprint new_value myoraver  select      s.username          i_username,      i.instance_name i_instance_name,      i.host_name         i_host_name,      to_char(s.sid)          i_sid,      to_char(s.serial#)      i_serial,      (select substr(banner, instr(banner, 'release ')+8,10) v$version rownum = 1) i_ver,     (select  substr(substr(banner, instr(banner, 'release ')+8),             1,             instr(substr(banner, instr(banner, 'release ')+8),'.')-1)      v$version       rownum = 1) i_myoraver,     to_char(startup_time, 'yyyymmdd') i_startup_day,      p.spid              i_spid,      trim(to_char(p.pid))        i_opid,      s.process           i_cpid,      s.saddr             saddr,      p.addr              paddr,     lower(s.username) "_i_user",     upper('&_connect_identifier') "_i_conn"      v$session s,      v$instance i,      v$process p      s.paddr = p.addr ,      sid = (select sid v$mystat rownum = 1);  -- windows cmd.exe specific stuff  -- host title %cp% &_i_user@&_i_conn [sid=&mysid ser#=&_i_serial spid=&_i_spid inst=&_i_inst host=&_i_host cpid=&_i_cpid opid=&_i_opid]    host title %cp% &_i_user@&_i_conn [sid=&mysid #=&_i_serial] -- host doskey /exename=sqlplus.exe desc=set lines 80 sqlprompt ""$tdescribe $*$tset lines 299 sqlprompt "sql> "  -- short xterm title -- host echo -ne "\033]0;&_i_user@&_i_inst &mysid[&_i_spid]\007" -- long xterm title --host echo -ne "\033]0;host=&_i_host inst=&_i_inst sid=&mysid ser#=&_i_serial spid=&_i_spid cpid=&_i_cpid opid=&_i_opid\007"   def myopid=&_i_opid def myspid=&_i_spid def mycpid=&_i_cpid  -- undef _i_spid _i_inst _i_host _i_user _i_conn _i_cpid 

sample output:

17:39:35 system@saz-dev> @sandbox connected. 18:29:02 system@sandbox> @me  username             inst_name    host_name                 sid   serial#  version    started  spid            opid  cpid            saddr    paddr -------------------- ------------ ------------------------- ----- -------- ---------- -------- --------------- ----- --------------- -------- -------- system               xe           oars-sandbox              34    175      11.2.0.2.0 20130318 3348            30    6108:7776       6f549590 6ff51020  1 row selected.  elapsed: 00:00:00.04 

Comments