SQL*Plus User's Guide and Reference
Release 8.1.7
Part Number A82950-01





Go to previous pageGo to next page


This chapter introduces you to SQL*Plus, covering the following topics:

Overview of SQL*Plus

You can use the SQL*Plus program in conjunction with the SQL database language and its procedural language extension, PL/SQL. The SQL database language allows you to store and retrieve data in Oracle. PL/SQL allows you to link several SQL commands through procedural logic.

SQL*Plus enables you to execute SQL commands and PL/SQL blocks, and to perform many additional tasks as well. Through SQL*Plus, you can

Basic Concepts

The following definitions explain concepts central to SQL*Plus:


An instruction you give SQL*Plus or Oracle. 


A group of SQL and PL/SQL commands related to one another through procedural logic. 


The basic unit of storage in Oracle. 


A SQL command (specifically, a SQL SELECT command) that retrieves information from one or more tables. 

query results 

The data retrieved by a query. 


Query results formatted by you through SQL*Plus commands. 

Who Can Use SQL*Plus

The SQL*Plus, SQL, and PL/SQL command languages are powerful enough to serve the needs of users with some database experience, yet straightforward enough for new users who are just learning to work with Oracle.

The design of the SQL*Plus command language makes it easy to use. For example, to give a column labelled ENAME in the database the clearer heading "Employee", you might enter the following command:


Similarly, to list the column definitions for a table called EMP, you might enter this command:


Using this Guide

This Guide gives you information about SQL*Plus that applies to all operating systems. Some aspects of SQL*Plus, however, differ on each operating system. Such operating system specific details are covered in the Oracle installation and user's manual(s) provided for your system. Use these operating system specific manuals in conjunction with the SQL*Plus User's Guide and Reference.

Throughout this Guide, examples showing how to enter commands use a common command syntax and a common set of sample tables. Both are described below. You will find the conventions for command syntax particularly useful when referring to commands in Chapter 7 and Chapter 8 of this Guide.

Conventions for Command Syntax

The following two tables describe the notation and conventions for command syntax used in this Guide.

Table 1-1 Commands, Terms, and Clauses

Feature Example Explanation



Enter text exactly as spelled; it need not be in uppercase. 

lowercase italics 


A clause value; substitute an appropriate value. 

words with 
specific meanings 


A single character. 



A CHAR value--a literal in single quotes--or an expression with a CHAR value. 


or e

A date or an expression with a DATE value. 



An unspecified expression. 


m or n

A number or an expression with a NUMBER value. 



A CHAR constant with or without single quotes. 



A user variable (unless the text specifies another variable type). 

Other words are explained where used if their meaning is not explained by context.

Table 1-2 Punctuation

Feature Example Explanation

vertical bar 


Separates alternative syntax elements that may be optional or mandatory. 



One or more optional items. If two items appear separated by |, enter one of the items separated by |. Do not enter the brackets or |. 



A choice of mandatory items; enter one of the items separated by |. Do not enter the braces or |. 



A default value; if you enter nothing, SQL*Plus uses the underlined value. 



Preceding item(s) may be repeated any number of times. 

Enter other punctuation marks where shown in the command syntax.

Sample Tables

Many of the concepts and operations in this Guide are illustrated by a set of sample tables. These tables contain personnel records for a fictitious company. As you complete the exercises in this Guide, imagine that you are the personnel director for this company.

The exercises make use of the information in two sample tables:


Contains information about the employees of the sample


Contains information about the departments in the company. 

Dates in the sample tables use four digit years. As the default date format in SQL*Plus is DD-MM-YY, dates displayed show only a two digit year. Use the SQL TO_CHAR function in your SELECT statements to control the way dates are displayed. 

Figure 1-1 and Figure 1-2 show the information in these tables.

Figure 1-1 DEPT Table

--------- ------------- -----------
       20 RESEARCH      DALLAS
       30 SALES         CHICAGO

Figure 1-2 EMP Table

----- -----  -------- ---- ----------- ------ ------ ------
 7369 SMITH  CLERK    7902 17-DEC-80      800            20
 7499 ALLEN  SALESMAN 7698 20-FEB-81     1600    300     30
 7521 WARD   SALESMAN 7698 22-FEB-81     1250    500     30
 7566 JONES  MANAGER  7839 02-APR-81     2975            20
 7654 MARTIN SALESMAN 7698 28-SEP-81     1250   1400     30
 7698 BLAKE  MANAGER  7839 01-MAY-81     2850            30
 7782 CLARK  MANAGER  7839 09-JUN-81     2450            30
 7788 SCOTT  ANALYST  7566 09-DEC-82     3000            20
 7839 KING   PRESIDENT     17-NOV-81     5000            10
 7844 TURNER SALESMAN 7698 08-SEP-81     1500      0     30
 7876 ADAMS  CLERK    7788 12-JAN-83     1100            20
 7900 JAMES  CLERK    7698 03-DEC-81      950            30
 7902 FORD   ANALYST  7566 03-DEC-81     3000            20
 7934 MILLER CLERK    7782 23-JAN-82     1300            10

What You Need to Run SQL*Plus

To run SQL*Plus, you need hardware, software, operating system specific information, a username and password, and access to one or more tables.

Hardware and Software

Oracle and SQL*Plus can run on many different kinds of computers. Your computer's operating system manages the computer's resources and mediates between the computer hardware and programs such as SQL*Plus. Different computers use different operating systems. For information about your computer's operating system, see the documentation provided with the computer.

Before you can begin using SQL*Plus, both Oracle and SQL*Plus must be installed on your computer. Note that in order to take full advantage of the enhancements in SQL*Plus Release 8.1.7, you must have Oracle8i Release 8.1.7. For a list of SQL*Plus Release 8.1.7 enhancements, see Appendix B.

If you have multiple users on your computer, your organization should have a Database Administrator (called a DBA) who supervises the use of Oracle.

The DBA is responsible for installing Oracle and SQL*Plus on your system. If you are acting as DBA, see the instructions for installing Oracle and SQL*Plus in the Oracle installation and user's manual(s) provided for your operating system.

Information Specific to Your Operating System

A few aspects of Oracle and SQL*Plus differ from one type of host computer and operating system to another. These topics are discussed in the Oracle installation and user's manual(s), published in a separate version for each host computer and operating system that SQL*Plus supports.

Keep a copy of your Oracle installation and user's manual(s) available for reference as you work through this Guide. When necessary, this Guide will refer you to your installation and user's manual(s).

Username and Password

When you start SQL*Plus, you will need a username that identifies you as an authorized Oracle user and a password that proves you are the legitimate owner of your username. See the PASSWORD command in Chapter 8 for details on how to change your password. The demonstration username, SCOTT, and password, TIGER, may be set up on your system during the installation procedure. In this case, you can use the Oracle username SCOTT and password TIGER with the EMP and DEPT tables (Figure 1-1 and Figure 1-2).

Multi-User Systems

If several people share your computer's operating system, your DBA can set up your SQL*Plus username and password. You will also need a system username and password to gain admittance to the operating system. These may or may not be the same ones you use with SQL*Plus.

Single-User Systems

If only one person at a time uses your computer, you may be expected to perform the DBAs functions for yourself. In that case, you can use the Oracle username SCOTT and password TIGER with the appropriate DBA priveleges. If you want to define your own username and password, see the Oracle8i SQL Reference.

Access to Sample Tables

Each table in the database is "owned" by a particular user. You may wish to have your own copies of the sample tables to use as you try the examples in this Guide. To get your own copies of the tables, see your DBA or run the Oracle-supplied command file named DEMOBLD (you run this file from your operating system, not from SQL*Plus).

When you have no more use for the sample tables, remove them by running another Oracle-supplied command file named DEMODROP. For instructions on how to run DEMOBLD and DEMODROP, see the Oracle installation and user's manual(s) provided for your operating system.

Go to previous page Go to next page
Copyright © 2000 Oracle Corporation.
All Rights Reserved.