Every SQLcl and SQL*Plus session starts with default settings: page size, output format, date format, server output off. A file named login.sql changes that. The tool runs it automatically after every connection, so your preferred settings are always in place.
Code for This Guide
The main examples are in the examples/tools folder of the Oracle Database 26ai code repository on GitHub, each with its output. They use NIMBUS, the sample schema of a fictional airline, which you can install with the scripts in the setup/nimbus folder.
They come from Oracle Database 26ai SQL and PL/SQL Book.
Where It Is Found
SQLcl and SQL*Plus look for login.sql in the current folder and in the folders listed in the SQLPATH environment variable. SQL*Plus also runs glogin.sql from its installation first, for settings shared by all users of that installation.
Example:
export SQLPATH=$HOME/sql # macOS and Linux set SQLPATH=C:\sql # Windows
A Practical login.sql
This is the login.sql that the examples in these guides run with, from the setup folder of the repository:
Example:
set sqlformat ansiconsole set pagesize 500 serveroutput on size unlimited set sqlblanklines on define off verify off tab off set long 100000 longchunksize 100000 alter session set nls_date_format = 'DD-MON-YYYY'; alter session set nls_timestamp_format = 'DD-MON-YYYY HH24:MI:SS'; alter session set nls_timestamp_tz_format = 'DD-MON-YYYY HH24:MI:SS TZR'; alter session set time_zone = 'UTC';
- ANSICONSOLE output, a large page size, and DBMS_OUTPUT on, without a size limit.
- Blank lines allowed inside statements, substitution off so & in text is safe, and long CLOBs shown in full.
- Fixed date and time formats and a UTC session time zone, so output looks the same on every computer.
Check That It Ran
Example:
-- settings that login.sql made at connection show sqlformat show define select sessiontimezone as session_time_zone, date '2026-03-15' as a_date from dual;
Output:
SQL Format : ansiconsole define OFF SESSION_TIME_ZONE A_DATE ____________________ ______________ UTC 15-MAR-2026
The session shows the ANSICONSOLE format, substitution off, the UTC time zone, and dates in DD-MON-YYYY, all from login.sql.
Things to Know
- login.sql runs after every CONNECT, not only at startup, so settings survive a reconnect.
- Keep it to settings; anything slow in it delays every connection.
- Use separate folders with their own login.sql for different projects, and start the tool from the right one.
Related Guides
Conclusion
login.sql holds your SQLcl and SQL*Plus settings and runs after every connection, from the current folder or SQLPATH. Put output formats, NLS settings, and server output in it, so every session starts the way you work.
