| Lesson 2 | Using the SQL*Plus Environment |
| Objective | Describe SQL*Plus and identify when to use it. |
SQL*Plus is the foundational command-line interface for interacting with Oracle Database. It ships with every Oracle installation and has been used by developers, DBAs, and analysts for decades. While Oracle now provides modern GUI tools and web-based management interfaces, SQL*Plus remains essential for scripting, automation, remote administration, and fast execution of SQL and PL/SQL commands. This lesson explains what SQL*Plus is, how it operates, and when it should be your tool of choice.
SQL*Plus is a versatile programming environment for SQL and PL/SQL. You can use it to:
Many administrators rely on SQL*Plus to generate custom scripts for granting privileges, building schema objects, automating maintenance tasks, or creating periodically refreshed web pages. SQL*Plus supports complete automation via shell scripts and scheduled jobs, making it ideal for environments where repeatability and reliability matter.
SQL*Plus includes the SET ERRORLOGGING command, which records SQL, PL/SQL, and SQL*Plus errors into a log table. When enabled, SQL*Plus writes errors automatically to the SPERRORLOG table, creating it if necessary.
Example:
-- enable error logging
SQL> set errorlogging on
-- bad query
SQL> select * from dud;
ORA-00942: table or view does not exist
Inspecting the structure of the logging table:
SQL> desc sperrorlog
Name Null? Type
------------ --------- ----------------------------
USERNAME VARCHAR2(256)
TIMESTAMP TIMESTAMP(6)
SCRIPT VARCHAR2(1024)
IDENTIFIER VARCHAR2(256)
MESSAGE CLOB
STATEMENT CLOB
Querying the logged errors:
SQL> select username, timestamp, statement, message
from sperrorlog;
USERNAME TIMESTAMP STATEMENT
--------- -------------------------------- -------------------------
MESSAGE
-------------------------------------------
SYS 11-AUG-07 09.54.47.000000 PM select * from dud
ORA-00942: table or view does not exist
SQL*Plus is available in two main interfaces:
Oracle Enterprise Manager introduced the SQLPlus Worksheet, which runs inside a web browser and provides a more modern interface. Although it resembles SQL*Plus, it lacks the full set of SQL*Plus environment commands and is not a complete replacement for SQL*Plus reporting features.
Oracle continues expanding its GUI- and web-based administration tools, gradually phasing out older command-line components like SVRMGR. However, SQL*Plus remains relevant for automation, script execution, and environments where GUI tools are impractical. Enterprise Manager’s SQLPlus Worksheet supports code execution but relies heavily on automated SQL generation and lacks SQL*Plus’s rich reporting features.
Most modern report-writing and analysis tasks are now handled by tools such as Oracle Developer, Oracle APEX, BI Publisher, or third-party reporting engines. SQL*Plus remains most valuable for rapid scripting, administrative tasks, and simple report generation.
Enterprise Manager Cloud Control provides a unified platform for managing Oracle environments, both on-premises and in the cloud. It includes:
Although SQL*Plus is not replaced by Cloud Control, many routine tasks traditionally executed manually in SQL*Plus can now be automated or orchestrated using Cloud Control’s GUI and automation tools.
SQL*Plus is useful for beginners and experienced users alike. It provides simple syntax, immediate feedback, and predictable behavior. For example, renaming a column heading is as simple as:
COLUMN LAST_NAME HEADING 'Family Name'
To view the columns of a table:
DESCRIBE EMPLOYEES
SQL*Plus follows a two-tier architecture:
The client and database may be on the same machine or separated across the network. SQL*Plus communicates with Oracle Database using Oracle Net packets, ensuring reliable and efficient command processing.