The Working Directory

Whenever you work with files in SQL*Plus, it’s important to understand the concept of a working directory. The working directory is simply the directory that is used whenever you specify a filename without also including a path. The working directory is also where SQL*Plus writes temporary files, such as the AFIEDT.BUF file created when you invoke the EDIT command.

If you work under an operating system like Unix, you are already familiar with the concept of a current working directory. You also very likely know how to move between directories, and are familiar with commands such as pwd that tell you what your current directory is. The working directory simply happens to be whatever directory you are in when you invoke SQL*Plus.

Users of the Microsoft Windows operating system tend to be a bit insulated from the concept of a current directory. SQL*Plus is typically invoked under Windows by clicking an icon, and the user often does not think of himself as being “in” any particular directory when this is done. In spite of this, some directory will be current when you run SQL*Plus under Windows. Take a look at Figure 2.8. It shows the properties for the SQL*Plus menu item under Windows 95.

The SQL*Plus shortcut properties under Windows 95

Figure 2-8. The SQL*Plus shortcut properties under Windows 95

Notice the Start in setting shown in Figure 2.8. It’s set to the C:ORAWIN95BIN directory, the same directory in which the executable sits. This is the default setting used when installing Oracle on any version of Windows. The implication is that whenever you run SQL*Plus under Windows and use the SAVE command without specifying a path for the file, the file will be created in the Oracle BIN directory. The same is true when you use the SPOOL command to send report output to a file. If you don’t specify a path, the report output will go to the BIN directory. Also, when you use the EDIT command, the AFIEDT.BUF temporary file will be created in this directory.

It’s best, if you are using SQL*Plus under Windows, always to specify a path when you save a query, or report output, to a file. If you save a file, and later can’t seem to find it, the Oracle BIN directory is the first place you should look.

You can change the default directory if you like. One way would be to edit the shortcut properties and change the Start in setting to some other directory. This would be a permanent change, and is probably more trouble than it is worth. Another, more useful, technique is to use the File Open dialog to navigate to the directory you want to be current, and then press the Cancel button. Figure 2.9 shows this dialog in preparation for making the C:JONATHANSQL_SCRIPTS directory the current working directory.

The SQL*Plus file open dialog

Figure 2-9. The SQL*Plus file open dialog

Once you navigate to the directory you want as the current directory, you just press the Cancel button. It’s not necessary to actually open a file. This use of the file open dialog is undocumented, but it’s a very handy technique for quickly changing your working directory under Windows.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset