Presentation on theme: "Database Administration Sessions. Identify the running Sessions The sessions can be identified using following objects. V$SESSION GV$SESSION Following."— Presentation transcript:
Identify the running Sessions The sessions can be identified using following objects. V$SESSION GV$SESSION Following queries can be used to identify sessions. Select * from v$session Select * from GV$session SELECT s.inst_id, s.sid, s.serial#, p.spid, s.username, s.program FROM gv$session s JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id WHERE s.type != 'BACKGROUND';
Killing the session The basic syntax for killing a session is shown below. SQL> ALTER SYSTEM KILL SESSION 'sid,serial#'; Or SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE; it returns control back to the current session immediately, rather than waiting for confirmation of the kill.
OS approach The Windows Approach To kill the session on the Windows operating system, first identify the session, then substitute the relevant SID and SPID values into the following command issued from the command line. C:> orakill ORACLE_SID spid The UNIX Approach To kill the session on UNIX or Linux operating systems, first identify the session, then substitute the relevant SPID into the following command. % kill spid If after a few minutes the process hasn't stopped, terminate the session using the following. % kill -9 spid If in doubt check that the SPID matches the UNIX PROCESSID shown using. % ps -ef | grep ora The session thread should be killed immediately and all resources released.
Extending the System session limit First check the session limit in oracle instance. show parameter sessions Alter the new session limit. alter system set sessions=180 scope=spfile; Shutdown and then startup. show parameter sessions
Sessions Management using Profiles show parameter resource_limit Alter resource limit. alter system set RESOURCE_LIMIT=true scope=both; Creating a new profile with session limit. create profile sesslimit limit sessions_per_user 2; Create user and assign new profile. create user fish identified by fish123 default tablespace data profile sesslimit; grant create session to fish; connect fish/fish123
Oracle Session views v$sessmetric This view is new in Oracle 10g and allows improved timing and statistics. v$session_event This views is similar to v$system_event. However, it breaks it down to currently connected sessions. V$session_event has also the column max_wait that shows the maximum time waited for a wait event. v$session_longops Use v$session_longops if you have a long running pl/sql procedure and want to give feedback on how far the procedure proceeded. If the following Procedure is run, it will report its progress in v$session_longops. The Procedure will also set the module attribute in v$session which makes it possible to find the sid and serial# of the session.
v$session_wait This views shows what wait event each session is waiting for, or what the last event was that it waited for. In contrast, v$session_event lists the cumulative history of events waited for in a session. The columns P1, P2 and P3 are parameters that are dependant on the event. With Oracle 10g, v$session_wait's information will be exposed within v$session as well.Since 10g, Oracle displays the v$session_wait information also in the v$session view. v$session_wait_history This view is new in Oracle 10g and allows improved timing and statistics. v$sesstat This view is similar to v$mystat except that it shows cumulated statistics for all sessions. Join sid with v$session and join statistic# with v$statname. v$sesstat is also similar to v$sysstat, except that v$sysstat accumulates the statistics as soon as a session terminates.
Your consent to our cookies if you continue to use this website.