In Oracle sqlplus, if you type ed or edit at the command prompt, sqlplus will put the last command into an editor buffer for easy editing. In Windows, the default editor is Notepad. In Unix / Linux, the default editor is usually vi. I have changed the default sqlplus editor on my Windows machine to vi. In an earlier post, I explained how to change Microsoft SQL Server 2005 sqlcmd default editor.
I am taking Oracle 10g training this week. The lab is based on Red Hat Linux. I was surprised to learn that the default editor is not setup for sqlplus. When I typed ed, sqlplus would hang.
Here is what I did to fix it:
1. Create a file called login.sql and put it under your home directory
2. Put this line into login.sql file
I also tried creating glogin.sql, as some web site suggested. But for some reason, it didn’t work for me on this Linux machine. I am pretty sure that’s what I did on Windows to make it work.
Update: It appears that if you start sqlplus from a directory other than your home, ed will fail. No big deal but still a bummer. Anybody can enlighten me?
Update1: $ORACLE_HOME/sqlplus/admin is the folder to put glogin.sql on Unix / Linux / Solaris systems. On Windows, the folder to put glogin.sql is c:\oracle\product\10.2.0\DbName\sqlplus\admin. Replace 10.2.0 with your version number. Replace DbName with your database name.
Another thing worth knowing is to set the sql prompt in SqlPlus. You can put this into glogin.sql:
set sqlprompt _user”@”_connect_identifier>
4 responses to “Customize Oracle sqlplus editor”
[…] for easy editing. In Windows, the default editor is Notepad. Archived in Tools | Trackback | del.icio.us | Top OfPage […]
[…] In Oracle sqlplus, if you type ed or edit at the command prompt, sqlplus will put the last command into an editor buffer for easy editing. In Windows, the default editor is Notepad. Read This […]
set an environment variable export EDITOR=/usr/bin/vi, then ed will work from anywhere. works on most flavors of unix/linux