SQL*Plus in a Windows Environment

In Blog, Technical Focus by Nymad0 Comments

Did you know that SQL*Plus under Windows is often preferred to its Unix equivalent? There are many ways to configure SQL*Plus to suit your individual needs but today I’ll just cover one option that makes life that little bit easier (at least in my opinion).

Many beginner DBA’s (and some senior ones too!) often overlook the usefulness of a login.sql script.

We all have our favourite editors, I personally still float between Sublime Text and emacs, but the choice is truly down to personal preference. SQL*Plus on Windows defaults to notepad, as do most applications that use a text editor in the Windows environment and we all know how useful that is, but its old and there are much better editors out there these days.

With a few choice commands and a bit of technical know-how you can change the default editor for SQL*Plus to something more DBA/Developer friendly.

Launch SQL*Plus on Windows from either the gui or a command prompt.

C:>sqlplus /nolog

This will launch sqlplus.

Type: ed login

 image of sql command lines

By default This will launch you into notepad.exe and you will be editing a new file named “login.sql”, this file will be located in the directory you launched SQL*Plus from so remember where that was (the easiest way to do this is to create a shortcut to launch SQL*Plus which starts in the same directory every time, but this is something for another article).

Now this is where we define your preferred editor, so in my case, I like Sublime Text, therefore the line for setting my default SQL*Plus editor is as follows:

 image of sql command lines

Save and close your file, then restart SQL*Plus.

Now when you type “ed” within SQL*Plus you will be thrown into your preferred editor.

This is just one of the changes that can be made in the login.sql, there are lots of others in the SQL*Plus reference documentation but this is my favourite change to make when first working on a new Windows environment.

Lee Cullip – Senior Consultant

Leave a Comment