SQL*Plus User’s Guide and Reference Release 9.2 March 2002 Part No. A90842-01 SQL*Plus User’s Guide and Reference, Release 9.2 Part No. A90842-01 Copyright © 1996, 2002 Oracle Corporation. All rights reserved. Primary Author: Simon Watt Contributors: Andrew Code, Alison Goggin, Alison Holloway, Christopher Jones, Luan Nim, Marcus Pecher, Andrei Souleimanian, Christopher Tan, Ian Wu. The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation. If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on behalf of the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the Programs. Oracle is a registered trademark, and Oracle7, Oracle8, Oracle8i, Oracle9i, PL/SQL, iSQL*Plus, SQL*Plus, SQL*Net, Oracle Store, Pro*C/C++ and Pro*COBOL are trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their respective owners. iii Contents Send Us Your Comments xv Preface xvii Intended Audience xviii Documentation Accessibility xviii Documentation Structure xix Related Documentation xxi Conventions xxiii What’s New in SQL*Plus? xxix New Features in SQL*Plus 9.2 xxx New Features in iSQL*Plus 9.2 xxxii Upgrading iSQL*Plus Server from 9.0.1 to 9.2 xxxiv New Features in SQL*Plus 9.0.1 xxxvi SQL*Plus Quick Start xxxix iSQL*Plus Quick Start xl SQL*Plus Command-line Quick Start for Windows xli SQL*Plus Command-line Quick Start for UNIX xlii iv Part I SQL*Plus Getting Started 1 SQL*Plus Overview What is SQL*Plus 1-2 SQL*Plus Command-line Architecture 1-4 iSQL*Plus Architecture 1-4 SQL*Plus Installation 1-5 Who Can Use SQL*Plus 1-5 How Can I Learn SQL*Plus 1-6 How to Use the SQL*Plus Guide 1-6 Oracle9i Sample Tables and SQL*Plus 1-6 Unlocking the Sample Tables 1-7 2 SQL*Plus User Interface SQL*Plus Command-line User Interface 2-2 The Command-line Screen 2-2 iSQL*Plus User Interface 2-3 iSQL*Plus Navigation 2-3 iSQL*Plus Login Screen 2-4 iSQL*Plus Work Screen 2-5 iSQL*Plus History Screen 2-6 iSQL*Plus Preferences Screen 2-8 iSQL*Plus User Interface Options 2-9 iSQL*Plus DBA Login Screen 2-10 iSQL*Plus DBA Work Screen 2-12 iSQL*Plus Server Statistics 2-12 Setting System Variables in iSQL*Plus 2-14 iSQL*Plus Extension for Windows 2-16 3 Configuring SQL*Plus SQL*Plus Configuration 3-2 Site Profile 3-2 User Profile 3-2 Storing and Restoring SQL*Plus System Variables 3-3 v iSQL*Plus Configuration 3-5 Configuring the Client Tier 3-5 Configuring the Middle Tier: iSQL*Plus Server 3-7 Configuring the Middle Tier: Oracle HTTP Server 3-12 Configuring the Middle Tier: Oracle Net 3-15 Configuring the Database Tier 3-15 iSQL*Plus Extension for Windows Configuration 3-15 Configuration Dialog 3-16 4 Starting SQL*Plus Starting Command-line SQL*Plus 4-2 The SQLPLUS Command 4-3 Options 4-4 Logon 4-10 Start 4-12 Getting Command-line Help 4-12 Installing Command-line Help 4-12 Exiting Command-line SQL*Plus 4-13 Starting iSQL*Plus 4-14 Getting Help in iSQL*Plus 4-14 Exiting iSQL*Plus 4-15 Starting iSQL*Plus from a URL 4-15 Login Username and Password 4-17 Changing your Password 4-18 Changing Your Password in iSQL*Plus 4-19 Multi-User Systems 4-20 Single-User Systems 4-20 Database Connection Identifier 4-20 Connecting to a Remote Database as You Start SQL*Plus 4-21 Connecting to a Remote Database Using the CONNECT Command 4-22 vi Part II Using SQL*Plus 5 SQL*Plus Basics Entering and Executing Commands 5-2 The SQL Buffer 5-2 Executing Commands 5-3 Running SQL Commands 5-3 Running PL/SQL Blocks 5-7 Running SQL*Plus Commands 5-8 Understanding SQL*Plus Command Syntax 5-9 System Variables that Affect How Commands Run 5-10 Saving Changes to the Database Automatically 5-11 Stopping a Command while it is Running 5-12 Running Host Operating System Commands 5-12 Getting Help 5-13 Listing a Table Definition 5-13 Listing PL/SQL Definitions 5-14 Controlling the Display 5-15 Interpreting Error Messages 5-15 6 Using Scripts in SQL*Plus Editing Scripts 6-2 Writing Scripts with a System Editor 6-2 Modifying Scripts 6-3 Editing Scripts in SQL*Plus 6-4 Placing Comments in Scripts 6-10 Using the REMARK Command 6-10 Using /* */ 6-10 Using 6-11 Notes on Placing Comments 6-11 Running Scripts 6-14 Nesting Scripts 6-15 Receiving a Return Code 6-16 Exiting from a Script with a Return Code 6-17 vii Writing Interactive Commands 6-17 Defining User Variables 6-17 Using Substitution Variables 6-18 Substitution Variables in iSQL*Plus 6-24 Passing Parameters through the START Command 6-26 Communicating with the User 6-27 Using Bind Variables 6-31 Creating Bind Variables 6-31 Referencing Bind Variables 6-31 Displaying Bind Variables 6-32 Using REFCURSOR Bind Variables 6-32 7 Formatting SQL*Plus Reports Formatting Columns 7-2 Changing Column Headings 7-2 Formatting NUMBER Columns 7-4 Formatting Datatypes 7-5 Copying Column Display Attributes 7-9 Listing and Resetting Column Display Attributes 7-9 Suppressing and Restoring Column Display Attributes 7-10 Printing a Line of Characters after Wrapped Column Values 7-10 Clarifying Your Report with Spacing and Summary Lines 7-12 Suppressing Duplicate Values in Break Columns 7-12 Inserting Space when a Break Column’s Value Changes 7-13 Inserting Space after Every Row 7-14 Using Multiple Spacing Techniques 7-14 Listing and Removing Break Definitions 7-16 Computing Summary Lines when a Break Column’s Value Changes 7-16 Computing Summary Lines at the End of the Report 7-20 Computing Multiple Summary Values and Lines 7-20 Listing and Removing COMPUTE Definitions 7-22 Defining Page and Report Titles and Dimensions 7-23 Setting the Top and Bottom Titles and Headers and Footers 7-23 Displaying System-Maintained Values in Titles 7-27 Listing, Suppressing, and Restoring Page Title Definitions 7-29 viii Displaying Column Values in Titles 7-29 Displaying the Current Date in Titles 7-30 Setting Page Dimensions 7-31 Storing and Printing Query Results 7-33 Sending Results to a File 7-34 Sending Results to a Printer 7-35 8 Generating HTML Reports from SQL*Plus Creating Reports using Command-line SQL*Plus 8-2 Creating Reports 8-2 Creating Reports with CGI Scripts 8-7 Suppressing the Display of SQL*Plus Commands in Reports 8-12 HTML Entities 8-12 Creating Reports using iSQL*Plus 8-13 9 Tuning SQL*Plus Tracing Statements 9-2 Controlling the Report 9-2 Execution Plan 9-3 Statistics 9-4 Collecting Timing Statistics 9-7 Tracing Parallel and Distributed Queries 9-7 System Variables Influencing SQL*Plus Performance 9-10 iSQL*Plus Server Statistics 9-12 Interpreting Active Statistics 9-13 iSQL*Plus Tuning Notes 9-14 10 SQL*Plus Security PRODUCT_USER_PROFILE Table 10-2 Creating the PUP Table 10-2 PUP Table Structure 10-3 Description and Use of PUP Columns 10-3 PUP Table Administration 10-4 Disabling SQL*Plus, SQL, and PL/SQL Commands 10-4 ix Creating and Controlling Roles 10-6 Disabling SET ROLE 10-7 Disabling User Roles 10-7 Disabling Commands with SQLPLUS -RESTRICT 10-8 iSQL*Plus Security 10-9 Administration Privileges 10-9 Enabling Server Authentication for Users 10-10 Enabling or Disabling Restricted Database Access 10-10 Enabling DBA Access 10-11 Adding Entries to an Oracle HTTP Server Authentication File 10-12 Security Usage Notes 10-13 11 Database Administration with SQL*Plus Overview 11-2 Introduction to Database Startup and Shutdown 11-2 Database Startup 11-2 Database Shutdown 11-3 Redo Log Files 11-4 ARCHIVELOG Mode 11-4 Database Recovery 11-5 12 SQL*Plus Globalization Support Configuring Globalization Support in Command-line SQL*Plus 12-2 Configuring Globalization Support in iSQL*Plus 12-3 x Part III SQL*Plus Reference 13 SQL*Plus Command Reference SQL*Plus Command Summary 13-2 @ (“at” sign) 13-5 @@ (double “at” sign) 13-7 / (slash) 13-9 ACCEPT 13-10 APPEND 13-12 ARCHIVE LOG 13-13 ATTRIBUTE 13-16 BREAK 13-18 BTITLE 13-23 CHANGE 13-24 CLEAR 13-27 COLUMN 13-29 COMPUTE 13-40 CONNECT 13-46 COPY 13-48 DEFINE 13-49 DEL 13-51 DESCRIBE 13-53 DISCONNECT 13-60 EDIT 13-61 EXECUTE 13-63 EXIT 13-64 GET 13-66 HELP 13-68 HOST 13-69 INPUT 13-71 LIST 13-73 PASSWORD 13-75 PAUSE 13-76 PRINT 13-77 PROMPT 13-78 [...]... 13- 120 SET SQLPLUSCOMPAT[IBILITY] {x.y[.z]} 13- 120 SET SQLPRE[FIX] {#|c} 13- 120 SET SQLP[ROMPT] {SQL>|text} 13- 120 SET SQLT[ERMINATOR] {;|c|ON|OFF} 13- 121 SET SUF[FIX] {SQL|text} 13- 121 SET TAB {ON|OFF} 13- 122 SET TERM[OUT] {ON|OFF} 13- 122 SET TI[ME] {ON|OFF} 13- 122 SET TIMI[NG] {ON|OFF} 13- 122 ... Oracle XML DB s Oracle9i Database Globalization Support Guide s Oracle9i Heterogeneous Connectivity Administrator’s Guide s Oracle9i Replication s Oracle9i Database Utilities xxi s Oracle9i Database Error Messages s Oracle9i Database Migration s Oracle9i Database Reference s Oracle9i Database Performance Tuning Guide and Reference s Oracle9i Real Application Clusters Concepts s Oracle9i Net Services Administrator’s... associated with Oracle and SQL*Plus Related Documentation For more information, see these Oracle resources: s SQL*Plus Quick Reference s PL/SQL User s Guide and Reference s Oracle9i SQL Reference s Oracle9i Database Concepts s Oracle9i Database Administrator’s Guide s Oracle9i User- Managed Backup and Recovery Guide s Oracle9i Application Developer’s Guide - Fundamentals s Oracle9i XML Database Developer’s... iSQL*Plus Release 9 .2 is http://machine_name.doman:port/isqlplus You must ensure that any HTML links to iSQL*Plus are updated to the new URL iSQL*Plus Configuration File The format of the iSQL*Plus configuration file, isqlplus.conf, has changed Any user customizations can be manually merged into the default iSQL*Plus Release 9 .2 configuration file On Windows, isqlplus.conf is located in %ORACLE_ HOME% \sqlplus\ admin... migrating to the current release The following sections describe the new features in SQL*Plus: s New Features in SQL*Plus 9 .2 s New Features in iSQL*Plus 9 .2 s Upgrading iSQL*Plus Server from 9.0.1 to 9 .2 s New Features in SQL*Plus 9.0.1 xxix New Features in SQL*Plus 9 .2 SQL*Plus Release 9 .2. 0 is a superset of SQL*Plus 9.0.1 This section describes new features introduced in this release of SQL*Plus XMLType... 13- 122 SET TIMI[NG] {ON|OFF} 13- 122 SET TRIM[OUT] {ON|OFF} 13- 122 SET TRIMS[POOL] {ON|OFF} 13- 123 SET UND[ERLINE] {-|c|ON|OFF} 13- 123 SET VER[IFY] {ON|OFF} 13- 123 SET WRA[P] {ON|OFF} 13- 123 SHOW 13- 124 SHUTDOWN 13- 129 xii SPOOL START STARTUP STORE... UNIX, isqlplus.conf is located in $ORACLE_ HOME /sqlplus/ admin iSQL*Plus Release 9.0.1 Parameters There were two parameters that could be configured in iSQL*Plus Release 9.0.1 s s iSQLPlusTimeOut This parameter has been removed Expiry is now always enabled iSQLPlusTimeOutInterval The new default value is 30 minutes This directive is now a parameter to the FastCgiServer directive iSQL*Plus Release 9 .2 Parameters... Release 9 .2 Parameters There are several new parameters for sizing and tuning iSQL*Plus Release 9 .2 You can edit the isqlplus.conf configuration file directly to change settings for iSQL*Plus Server parameter settings: s s iSQLPlusLogLevel s xxxiv iSQLPlusNumberOfThreads iSQLPlusTimeOutInterval s iSQLPlusHashTableSize s iSQLPlusConnectIdList s -idle-timeout For information about these parameters, see "Configuring... to retrieve XMLType data See Also: s "DESCRIBE" on page 13-53 s "SET LONG {80|n}" on page 13-1 12 s "SET LONGC[HUNKSIZE] {80|n}" on page 13-1 12 s "Formatting Datatypes" on page 7-5 SQLPLUS -L Argument There is a new command-line argument for the SQLPLUS command, SQLPLUS -L which specifies not to reprompt for username or password if the initial connection does not succeed This can be useful in operating-system... SELECT username FROM dba_users WHERE username = ’MIGRATE’; Code examples illustrate SQL, PL/SQL, SQL*Plus, or other command-line statements If users are expected to type them into the system, they are identified by the keyboard icon shown in the margin following They are displayed in a monospace (fixed-width) font and separated from normal text as shown in this example: SELECT username FROM dba_users . SQL*Plus User s Guide and Reference Release 9 .2 March 20 02 Part No. A908 42- 01 SQL*Plus User s Guide and Reference, Release 9 .2 Part No. A908 42- 01 Copyright © 1996, 20 02 Oracle Corporation 13- 122 SET TERM[OUT] {ON |OFF} 13- 122 SET TI[ME] {ON|OFF } 13- 122 SET TIMI[NG] {ON|OFF} 13- 122 SET TRIM[OUT] {ON |OFF} 13- 122 SET TRIMS[POOL] {ON|OFF } 13- 123 SET UND[ERLINE] {- |c|ON|OFF} 13- 123 SET. Tables 1-7 2 SQL*Plus User Interface SQL*Plus Command-line User Interface 2- 2 The Command-line Screen 2- 2 iSQL*Plus User Interface 2- 3 iSQL*Plus Navigation 2- 3 iSQL*Plus Login Screen 2- 4 iSQL*Plus