SQL to monitor sessions in an Oracle database

Here is a SQL script that you can use to monitor Oracle database sessions:

-- Query to monitor Oracle database sessions SELECT s.sid, s.serial#, s.username, s.status, s.machine, s.program, s.osuser, s.process, s.logon_time FROM v$session s WHERE s.type = 'USER' ORDER BY s.logon_time ASC;

This script queries the v$session view, which contains information about all the sessions currently connected to the database. The WHERE clause filters the rows to show only user sessions, and the ORDER BY clause sorts the results by logon time in ascending order.

The columns in the v$session view include:

  • sid: the session ID of the session
  • serial#: the serial number of the session
  • username: the username of the user connected to the session
  • status: the status of the session (e.g. ACTIVE, INACTIVE)
  • machine: the name of the machine from which the session is connected
  • program: the name of the program connected to the session
  • osuser: the operating system user associated with the session
  • process: the process ID of the session
  • logon_time: the time at which the session was established

You can modify this script to include other columns from the v$session view, or add additional filters to the WHERE clause to narrow down the results.

Comments

Popular posts from this blog

Auditing user logon and logoff in Oracle

RMAN Restore vs. Recovery - what's the difference?

Use rsync on Unix to backup your archive logs