SQL Extensions   «Prev 

Lesson 5 SQL*Plus File Location
Objective Describe the file location of a saved file in SQL*Plus.

Where SQL*Plus Saves Your Files

When you use commands like SAVE, START, @, or EDIT in SQL*Plus, you are working with files on the operating system. To use these features effectively, you must understand where SQL*Plus saves and loads those files. This lesson explains how SQL*Plus determines the default directory for script files and how you can confirm or change that location.

Default File Location in SQL*Plus

By default, SQL*Plus saves and loads files in the current working directory of your SQL*Plus session unless you specify a full or relative path in your command.

Any scripts you save or run without specifying a path will be stored in, or loaded from, this current directory.

Finding the Current Directory with HOST

You can always check where SQL*Plus is reading and writing files by using the HOST command to run operating system commands from inside SQL*Plus.

On Windows

To see the list of files in the current directory, use:


SQL> HOST DIR

This opens a directory listing from the folder where SQL*Plus is currently working. Any scripts you save without a path (for example, SAVE report1) will appear in this directory as .sql files.

On Linux/UNIX

To find the current working directory, use:


SQL> HOST PWD

You can also list files with:


SQL> HOST ls

The directory reported by PWD is where SQL*Plus will save and look for files when you do not specify a path.

How SQL*Plus Uses the Current Directory

When you work with files, SQL*Plus combines its file commands with the current directory as follows:

If SQL*Plus cannot find the file in the current directory, it will return a “file not found” error. In that case, either change to the correct directory before starting SQL*Plus, or include an explicit path in your command.

Specifying a Different Directory

You are not limited to the default location. You can specify a full or relative path in your file commands to work with scripts stored elsewhere.

For example:


SQL> SAVE C:\oracle\scripts\monthly_sales REPLACE
SQL> @C:\oracle\scripts\monthly_sales

On Linux/UNIX:


SQL> SAVE /u01/app/oracle/scripts/monthly_sales REPLACE
SQL> @/u01/app/oracle/scripts/monthly_sales

In these examples, SQL*Plus reads and writes directly to the specified directory instead of the default working directory.

Practical Workflow Summary

To reliably understand and control where your SQL*Plus files are saved:

  1. Start SQL*Plus from a known directory whenever possible (for example, a dedicated scripts folder).
  2. Confirm the current directory using HOST DIR (Windows) or HOST PWD / HOST ls (Linux/UNIX).
  3. Save scripts with SAVE, knowing they will be written to the current directory if no path is specified.
  4. Run scripts with START or @, understanding that SQL*Plus searches the current directory when you do not supply a path.
  5. Use full or relative paths when your scripts are organized in specific folders outside the default directory.

By keeping track of the current directory and using explicit paths when needed, you can always describe and control where SQL*Plus saves and retrieves your script files.