The Working Directory

Whenever you work with files in SQL*Plus, you must 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 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 will be familiar with the concept of a current working directory. You will likely need to know how to move between directories, and will be 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 often 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. Nonetheless, some directory will be current when you run SQL*Plus under Windows. Take a look at Figure 2-9. It shows the properties for the SQL*Plus menu item under Windows XP.

Figure 2-9. The SQL*Plus shortcut properties under Windows XP


Notice the Start in setting shown in Figure 2-9. It's set to the c:oracleproduct10.1.1.0Db_1BIN directory, the same directory in which the executable sits. The implication is that whenever you run SQL*Plus under Windows and use the @ command to execute a file, and you don't specify a path, SQL*Plus will look in Oracle's BIN directory. Likewise, the SAVE and GET commands will write and read from the BIN directory, at least by default. And when you use the EDIT command, the temporary file afiedt.buf will be created in the BIN directory.

It's best, if you are using SQL*Plus under Windows, to specify a path when you save a query 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. Sometimes, I'll create a second copy of the SQL*Plus shortcut, for a specific project, pointing the Start in directory to my project directory. Then I can easily start the Windows GUI version of SQL*Plus and begin editing or executing my scripts.


Introduction to SQL*Plus

Command-Line SQL*Plus

Browser-Based SQL*Plus

A Lightning SQL Tutorial

Generating Reports with SQL*Plus

Creating HTML Reports

Advanced Reports

Writing SQL*Plus Scripts

Extracting and Loading Data

Exploring Your Database

Advanced Scripting

Tuning and Timing

The Product User Profile

Customizing Your SQL*Plus Environment

Appendix A. SQL*Plus Command Reference

Appendix B. SQL*Plus Format Elements

Oracle SQL Plus The Definitive Guide, 2nd Edition
Oracle SQL*Plus: The Definitive Guide (Definitive Guides)
ISBN: 0596007469
EAN: 2147483647
Year: N/A
Pages: 151 © 2008-2020.
If you may any questions please contact us: