Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In SQL*Plus, how do I change the prompt to show the connected user and database?

Tags:

oracle

sqlplus

To show, for example....

USER@SID > 

I thought this was potentially helpful to a few people so I'm going to answer it too!

like image 205
cagcowboy Avatar asked Nov 20 '08 00:11

cagcowboy


People also ask

How do you login as the system administrator on the Oracle SQL*Plus interface?

Click Start > Programs > Oracle-OraHomeName > Application Development > SQL Plus. The SQL*Plus Windows GUI opens and the Log On dialog is displayed. Enter your Oracle Database username and password in the Log On dialog. If you do not know your Oracle Database username and password, ask your Database Administrator.


1 Answers

Amend your $ORACLE_HOME\sqlplus\admin\glogin.sql script - add:

set sqlprompt "_user '@' _connect_identifier > "

to the end of the file.

In Oracle 10g this will change correctly each time you issue a "conn". For clients before 10g it won't change when you do a "conn" but will remain as the username/db you first connected to.

You can also use _date for the current date and _privilege for the privilege (eg SYSDBA) of the connected user.

Reference:

http://www.acs.ilstu.edu/docs/Oracle/server.101/b12170/whatsnew.htm

like image 101
cagcowboy Avatar answered Oct 14 '22 09:10

cagcowboy