Process | data | database
Many times, because exceptions or program errors can cause individual processes to consume a large amount of system resources, you need to end these processes, and you can typically use the following command to kill a process:
Alter system kill session ' sid,serial# ';
However, this command frees up resources very slowly, specifically for reference: the study of Kill session in Oracle.
To release resources more quickly, we usually use the following procedure to kill the process:
1. First in the operating system level kill process
2. Kill session inside the database
This typically allows you to quickly abort a process and free up resources.
Today, there is a case where the other friends kill session in the database, but still have no effect for a long time:
[Oracle@danaly ~]$ Sqlplus "/As SYSDBA"
Sql*plus:release 10.2.0.1.0-production on Thu Oct 27 11:09:50 2005
Copyright (c) 1982, +, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-production
With the partitioning, Oracle Label security, OLAP and Data Mining scoring Engine options
Sql> select Sid,username,status from V$session;
SID USERNAME STATUS
---------- ------------------------------ --------
....
154 SCOTT killed
...
Rows selected.
So follow the steps I mentioned earlier, first query for the OS process number that corresponds to the session:
sql> select ' Kill-9 ' | | The SPID from v$process where addr = (select Paddr from v$session where Sid=&sid);
Enter value for sid:154
Old 1:select ' kill-9 ' | | SPID from v$process where addr = (select Paddr from v$session where Sid=&sid)
New 1:select ' kill-9 ' | | SPID from v$process where addr = (select Paddr from v$session where sid=154)
' KILL-9 ' | | SPID
--------------------
Kill-9 22702
Sql>!
Kill the process at the operating system level:
[Oracle@danaly ~]$ Ps-ef|grep 22702
Oracle 22702 1 0 Oct25? 00:00:02 Oracledanaly (Local=no)
Oracle 12082 12063 0 11:12 pts/1 00:00:00 grep 22702
[Oracle@danaly ~]$ kill-9 22702
[Oracle@danaly ~]$ Ps-ef|grep 22702
Oracle 12088 12063 0 11:12 pts/1 00:00:00 grep 22702
[Oracle@danaly ~]$ exit
Exit
Sql> select Sid,username,status from V$session;
SID USERNAME STATUS
---------- ------------------------------ --------
...
154 SCOTT killed
...
Rows selected.
Sql> Select Sid,serial#,username from v$session where sid=154;
SID serial# USERNAME
---------- ---------- ------------------------------
154 56090 SCOTT
Kill the session again in the database and specify the immediate option:
Sql> alter system kill session ' 154,56090 ' immediate;
System altered.
Sql> Select Sid,serial#,username from v$session where sid=154;
No rows selected