View the number of connections to the Oracle database and the user

Source: Internet
Author: User

1. Query the number of connections to Oracle
Select COUNT (*) from v$session;
2. Querying the number of concurrent connections for Oracle
Select COUNT (*) from v$session where status= ' ACTIVE ';
3. View the number of connections for different users
Select Username,count (username) from V$session where username are not null GROUP by username;
4. View all Users:
SELECT * from All_users;
5. View user or role system permissions (System permissions that are directly assigned to a user or role):
SELECT * from Dba_sys_privs;
SELECT * from User_sys_privs;
6. View the roles (only the roles owned by the logged-in user) that contain the permissions
SELECT * from Role_sys_privs;
7. View User Object permissions:
SELECT * from Dba_tab_privs;
SELECT * from All_tab_privs;
SELECT * from User_tab_privs;
8. View all roles:
SELECT * from Dba_roles;
9. View the roles owned by the user or role:
SELECT * from Dba_role_privs;
SELECT * from User_role_privs;
10. See which users have SYSDBA or Sysoper system permissions (requires appropriate permissions when querying)
SELECT * from V$pwfile_users;

Select COUNT (*) from v$process--current number of connections

Select value from v$parameter where name = ' processes '--the maximum number of connections allowed for the database

To modify the maximum number of connections:
alter system SET processes = + scope = SPFile;

To restart the database:
Shutdown immediate;
Startup

--See which users are currently using the data
SELECT Osuser, a.username,cpu_time/executions/1000000| | ' S ', Sql_fulltext,machine
From V$session A, V$sqlarea b
where a.sql_address =b.address order by cpu_time/executions Desc;
Select COUNT (*) from V$session #连接数


Select COUNT (*) from v$session where status= ' ACTIVE ' #并发连接数

Show parameter Processes #最大连接

alter system SET processes = value scope = spfile; Restart database #修改连接

Sql> Select Count (*) from v$session where status= ' ACTIVE ';

COUNT (*)
----------
20

Sql> Select Count (*) from v$session;

COUNT (*)
----------
187

Sql> Show parameter processes;

NAME TYPE VALUE
------------------------------------ ----------- ----------
Aq_tm_processes integer 0
Db_writer_processes Integer 1
Gcs_server_processes integer 0
Job_queue_processes Integer 10
Log_archive_max_processes Integer 2
Processes integer 450
Sql>

Concurrency refers to active,i see

Sql> Select COUNT (*) from V$session #连接数
Sql> Select Count (*) from v$session where status= ' ACTIVE ' #并发连接数
Sql> Show parameter Processes #最大连接
Sql> alter system SET processes = value scope = spfile; Restart database #修改连接

Unix 1 user session corresponds to an operating system process
While Windows embodies the thread

The DBA will periodically check the connection of the database to see if the number of sessions established with the database is normal, and if too many connections are established, the resources of the database are consumed. At the same time, some "dead" connections may require the DBA to manually clean up.
The following SQL statement lists the session conditions established by the current database:
Select Sid,serial#,username,program,machine,status
From V$session;
The output is:
SID serial# USERNAME Program Machine STATUS
---- ------- ---------- ----------- --------------- --------
1 1 ORACLE. EXE WORK3 ACTIVE
2 1 ORACLE. EXE WORK3 ACTIVE
3 1 ORACLE. EXE WORK3 ACTIVE
4 1 ORACLE. EXE WORK3 ACTIVE
5 3 ORACLE. EXE WORK3 ACTIVE
6 1 ORACLE. EXE WORK3 ACTIVE
7 1 ORACLE. EXE WORK3 ACTIVE
8 SYS SQLPLUS. EXE Workgroup\\work3 ACTIVE
5 Dbsnmp Dbsnmp.exe Workgroup\\work3 INACTIVE
which
The ID number of the SID session;
The serial number of the serial# session, together with the SID, is used to uniquely identify a session;
USERNAME the user name of the session to be established;
Program This session is using what tools to connect to the database;
Status current state of this session, active indicates that the session is performing certain tasks, inactive indicates that the current session does not perform any action;
If the DBA is going to manually disconnect a session, execute:
Alter system kill session \ ' Sid,serial#\ '

The SQL statement SQL statement is as follows:

SELECT username, machine, program, status, COUNT (machine) as
Number of connections
From V$session
GROUP by username, machine, program, status
ORDER by Machine;

Show results (different on everyone's machine)

schneider| Workgroud\wangzheng| toad.exe| Active|1
schneider| workgroup\597728aa514f49d|sqlplusw.exe| Inactive|1
| www-q6zmr2oiu9v| ORACLE. exe| Active|8
public| | | Inactive|0 Query by host name Select COUNT (*) from v$session WHERE machine = ' DXMH '; ' DXMH ' for Host name Data Recovery statement CREATE TABLE Informationlaw_bak
As
SELECT * from Informationlaw as of TIMESTAMP to_timestamp (' 20121126 103435 ', ' yyyymmdd Hh24miss '); Search by machine name Select Username,machine,count (username) from V$session where username are not null GROUP by Username,machine;

View the number of connections to the Oracle database and the user

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.