Manage your SQL Plus Window

Update your glogin.sql file to contain the code below to automatically modify your sql plus window to reflect database environment and logged in user.  My glogin.sql file is located in the following directory:

C:\oracle\Ora11gR2x64\product\11.2.0\client_1\sqlplus\admin


set term off
set sqlprompt "_user > "
define sql_prompt= '&_user @ &_connect_identifier'

COLUMN host_cmd_col NEW_VALUE host_cmd

SELECT ( CASE
when upper('&_CONNECT_IDENTIFIER') = 'PROD' THEN 'COLOR F0'
when upper('&_CONNECT_IDENTIFIER') = 'DEV' THEN 'COLOR 1F'
when upper('&_CONNECT_IDENTIFIER') = 'STAGE' THEN 'COLOR 0F'
when upper('&_CONNECT_IDENTIFIER') = 'QA' THEN 'COLOR 4F'
else 'COLOR 0E'
END) host_cmd_col
FROM dual;

HOST &host_cmd
set term on
HOST title &sql_prompt

/* Color attributes are specified by TWO hex digits -- the first corresponds to the
background; the second the foreground. Each digit can be any of the below values.

0 = Black      8 = Gray
1 = Blue       9 = Light Blue
2 = Green      A = Light Green
3 = Aqua       B = Light Aqua
4 = Red        C = Light Red
5 = Purple     D = Light Purple
6 = Yellow     E = Light Yellow
7 = White      F = Bright White
*/

One source I used heavily for writing my own script:  http://steveharville.wordpress.com/2010/01/29/change-sqlplus-color-according-to-database-name/

Advertisements

One response to “Manage your SQL Plus Window

  1. steveharville March 26, 2014 at 3:16 pm

    Hi Chris,
    I’m glad it was helpful to you.
    Steve

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: