SQL*Plus® User's Guide and Reference Release 10.1 Part Number B12170-01 |
|
|
View PDF |
This chapter introduces you to some general aspects of SQL*Plus. It has the following topics:
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:
Format, perform calculations on, store, and print from query results
Examine table and object definitions
Develop and run batch scripts
Perform database administration
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.
SQL*Plus command-line and the Windows GUI use a two-tier model comprising:
Client (command-line user interface).
Database (Oracle Database).
iSQL*Plus is a browser-based interface which uses the SQL*Plus processing engine in a three-tier model comprising:
Client (Web browser).
Middle tier (Application Server).
Database (Oracle Database).
The iSQL*Plus Server is installed on the same machine as the Application Server. The client may or may not also be on this machine. The middle tier coordinates interactions and resources between the client tier and the database tier. The database is Oracle8i, Oracle9i or Oracle Database 10g accessed through Oracle Net.
The iSQL*Plus user interface comprises web pages served to your web browser through the Internet or your intranet. There is no installation or configuration required for the iSQL*Plus user interface. You only need to know the URL of the Application Server to access an available Oracle database.
The Application Server is installed when Oracle Database is installed.
The middle tier contains a Java2 Enterprise Edition (J2EE) compliant application server. It uses Oracle Containers for Java (OC4J) as the server engine. The Application Server enables communication and authentication between the iSQL*Plus user interface and Oracle Database.
SQL*Plus is a component of Oracle Database. SQL*Plus, and its command-line user interface, Windows GUI, and iSQL*Plus web-based user interface are installed by default when you install the Oracle Database.
Some aspects of Oracle Database and SQL*Plus differ from one computer and operating system to another. These topics are discussed in the Oracle Database Installation Guide for each operating system that SQL*Plus supports.
Keep a copy of your Oracle Database Installation Guide available for reference.
The default date format in SQL*Plus is determined by the database NLS_DATE_FORMAT parameter and may use a date format displaying two digit years. You can use the SQL TO_CHAR function, or the SQL*Plus COLUMN FORMAT command in your SELECT statements to control the way dates are displayed in your report.
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 the Oracle Database.
The SQL*Plus language is easy to use. For example, to rename a column labelled LAST_NAME with the heading "Family Name", enter the command:
COLUMN LAST_NAME HEADING 'Family Name'
Similarly, to list column definitions for the EMPLOYEES table, enter the command:
DESCRIBE EMPLOYEES
There are several sources available to assist you to learn SQL*Plus:
Part II of this Guide, Using SQL*Plus
Help for SQL*Plus, Command-line and iSQL*Plus online help
Oracle Database 10g: SQL Fundamentals
An instructor-led course run by Oracle. This is a comprehensive hands-on course taking the student through all aspects of using SQL*Plus and iSQL*Plus to access Oracle Database.
More Oracle Database 10g Training
To find more useful Oracle courses, go to http://www.oracle.com/education
.
This guide provides information about SQL*Plus that applies to all operating systems. It also includes some Windows and UNIX specific information, for example, the Windows Graphical User Interface. Some aspects of SQL*Plus differ on each operating system. Such operating system specific details are covered in the Oracle Database Installation Guide provided for your system. Use these operating system specific guides in conjunction with this 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. The tables are described in "Oracle Database Sample Schemas and SQL*Plus". The conventions used in command examples are described in "Conventions".
Sample schemas are included with Oracle Database. The tutorial and 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. To view column details for the view, EMP_DETAILS_VIEW, enter
DESCRIBE EMP_DETAILS_VIEW
For more information about the sample schemas, see the Oracle Database Sample Schemas guide.
The Human Resources (HR) Sample Schema is 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 your_password is the password you want to define for the user HR:
ALTER USER HR IDENTIFIED BY your_password ACCOUNT UNLOCK;
For further information about unlocking the HR account, see the Oracle Database Sample Schemas guide. The HR user is primarily to enable you to access the HR sample schema and is necessary to enable you to run the examples in this guide.
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 HR tables, see your DBA or see the Oracle Database Sample Schemas guide, or you can create the HR tables with the script HR_MAIN.SQL which is located in the following directory on UNIX:
$ORACLE_HOME/DEMO/SCHEMA/HUMAN_RESOURCES/HR_MAIN.SQL
And on the following directory on Windows:
%ORACLE_HOME%\DEMO\SCHEMA\HUMAN_RESOURCES\HR_MAIN.SQL
To create the HR tables from command-line SQL*Plus, do the following:
Ask your DBA for your Oracle Database account username and password.
Login to SQL*Plus.
On UNIX, enter the following command at the SQL*Plus prompt:
SQL> @?/DEMO/SCHEMA/HUMAN_RESOURCES/HR_MAIN.SQL
On Windows, enter the following command at the SQL*Plus prompt:
SQL> @?\DEMO\SCHEMA\HUMAN_RESOURCES\HR_MAIN.SQL
To remove the sample tables, perform the same steps but substitute HR_DROP.SQL for HR_MAIN.SQL.