U of A University of Arkansas Division of Agriculture

Pictures of chickens, flowers, wheat, a boy looking through a magnifying glass, irrigation pipe, soybean pods, and fruits and vegetables.

Cooperative Extension Service

Cooperative Extension Service

Agricultural Experiment Station

Steve Rea's
Oracle Tips, Tricks, and Scripts

Link to Steve Rea's Oracle Certification graphic


Search | Publications | Jobs | Personnel Directory | Links

User ID/Database Name Prompt in SQL*Plus

When working with multiple database instances and logging on with several user ID's, it is very easy to get confused as to who and what is active in each of those SQL*Plus sessions that you have going at the current time.  To change the SQL prompt to show the user ID and database (instance) name, just put the following at the end of the $ORACLE_HOME/sqlplus/admin/glogin.sql file (by Dave Hill and Julie Dunnam; note that the prompt is only set at startup, and is not changed if you connect to another user ID during the SQL*Plus session):

set termout off
define new_prompt='nolog'
column new_prompt new_value new_prompt
select username || ': ' || substr(global_name,1,instr(global_name || '.','.')-1)
     new_prompt from user_users, global_name;
set sqlprompt "&new_prompt> "
set termout on

On Oracle8, some of our users were getting a buffer overflow on the above code, so, you might want to try the following instead:

set termout off
define new_prompt='nolog'
column new_prompt new_value new_prompt
select username || ': ' || substr(substr(global_name,1,30),1,
     instr(substr(global_name || '.',1,30),'.')-1) new_prompt from user_users, global_name;
set sqlprompt "&new_prompt> "
set termout on

Be aware that the prompt is only set at the startup of sqlplus, so, if you connect to another user ID, the prompt will still show the original login user ID.

This Page was Last Updated on 06/04/07

You Are Visitor Number

Hit Counter

Link to CES Home PageBack To CES Home Page

Link to Steve Rea's Oracle PageBack To Steve Rea's Oracle Page

Back to top of this pageBack To Top


© 2006
University of Arkansas
Division of Agriculture
All rights reserved.
Last Date Modified 02/09/2008
Webmaster

University of Arkansas • Division of Agriculture
Cooperative Extension Service
2301 South University Avenue
Little Rock, Arkansas 72204 • USA
Phone (501) 671-2000 • Fax (501) 671-2209
 

MissionDisclaimerEEO
PrivacyFOI