Home >Database >Oracle >How to query the number of sessions in oracle

How to query the number of sessions in oracle

WBOY
WBOYOriginal
2022-05-25 10:10:449021browse

In Oracle, you can use the select statement with "v$session" to query the number of sessions in the database. The "v$session" view contains every session record in the database instance, and the syntax is "select count (*) from v$session;".

How to query the number of sessions in oracle

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

How to query the number of sessions in oracle

The syntax for viewing the number of connections for the current session of the system is as follows:

select count(*) from v$session;

How to query the number of sessions in oracle

View Number of active sessions on the current oracle node:

How to query the number of sessions in oracle

How to query the number of sessions in oracle

Modify the maximum number of sessions in the database:

alter system set processes=500 scope=spfile  (在命令模式下执行)

View the maximum session limit of the current database:

show parameters processes;

View the maximum number of connections that can be opened by DBLINK in the current database:

show parameters open_links;

Extended knowledge:

Session ( Session) is a context (Context) between the communicating parties from the beginning of communication to the end of communication. This context is a piece of memory located on the server side: it records the client machine connected this time, which application is used, which user logged in and other information.

We can view the current database through the oracle view v$session All session information, among which this view has a column status indicating the session status, the official Oracle document defines this column as follows

STATUS
VARCHAR2(8)
Status of the session:
ACTIVE - Session currently executing SQL
INACTIVE
KILLED - Session marked to be killed
CACHED - Session temporarily cached for use by Oracle*XA
SNIPED - Session inactive, waiting on the client

What we encounter are ACTIVE, INACTIVE, and KILLED

1. The active session is in the active state, and the current session is executing the sql statement.

2. The inactive session is in the inactive state, and the sql statement has been executed. However, for some reason, the session and background process are not released. By When we exit in sqlplus and log out or exit directly from similar plsql developer tools, we close the session directly instead of putting the session in the inactive state. The following takes the sqlplus command as an example

[oracle@oracle11g ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu May 23 23:09:30 2013
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count(*) from v$process;
COUNT(*)
----------
30
SQL>

Recommended tutorial: "OracleVideoTutorial

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

Statement:
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