Showing posts with label oracle database. Show all posts
Showing posts with label oracle database. Show all posts

Friday, February 26, 2016

How to Remove/Wipe long running KILLED and INACTIVE session in Oracle Database

SQL>
SQL> select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';

       SID    SERIAL#      USER# USERNAME             SCHEMANAME                        SCHEMA# STATUS   PROCESS                  OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------
        10       4827          0 SYS                  SYS                                     0 INACTIVE 23017                    oracle
       209      33035          0 SYS                  SYS                                     0 ACTIVE   13138                    oracle
       226       5355          0 SYS                  TRACK_OWNER                            78 KILLED   8499                     oracle

SQL> select s.username,s.sid,s.serial#,p.spid,s.lockwait,s.logon_time
from v$session s, v$process p
where s.paddr = p.addr and s.USERNAME='SYS';  2    3

USERNAME                    SID    SERIAL# SPID                     LOCKWAIT         LOGON_TIME
-------------------- ---------- ---------- ------------------------ ---------------- ------------------
SYS                         226       5355 8500                                      24-FEB-16
SYS                          10       4827 23018                                     25-FEB-16
SYS                         209      33035 13139                                     25-FEB-16
  
SQL> !ps -aef|grep 8499
oracle    8499  8213  0 Feb24 ?        00:00:00 sqlplus   as sysdba
oracle    8500  8499  0 Feb24 ?        00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle   14627 13138  0 13:25 pts/8    00:00:00 /bin/ksh -c ps -aef|grep 8499
oracle   14629 14627  0 13:25 pts/8    00:00:00 grep 8499

SQL> !ps -aef|grep 8500
oracle    8500  8499  0 Feb24 ?        00:04:03 oracleTW1D (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle   14631 13138  0 13:25 pts/8    00:00:00 /bin/ksh -c ps -aef|grep 8500
oracle   14633 14631  0 13:25 pts/8    00:00:00 grep 8500
oracle   32079  8500  0 Feb24 ?        00:00:02 /u001/app/oracle/product/11.2.0.4/ctx/bin/ctxhx /tmp/drgibUskeUq /tmp/drgitee7wti ASCII8 utf8 H NOMETA 120 HEURISTIC FORMAT NOPDFROTATE /tmp/drgitmp4I7029 ENCRYPTED

SQL> !kill -9 8500  8499

SQL> !kill -9 32079

SQL> !kill -9 23018 23017

SQL> exit
.
.
.
.
SQL>  select SID, SERIAL#, USER#, USERNAME,SCHEMANAME,SCHEMA#, STATUS,PROCESS,OSUSER from v$session where USERNAME='SYS';

       SID    SERIAL#      USER# USERNAME             SCHEMANAME                        SCHEMA# STATUS   PROCESS                  OSUSER
---------- ---------- ---------- -------------------- ------------------------------ ---------- -------- ------------------------ ------------------------------        
  209      33039          0 SYS                  SYS                                     0 ACTIVE   15044                    oracle

SQL>



So, now as you can see there is no KILLED/INACTIVE Session. Please use below Sql Queries:

1)To Find KILLED/INACTIVE Session Process to kill use PPID & PID Column "kill -9 31105 31103"
col username format a20
col SCHEMANAME format a20
col status format a20
col OSUSER format a20
col PPID format a10
col PID format a10

select s.OSUSER,s.username,s.SCHEMANAME,s.sid,s.serial#,p.spid as PPID,s.process as PID,s.logon_time,s.STATUS
from v$session s, v$process p 
where s.paddr = p.addr and s.USERNAME='SYS';   


OSUSER               USERNAME             SCHEMANAME                  SID    SERIAL# PPID       PID        LOGON_TIME         STATUS
-------------------- -------------------- -------------------- ---------- ---------- ---------- ---------- ------------------ --------------------
oracle               SYS                  SYS                           6      45904 31105      31103      26-FEB-16          ACTIVE

SQL>

2)To Generate oracle statemt to kill session.
select 'alter system kill session '''||SID||','||SERIAL#||''' immediate;' from v$session where username='USER_NAME';



Saturday, September 28, 2013

Learn Oracle PL/SQL Basic Fundamentals within 24Hr.

Oracle PL/SQL More than Basic and Less than Advanced. 

An Introduction to PL/SQL: 
So, what is PL/SQL? It is the procedural (and sometimes object-oriented) programming extension to SQL, provided by Oracle. The PL in PL/SQL stands for procedural language (PL) superset of the Structured Query Language (SQL). PL/SQL is a proprietary language not available outside the Oracle Database. It is a third-generation language (3GL) that provides programming constructs similar to other 3GL languages, including variable declarations, loops, error handling, etc. You can use PL/SQL to do such things as codifying your business rules through the creation of stored procedures and packages, trigger database events to occur and add programming logic to the execution of SQL commands. Structured Query Language (SQL).

The SQL in PL/SQL stands for structured query language. We use SQL to SELECT, INSERT, UPDATE and DELETE data. We use it to create and maintain objects and Schemas to control access rights to our instances. It actually grew out of the work done by Dr. E.F. Codd and IBM in the early 1970s. The American National Standards Institute (ANSI) recognizes SQL and publishes standards for the language.

It's Free Click Here to Download .pdf File




Hope It will be useful for you Guys, Thank You!!!