<$BlogRSDUrl$>

Thursday, April 08, 2004

10g sqlplus.

Connor McDonald points out on his pages that there is no longer a requirement to enclose connection strings in quotes when starting sqlplus from the command line.

In addition an enhancement to 10g now ensures that login.sql and glogin.sql are read whenever sqlplus issues a connect as well as at startup. This means that it is now feasible to set the sql prompt to something meaningful and not have it mislead you if you change the db you are connected to (from dev to prod for example).

This is almost certainly what they had in mind as there are some useful predefined variables now for exactly this purpose.

_DATE contains the current date (dynamic) by default or else a fixed string
_PRIVILEGE contains the sysdba or sysoper priv if specified at connect
_USER contains the current username
_CONNECT_IDENTIFER contains the connection identifer used to connect

so my login.sql which reads

SET FEED OFF
ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
SET FEED ON
set sqlprompt "_USER' '_DATE '@'_CONNECT_IDENTIFIER>"

Gives me a sqlprompt of the form
<username> 08-APR-2004 13:55@<dbname>>

which is nice for those which database am I on moments.

0 Comments
0 Comments: Post a Comment