HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Do I have to retype information every time I make a mistake in SQLPlus

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
retypemakeeverytimemistakesqlplushaveinformation

Problem

If I make a mistake in SQLPlus while inputting an 'insert into' command, is there a way I can bring this information back up in order to edit it?

Solution

Several ways.

You can set the EDITOR environment variable before running SQL*Plus (Assuming Unix), to allow use of an external text editor (vi, by way of example):

export EDITOR=vi


Then type ed in SQL*Plus to edit the previous query in the vi editor. Of course, you may prefer nano, pico, emacs, vim etc etc.

If you don't wish to set an environment variable, you can add define _editor=vi to your $ORACLE_HOME/sqlplus/admin/glogin.sql file instead.

My favourite way of achieving SQLPlus edit heaven (in Unix) is by using rlwrap. This adds readline support to SQLPlus and allows you to easily edit within SQL*Plus itself.

Install rlwrap from your distributions package repository (or download & compile from the website here), then add the following to your shells startup script (.bashrc/.bash_profile or similar):

alias sqlplus="rlwrap -i sqlplus"

Code Snippets

export EDITOR=vi
alias sqlplus="rlwrap -i sqlplus"

Context

StackExchange Database Administrators Q#30101, answer score: 15

Revisions (0)

No revisions yet.