DB Creation   «Prev  Next»

Lesson 1

Introduction to Oracle SQL*Plus

SQL*Plus is Oracle Database’s command-line client for connecting, running SQL and PL/SQL, and performing basic administration tasks. For scripting-heavy workflows, many teams also use SQLcl (a modern CLI with command history and scripting niceties). Browser-based iSQL*Plus is discontinued.

Prerequisites

Common Tasks

  1. Start SQL*Plus and connect to a database.
  2. Check help for SQL*Plus commands (environment, formatting, spooling).
  3. Describe tables and views.
  4. Run queries and review results.
  5. Write output to a file (spool).
  6. Optional (DBA only): start up or shut down a database when connected as SYSDBA.

Quick Examples

Connect

sqlplus username@//host:port/service_name
-- or on the same host:
-- sqlplus / as sysdba

Describe a table and query data

DESCRIBE hr.employees;

SELECT first_name, last_name, department_id
FROM   hr.employees
WHERE  ROWNUM <= 5;

Write output to a file (spool)

SPOOL /tmp/report.txt
SELECT COUNT(*) AS rows_in_emp FROM hr.employees;
SPOOL OFF
Note on Shared Server vs. Dedicated: SQL*Plus works with either server mode. Shared Server is a database-side architecture choice and is not a separate SQL*Plus command set. See the dedicated module on Shared Server Architecture for details.

Related: Monitoring with Enterprise Manager Cloud Control

SQL*Plus is ideal for ad-hoc SQL and scripting. For fleet monitoring, alerting, and job automation, use Enterprise Manager Cloud Control.

Oracle Enterprise Manager Cloud Control dashboard with target status and performance panels
Figure 2. Enterprise Manager Cloud Control (related tooling)

SEMrush Software 1 SEMrush Banner 1