Home > Database > Oracle > How to delete session in oracle

How to delete session in oracle

WBOY
Release: 2022-05-24 15:46:59
Original
4842 people have browsed it

Method to delete session: 1. Use the "v$session" view to view the sid and "serial#" of the session; 2. Use the alter statement to delete the session. The syntax is "alter system kill session 'sid , serial#'".

How to delete session in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to delete session in oracle

View the sid and serial of the session through v$session view

#
--这里的sid,serial根据查询的结果修改为对应的值
alter system kill session 'sid, serial#'
Copy after login

The example is as follows:

1. Query the current session

SQL> select username,sid,serial# from v$session where username is not null;
USERNAME SID SERIAL#
Copy after login

SYS 144 4

HYL 146 48

SCOTT 147 64

HR 159 15

--SERIAL#: SID may be repeated. When the SID of two sessions is repeated, SERIAL# is used to distinguish the session.

Query the connected session

select sid,serial#,username,program,machine,status from v$session
Copy after login

The query results are as follows , you can locate it according to the machine and logged-in account:

How to delete session in oracle

2. Delete the current session

SQL> alter system kill session '146,48';
System altered.
Copy after login

Hyl's session and perform the following operations:

SQL> show user
USER is "HYL"
SQL> select * from test1;
select * from test1
*
ERROR at line 1:
ORA-00028: your session has been killed
Copy after login

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to delete session in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template