SQL*Plus is a client-server tool for connecting to a database and issuing ad hoc SQL commands. It can also be used for creating PL/SQL code and has facilities for formatting results. It is available on all platforms to which the database has been ported—the sections that follow give some detail on using SQL*Plus on Linux and Windows. There are no significant differences with using SQL*Plus on any other platform. In terms of architecture, SQL*Plus is a user process written in C. It establishes a session against an instance and a database over the Oracle Net protocol. The platforms for the client and the server can be different. For example, there is no reason not to use SQL*Plus on a Windows PC to connect to a database running on a mainframe (or the other way round) provided that Oracle Net has been configured to make the connection.
SQL*Plus on Linux
The SQL*Plus executable file on a Linux installation is sqlplus. The location of this file will be installation specific but will typically be something like:
Your Linux account should be set up appropriately to run SQL*Plus. There are some environment variables that will need to be set. These are:
The ORACLE_HOME variable points to the Oracle Home. An Oracle Home is the Oracle software installation: the set of files and directories containing the executable code and some of the configuration files.
The PATH must include the bin directory in the Oracle Home.
The LD_LIBRARY_PATH should include the lib directory in the Oracle Home, but in practice you may get away without setting this. Figure below shows a Linux terminal window and some tests to see if the environment is correct.
In The Figure , first the echo command checks whether the three variables have been set up correctly: there is an ORACLE_HOME, and the bin and lib directories in it have been set as the first element of the PATH and LD_LIBRARY_PATH variables. Then which confirms that the SQL*Plus executable file really is available, in the PATH. Finally, SQL*Plus is launched with a username, a password, and a connect identifier passed to it on the command line. If the tests do not return acceptable results and SQL*Plus fails to launch, this should be discussed with your system administrator and your database administrator.
The format of the login string is the database username followed by a forward slash character as a delimiter, then a password followed by an @ symbol as a delimiter, and finally an Oracle Net connect identifier. Following the logon, the next lines of text display the version of SQL*Plus being used, which is 184.108.40.206.0, the version of the database to which the connection has been made (which happens to be the same as the version of the SQL*Plus tool), and which options have been installed within the database. The last line is the prompt to the user, SQL, at which point the user can enter any SQL*Plus or SQL command. If the login does not succeed with whatever username (probably not system) you have been allocated, this should be discussed with your database administrator.
SQL*Plus on Windows
Historically, there were always two versions of SQL*Plus for Microsoft Windows: the character version and the graphical version. The character version is the executable file sqlplus.exe, and the graphical version was sqlplusw.exe. With the current release the graphical version no longer exists, but many developers will prefer to use it and the versions shipped with earlier releases are perfectly good tools for working with an 11g database. There are no problems with mixing versions: an 11g SQL*Plus client can connect to a 10g database, and a 10g SQL*Plus client can connect to an 11g database. Following a default installation of either the Oracle database or just the Oracle client on Windows, SQL*Plus will be available as a shortcut on the Windows Start menu. The navigation path will be as follows:
- Application Development
- SQL Plus
However, the exact path will be installation specific. Figure below shows a logon to a database with SQL*Plus, launched from the shortcut. The first line of text shows the version of SQL*Plus, which is the 220.127.116.11.0 beta release, and the time the program was launched. The third line of text is a logon prompt:
followed by the logon string entered manually, which was
A change some people like to make to the shortcut that launches SQL*Plus is to prevent it from immediately presenting a login prompt. To do this, add the NOLOG switch to the end of the command:
There is no reason not to launch SQL*Plus from an operating system prompt rather than from the Start menu shortcut: simply open a command window and run it. The program will immediately prompt for a logon, unless you invoke it with the NOLOG switch described above.
- OCA Oracle Database 11g: SQL Fundamentals I Exam Guide (Exam 1Z0-051)