You are in SQL*Plus. You entered a command and urgh, there was a typo. No worries, you bring up the command in an editor by typing:
SQL> ed
This opens up an editor, such as notepad.exe in Windows or vi in Unix, etc. And it puts the last SQL you entered in a file, oddly named, afiedt.buf. You don't like it and you want a name easier to type. Is it possible? Of course.
First a little bit of background information on the odd name. SQL*Plus as a tool evolved from another tool Oracle provided a long, long time ago, called--rather uncreatively--User Friendly Interface, or UFI. When the editor wanted to bring up a file for editing, the file had to be given a name unique enough so as not to conflict with anything else. Therefore the file was named ufiedt.buf, which roughly indicated UFI Editor Buffer.
Later as UFI was added new features, it was called Advanced UFI (well, "advanced" is relative). To keep pace, the generated file was called Advanced UFI Editor Buffer, or aufiedt.buf. However an operating system that Oracle supported couldn't handle a 7 character file name before the period before suffix. Therefore the name was shortened to afiedt.buf to keep it distinct from ufiedt.buf (which presumably was not as "advanced"). As the advancements in technology came, Oracle didn't bother to change it and the name stuck. Long live afiedt.buf!
If ain't broken, don't fix it. Shouldn't that be the case? The name doesn't break anything; so why change it? There are three reasons to at least consider.
It's ridiculously simple to change the file. A setting in SQL*Plus controls it.
SQL> set editfile arup.sql
After this when you type the editor command:
SQL> ed
Wrote file arup.sql
Look how the file created was named "arup.sql"; not afiedt.buf. Of course you can use any name as you find appropriate.
Let's handle the second problem. You are in a directory where you don't have write permission and you want to edit the command. Well, you can use a full path to the file as well.
SQL> set editfile c:\temp\arup.sql
SQL> ed
Wrote file c:\temp\arup.sql
The file is created in the C:\temp directory instead of the default option of the current directory.
While on the subject, do you know that you can change the default editor as well? For instance, if you are on Windows, you don't have to have Notepad as the editor for SQL scripts. It can be notepad++, or, as I prefer, "vim", which is enhanced vi. In Unix, the default is not vi; it's "ed" and you may want to change it. How to do that?
Very simple; another setting _EDITOR allows us to do that. It's a variable; so you have to use DEFINE command. Use the following:
SQL> define _editor = vi
That's it; now when you enter "ed" command, it will bring up vi editor. Change to whatever you want to set.
If you want to change the default editor and the default file for editing, put the commands in the glogin.sql file, which ensures their automatic execution when someone invokes SQL*Plus.
Afiedt.Buf is dead. Long live Afedit.Buf. Or, was it Afiedt.Buf? Oh, who cares?
Recent comments
12 weeks 6 days ago
25 weeks 9 hours ago
29 weeks 2 days ago
30 weeks 1 day ago
34 weeks 5 days ago
1 year 3 weeks ago
1 year 24 weeks ago
2 years 1 week ago
2 years 38 weeks ago
2 years 38 weeks ago