KB · Oracle Database · Script

login.sql: a SQL*Plus prompt that shows user@database

Oracle Database · Script · Verified on Oracle 11.2 and 23ai · Updated 2026-12-03

The cheapest safety measure in Oracle work: a prompt that tells you which user and database you're connected to before you hit Enter. SQL*Plus runs login.sql every time you connect, so these settings follow you.

Usage

Put it in the directory you start sqlplus from, or in a directory listed in SQLPATH.

SCOTT@PROD=> select 1 from dual;
login.sqlMIT · Download ·
-- login.sql: SQL*Plus settings and a user@database prompt
-- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/)
-- https://hashjoin.com/kb/oracle/sqlplus-login-sql/
--
-- Usage: put it in the directory you start sqlplus from, or in SQLPATH

set timing on
set tab off
set time on
SET SERVEROUTPUT ON size unlimited
WHENEVER SQLERROR CONTINUE

set sqlprompt			"_USER'@'_CONNECT_IDENTIFIER=> "
define _editor=vi
set echo on

curl -O https://hashjoin.com/kb/oracle/sqlplus-login-sql/login.sql

Gotchas

Tired of fixing the same thing twice?

HASHJOIN turns the checks and fixes your on-call runs by hand into tooling that gives the same answer every time. Fixed scope, and you own all of the code.