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.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 oncurl -O https://hashjoin.com/kb/oracle/sqlplus-login-sql/login.sql
Gotchas
- Newer SQL*Plus releases (12.2 onward) stopped reading
login.sqlfrom the current directory. PointORACLE_PATH(Unix) orSQLPATH(Windows) at the folder that holds it. set echo onat the end means scripts you run print each statement. Remove it if you prefer quiet output.glogin.sqlin$ORACLE_HOME/sqlplus/adminruns before it for every user of that home;login.sqlis yours.
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.
New fixes and field notes by email, about once a month.