DB Creation   «Prev  Next»

Lesson 2

Getting Started with SQL*Plus

SQL*Plus is Oracle Database’s classic command-line client for connecting, running SQL/PLSQL, and simple administration. For a more modern CLI with scripting niceties, consider SQLcl. (The browser-based iSQL*Plus is discontinued.)

What you’ll learn

Prerequisites

Connect patterns

1) Easy Connect

sqlplus scott@//localhost:1521/orclpdb1
-- then enter password when prompted

2) TNS alias (tnsnames.ora)

sqlplus scott@orcl

3) Start without connecting, then connect

sqlplus /nolog
CONNECT scott@//localhost:1521/orclpdb1

4) Privileged connection (local, OS-auth)

sqlplus / AS SYSDBA
Wallet / TCPS: When using mTLS/TCPS, wallet location and related settings are configured in sqlnet.ora / tnsnames.ora (or Easy Connect Plus parameters). They are not passed as extra tokens on the CONNECT command.

Common tasks

Describe objects and run queries

DESCRIBE hr.employees;

SELECT first_name, last_name, department_id
FROM   hr.employees
FETCH FIRST 5 ROWS ONLY;

Write output to a file

SPOOL /tmp/emp_report.txt
COLUMN full_name FORMAT A30
SELECT first_name || ' ' || last_name AS full_name FROM hr.employees FETCH FIRST 10 ROWS ONLY;
SPOOL OFF

Shared Server vs. Dedicated (clarification)

SQL*Plus works with either Shared or Dedicated server modes, but you don’t “turn on shared server” in the CONNECT command. Shared/Dedicated is a database configuration (dispatchers, shared servers, service handlers). If the database offers a Shared Server service, your normal connect string will use it.

Legacy tools (context)

Server Manager (svrmgrl) was retired long ago and its CLI functions were consolidated into SQL*Plus. For fleet monitoring and automation, use Enterprise Manager Cloud Control.


SEMrush Software 2 SEMrush Banner 2