Home > Oracle Tips > Oracle Database Administrator > See who is logged into the database
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ORACLE DATABASE ADMINISTRATOR

See who is logged into the database


Patricia Ashe
06.19.2006
Rating: -3.60- (out of 5)


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


This is a script that was passed down to me about eight years ago from another DBA and I have passed it on to others. I use it all the time to see who is logged into the database. I use it when I have to kill an OS process for a user connected to the database or just to see who is on.

To run, I log on to the database server and set my Oracle environment for the database I want to check using coraenv or oraenv. Then, I just type "on_ora_sid". This script runs a SQL script called "session.sql" and will query the Oracle V$Session tables and return the userid of people logged into the Oracle database identified SID.

on_ora_sid:

#!/bin/csh -f
# This program will query the Oracle V$Session tables and return
# the userid of people logged in to the Oracle Database identified
# oracle_sid
#
echo ""
#
echo ""
setenv ORACLE_SID $ORACLE_SID
echo "Users logged in to" $ORACLE_SID
sleep 3
sqlplus system/password @/ora01/scripts/dba_scripts/session.sql
echo ""

session.sql:

column username heading user format a10
column program heading running format a40
column status heading status format a9
column spid heading proc format a5
column lockwait heading lockwait format a8 
select sys.v_$session.username, 
sys.v_$session.program,
sys.v_$session.status, 
sys.v_$session.lockwait,
sys.v_$process.spid 
from sys.v_$session, sys.v_$process
where sys.v_$session.paddr = sys.v_$process.addr 
and sys.v_$session.username is not null;
exit

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Oracle Database Administrator
What is the difference between a database engineer, architect and administrator?
Import on one table from dump file
Error during RMAN backup
Can I drop a column in SYS schema?
STATSPACK tool: transaction vs. execution measurement
Should I port from Microsoft Access?
Installing multiple Oracle homes
How can I find statistics on total memory usage and database connections?
Modifying SYS password in a RAC environment
How to create Datafiles in a Data Guard (10g) environment

Oracle SQL
SQL to count values of a status code
Counting NULL columns
Detail rows for accounts that occur three times
Counting a row's NULL columns
Oracle's free SQL Developer adds database migration tool
Latest transaction if no recent prior transactions
Three ways SQL can count rows by type
SQL to select only certain times within a date range
Oracle SQL to test for numerics
Number of rows in multiple tables
Oracle SQL Research

Oracle tutorials, tips and FAQs
How to create a database link in Oracle
Most clicked stories of 2007
How do I do that in Oracle?
Counting a row's NULL columns
How many redo log files?
How to start multiple instances in Oracle 10g
Is it possible to assign a role to a profile?
Difference between RECYCLEBIN and 'DROPPED' column
How to find transactions being committed to Oracle database
How to create a database schema in Oracle?
Oracle tutorials, tips and FAQs Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
autonomous transaction  (SearchOracle.com)
CFML  (SearchOracle.com)
dynamic SQL  (SearchOracle.com)
foreign key  (SearchOracle.com)
Java Database Connectivity  (SearchOracle.com)
Open Database Connectivity  (SearchOracle.com)
Oracle  (SearchOracle.com)
stored procedure  (SearchOracle.com)
The Open Group  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts