Skip Headers

SQL*Plus® User's Guide and Reference
Release 10.1

Part Number B12170-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

SQL*Plus Quick Start

These instructions are to enable you to login and connect to a database after you have installed SQL*Plus. You can connect to the default database you created during installation, or to another existing Oracle database.

Resources

What is SQL*Plus

SQL*Plus is an interactive and batch query tool that is installed with every Oracle Database Server or Client installation. It has a command-line user interface, a Windows Graphical User Interface (GUI) and the iSQL*Plus web-based user interface.

SQL*Plus has its own commands and environment, and it provides access to the Oracle Database. It enables you to enter and execute SQL, PL/SQL, SQL*Plus and operating system commands to perform the following:

You can use SQL*Plus to generate reports interactively, to generate reports as batch processes, and to output the results to text file, to screen, or to HTML file for browsing on the Internet. You can generate reports dynamically using the HTML output facility of SQL*Plus, or using the dynamic reporting capability of iSQL*Plus to run a script from a web page.

Before Starting SQL*Plus or iSQL*Plus

What is necessary before you can run SQL*Plus or iSQL*Plus?

Starting SQL*Plus Command-line

The SQL*Plus executable is usually installed in $ORACLE_HOME/bin, which is usually included in your operating system PATH environment variable. You may need to change directory to the $ORACLE_HOME/bin directory to start SQL*Plus.


To start SQL*Plus and connect to the default database
  1. Open a UNIX or a Windows terminal and enter the SQL*Plus command:

    sqlplus
    
  2. When prompted, enter your Oracle Database username and password. If you do not know your Oracle Database username and password, ask your Database Administrator.

  3. Alternatively, enter the SQL*Plus command in the form:

    sqlplus username/password
    

    To hide your password, enter the SQL*Plus command in the form:

    sqlplus username
    

    You will be prompted to enter your password.

  4. SQL*Plus starts and connects to the default database.

    Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands at the SQL> prompt.


To start SQL*Plus and connect to a database other than the default

Open a UNIX or a Windows terminal and enter the SQL*Plus command:

sqlplus username/password@connect_identifier

To hide your password, enter the SQL*Plus command in the form:

sqlplus username@connect_identifier

You will be prompted to enter your password.

Starting SQL*Plus Windows GUI


To start the SQL*Plus Windows GUI and connect to a database
  1. Click Start > Programs > Oracle-OraHomeName > Application Development > SQL Plus.

  2. Alternatively, open a Windows terminal and enter the SQL*Plus command:

    sqlplusw 
    
  3. The SQL*Plus Windows GUI opens and the Log On dialog is displayed.

    Enter your Oracle Database username and password in the Log On dialog. If you do not know your Oracle Database username and password, ask your Database Administrator.

    Leave the Host String field blank to connect to the default database. Enter a connection identifier for the database you want to connect to in the Host String field. You can connect to Oracle8i, Oracle9i and Oracle Database 10g databases.

  4. Click OK. SQL*Plus starts and connects to the database.

    Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands at the SQL> prompt.

Starting and Stopping the iSQL*Plus Application Server

The iSQL*Plus Application Server is started during Oracle Database installation. It must be running to enable web-based iSQL*Plus sessions. See Starting the iSQL*Plus Application Server.

Starting iSQL*Plus


To start an iSQL*Plus session
  1. Enter the iSQL*Plus URL in your web browser's Location or Address field. The iSQL*Plus URL looks like:

    http://machine_name.domain:port/isqlplus
    
  2. Press Enter to go to the URL. The iSQL*Plus Login screen is displayed in your web browser.

  3. Enter your Oracle Database username and password in the Username and Password fields. If you do not know your Oracle Database username and password, ask your Database Administrator.

  4. Leave the Connection Identifier field blank to connect to the default database.

    Enter an Oracle Database connection identifier in the Connection Identifier field to connect to a database other than the default. You can connect to Oracle8i, Oracle9i and Oracle Database 10g databases.

    If restricted database access has been configured, the Connection Identifier field is a dropdown list of available databases to select.

  5. Click Login to connect to the database. The iSQL*Plus Workspace is displayed in your web browser.

    Now you can start entering and executing SQL, PL/SQL and SQL*Plus statements and commands in the Workspace.

Connecting to a Different Database


To connect to a different database from a current command-line session

From an existing Windows GUI or command-line session, enter a CONNECT command in the form:

SQL> connect username/password@connect_identifier

To hide your password, enter the CONNECT command in the form:

SQL> connect username@connect_identifier

You will be prompted to enter your password.


To connect to a different database from a current iSQL*Plus session

From an existing iSQL*Plus session, enter a CONNECT command in the form:

connect username/password@connect_identifier

If you do not enter a password, iSQL*Plus prompts you to enter one.

Sample Schemas and SQL*Plus

Sample schemas are included with the Oracle Database. Examples in this guide use the EMP_DETAILS_VIEW view of the Human Resources (HR) sample schema. This schema contains personnel records for a fictitious company.

For more information about the sample schemas, see the Oracle Database Sample Schemas guide.

Unlocking the Sample Tables

The Human Resources (HR) Sample Schema may be installed as part of the default Oracle Database installation. The HR account is locked by default.

You need to unlock the HR account before you can use the HR sample schema. To unlock the HR account, log in as the SYSTEM user and enter the following command, where password is the password you want to define for the user HR:

ALTER USER HR IDENTIFIED BY password ACCOUNT UNLOCK;

Running your first Query

To describe a database object using iSQL*Plus, for example, column details for EMP_DETAILS_VIEW, enter a DESCRIBE command like:

DESCRIBE EMP_DETAILS_VIEW

which produces the following output:

Description of describe.gif follows
Description of the illustration describe.gif

To rename the column headings, and to select data from the HR sample schema view, EMP_DETAILS_VIEW, enter

COLUMN FIRST_NAME HEADING "First Name"
COLUMN LAST_NAME HEADING "Family Name"
SELECT FIRST_NAME, LAST_NAME
FROM EMP_DETAILS_VIEW
WHERE LAST_NAME LIKE 'K%';

which produces the following output:

Description of selectout.gif follows
Description of the illustration selectout.gif

Exiting SQL*Plus

It is recommended that you always use the Logout icon to exit iSQL*Plus to free up system and server resources.

To exit SQL*Plus command-line, enter EXIT.

To exit the Windows GUI, enter EXIT or select Exit from the File menu.

In iSQL*Plus, the EXIT or QUIT command halts the script currently running, it does not terminate your session.