Setup login.sql in sqlplus windows envrionment

it would be tiresome to enter environment variables each time you login to sqlplus, good thing is sqlplus allows us to use a script (login.sql) which has the environment variables defined each time we login (user profile)  https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_two.htm#i1133044 .  Once you define the sqlpath sqlplus looks for login.sql in the path directory and executes it once you login successful. This can be also configured at global level called site profile it allows the DBA to set default env for all the users. so when a user connects through sqlplus first the global site profile (glogin.sql) is executed and then the user profile (login.sql) is executed which is defined in SQLPATH environment variable in Windows

 

sqlpath

 

here %USERPROFILE% is an environment variable has default location of the user who is logged into the machine  C:\USERS\Username

we have to make sure we have login.sql available in that location

 

sql plus login sql

 

you can see below sqlprompt has changed to what we defined in login.sql  (‘&_user.@&_connect_identifier.>’)

sqlprompt sqlplus

 

 

Advertisements

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