René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback
 

Storing settings for SQL*PLUS (login.sql and glogin.sql)

glogin.sql

Whenever SQL*PLUS starts up, it looks for a file named glogin.sql under the directory $ORACLE_HOME/sqlplus/admin. If such a file is found, it is read and the containing statements executed. This allows to store settings (such as linesize) accross SQL*PLUS sessions.
New in Oracle 10g: Oracle also reads glogin.sql and login.sql at a connect in sql*plus.

login.sql

Additionally, after reading glogin.sql, sql*plus also looks for a file named login.sql in the directory from where SQL*PLUS was and in the directory that the environment variable SQLPATH points to and reads it and executes it. Settings from the login.sql take precedence over settings from glogin.sql
If the restriction level is set to 3, the login.sql is not read.

A common login.sql file

set pagesize 0
set linesize 190
define _editor=gvim

10g

Since Oracle 10g, the login.sql is executed after a connect
This allows to have a prompt that displays the username. For that, the following line must be in the login.sql:
set sqlprompt "&_user> "

Related links

See also the set store command.