Sql*Plus – Scripts and SQLPATH

As oracle DBA’s I find that most of us are command line sadists more than GUI folk. Therefore we write and run lots of scripts and if we can store those scripts in a common location our lives are easier. Here is my method.

  • Create a Common Directory
  • Set the SQLPATH Environment Variable

Create a Common Directory

I run my databases on Linux and NetApp filers so I create a volume on the NetApp filer named /dba. This way I can mount /dba on each of my Linux servers creating a common mount point available to all servers. Then what I do is create a series of directories for various purposes. The purpose of this post is for a scripts directory. So, on all of my Linux servers I now have access to:


For windows you may want to mount a drive such as

m: which has the directory /dba/scripts

Set the SQLPATH Environment Variable

When running scripts in Sql*Plus it is easiest if I can just type in the name of the script (without the full path and filename). The SQLPATH environment variable is how this can be accomplished. To use the directory I mentioned above the SQLPATH is set like this.

export SQLPATH=/dba/scripts

If you are using windows you will do something like this.

set SQLPATH=m:\dba\scripts
(TIP: The same directory can be utilized by both Linux and Windows machines)

On Linux I put the export SQLPATH=/dba/scripts in my .bashrc file so it is set each time I start a shell.

As I put new posts on this blog about the scripts I use in my daily life as a DBA they will all be stored in this directory if they are SQL scripts. For shell scripts I use a different directory.>

3-2-1 Execute

Welcome to the launch of my new blog. Let’s get right to it. The goal of this blog is to provide helpful tips and articles for Oracle DBA’s, Linux Administrators, NetApp Administrators, and those who use all three of these technologies like I do. I’m learning SQL Server, MySql, and WordPress so perhaps I can post on those topics as well.

My name is Michael Cunningham and I’ve been an Oracle DBA since October 2003. I’ve used oracle since 1998 and even been involved in the design of several data models, but during that time my primary responsibility was writing enterprise level custom business applications. I’ve also been doing Linux Administration for over 3 years and am a Red Hat Certified Engineer.

I’m just getting started with this blog and I suspect it will be a slow start as I get going, but I hope you will come back and even subscribe to the RSS feed when I learn how to do that.