1. Trang chủ
  2. » Công Nghệ Thông Tin

oracle and sql manual

394 411 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 394
Dung lượng 2,99 MB

Nội dung

SQL*Plus® User’s Guide and Reference Release 8.1.6 October, 1999 Part No. A75664-01 SQL*Plus User’s Guide and Reference, Release 8.1.6 Part No. A75664-01 Copyright © 1996, 1999, Oracle Corporation. All rights reserved. Contributing Authors: Larry Baer, Lisa Colston, Roland Kovacs, Karen Denchfield-Masterson, Alison Holloway, Sanjeev Jhala, Christopher Jones, Anita Lam, Nimish Mehta, Luan Nim, Bud Osterberg, Irene Paradisis, Richard Rendell, Frank Rovitto, Farokh Shapoorjee, Larry Stevens, Andre Touma, Simon Watt 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 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, back up, redundancy, and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle disclaims liability for any damages caused by such use of the Programs. Oracle is a registered trademark, and JDeveloper, Oracle Designer, Oracle Developer, Oracle Discoverer, Oracle7, Oracle8, Oracle8i, Oracle Media Objects, Oracle Mobile Agents, Oracle Application Server, PL/SQL, Oracle Programmer, SQL*Forms, Net8 and SQL*Plus are trademarks or registered trademarks of Oracle Corporation. All other company or product names mentioned are used for identification purposes only and may be trademarks of their respective owners. iii Contents Send Us Your Comments xi Preface xiii Part I Understanding SQL*Plus 1 Introduction Overview of SQL*Plus 1-2 Basic Concepts 1-2 Who Can Use SQL*Plus 1-2 Other Ways of Working with Oracle 1-3 Using this Guide 1-4 Conventions for Command Syntax 1-4 Sample Tables 1-5 What You Need to Run SQL*Plus 1-6 Hardware and Software 1-6 Information Specific to Your Operating System 1-7 Username and Password 1-7 Access to Sample Tables 1-8 2 Learning SQL*Plus Basics Getting Started 2-2 Using the Keyboard 2-2 Starting SQL*Plus 2-3 iv Leaving SQL*Plus 2-4 Entering and Executing Commands 2-5 Running SQL Commands 2-6 Running PL/SQL Blocks 2-10 Running SQL*Plus Commands 2-11 Variables that Affect Running Commands 2-13 Saving Changes to the Database Automatically 2-13 Stopping a Command while it is Running 2-15 Collecting Timing Statistics on Commands You Run 2-15 Running Host Operating System Commands 2-15 Getting Help 2-16 Listing a Table Definition 2-16 Listing PL/SQL Definitions 2-17 Controlling the Display 2-17 Interpreting Error Messages 2-17 3 Manipulating Commands Editing Commands 3-2 Listing the Buffer Contents 3-3 Editing the Current Line 3-4 Adding a New Line 3-5 Appending Text to a Line 3-6 Deleting Lines 3-7 Editing Commands with a System Editor 3-8 Saving Commands for Later Use 3-8 Storing Commands in Command Files 3-8 Placing Comments in Command Files 3-12 Retrieving Command Files 3-13 Running Command Files 3-14 Nesting Command Files 3-16 Modifying Command Files 3-16 Exiting from a Command File with a Return Code 3-17 Setting Up Your SQL*Plus Environment 3-17 Storing and Restoring SQL*Plus System Variables 3-18 Writing Interactive Commands 3-19 v Defining User Variables 3-20 Using Substitution Variables 3-20 Passing Parameters through the START Command 3-25 Communicating with the User 3-27 Using Bind Variables 3-30 Creating Bind Variables 3-30 Referencing Bind Variables 3-31 Displaying Bind Variables 3-31 Using REFCURSOR Bind Variables 3-32 Tracing Statements 3-35 Controlling the Report 3-35 Execution Plan 3-36 Statistics 3-37 Tracing Parallel and Distributed Queries 3-39 4 Formatting Query Results Formatting Columns 4-2 Changing Column Headings 4-2 Formatting NUMBER Columns 4-4 Formatting Datatypes 4-6 Copying Column Display Attributes 4-8 Listing and Resetting Column Display Attributes 4-9 Suppressing and Restoring Column Display Attributes 4-9 Printing a Line of Characters after Wrapped Column Values 4-10 Clarifying Your Report with Spacing and Summary Lines 4-11 Suppressing Duplicate Values in Break Columns 4-12 Inserting Space when a Break Column’s Value Changes 4-13 Inserting Space after Every Row 4-14 Using Multiple Spacing Techniques 4-14 Listing and Removing Break Definitions 4-15 Computing Summary Lines when a Break Column’s Value Changes 4-16 Computing Summary Lines at the End of the Report 4-20 Computing Multiple Summary Values and Lines 4-21 Listing and Removing COMPUTE Definitions 4-22 Defining Page and Report Titles and Dimensions 4-23 vi Setting the Top and Bottom Titles and Headers and Footers 4-23 Displaying the Page Number and other System-Maintained Values in Titles 4-28 Listing, Suppressing, and Restoring Page Title Definitions 4-29 Displaying Column Values in Titles 4-30 Displaying the Current Date in Titles 4-32 Setting Page Dimensions 4-32 Storing and Printing Query Results 4-35 Sending Results to a File 4-36 Sending Results to a Printer 4-36 Creating Web Reports 4-38 Creating Web Reports Interactively 4-38 HTML Entities 4-42 Creating Embedded Web Reports 4-42 Suppressing the Display of SQL*Plus Commands in Web Reports 4-45 5 Database Administration Overview 5-2 Introduction to Database Startup and Shutdown 5-2 Database Startup 5-2 Database Shutdown 5-3 Redo Log Files 5-4 ARCHIVELOG Mode 5-4 Database Recovery 5-5 6 Accessing SQL Databases Connecting to the Default Database 6-2 Connecting to a Remote Database 6-2 Connecting to a Remote Database from within SQL*Plus 6-3 Connecting to a Remote Database as You Start SQL*Plus 6-3 Copying Data from One Database to Another 6-4 Understanding COPY Command Syntax 6-4 Controlling Treatment of the Destination Table 6-6 Interpreting the Messages that COPY Displays 6-8 Specifying Another User’s Table 6-8 Copying Data between Tables on One Database 6-8 vii Part II Reference 7 Starting SQL*Plus and Getting Help Starting SQL*Plus Using the SQLPLUS Command 7-2 Setting Up the Site Profile 7-8 Setting Up the User Profile 7-8 Getting Help 7-10 8 Command Reference SQL*Plus Command Summary 8-2 @ ("at" sign) 8-5 @@ (double "at" sign) 8-7 / (slash) 8-9 ACCEPT 8-10 APPEND 8-12 ARCHIVE LOG 8-14 ATTRIBUTE 8-18 BREAK 8-20 BTITLE 8-25 CHANGE 8-26 CLEAR 8-29 COLUMN 8-31 COMPUTE 8-41 CONNECT 8-47 COPY 8-49 DEFINE 8-52 DEL 8-54 DESCRIBE 8-56 DISCONNECT 8-63 EDIT 8-64 EXECUTE 8-66 EXIT 8-67 GET 8-69 HELP 8-70 viii HOST 8-71 INPUT 8-72 LIST 8-74 PASSWORD 8-76 PAUSE 8-77 PRINT 8-78 PROMPT 8-79 RECOVER 8-81 REMARK 8-87 REPFOOTER 8-88 REPHEADER 8-90 RUN 8-94 SAVE 8-95 SET 8-97 SHOW 8-124 SHUTDOWN 8-129 SPOOL 8-131 START 8-132 STARTUP 8-134 STORE 8-138 TIMING 8-139 TTITLE 8-141 UNDEFINE 8-145 VA R I A B LE 8-146 WHENEVER OSERROR 8-152 WHENEVER SQLERROR 8-154 ix A COPY Command Messages and Codes B Release 8.1.6 Enhancements C SQL*Plus Limits D SQL Command List E Security F Obsolete SQL*Plus Commands Glossary Index x [...]... the command and re-displays the command prompt, indicating that you can enter another command Running SQL Commands The SQL command language enables you to manipulate data in the database See your Oracle8 i SQL Reference for information on individual SQL commands Example 2–3 Entering a SQL Command In this example, you will enter and execute a SQL command to display the employee number, name, job, and salary... publications: s s PL /SQL User’s Guide and Reference s Oracle8 i SQL Reference s Oracle8 i Concepts s Oracle8 i Administrator’s Guide s Oracle8 i Backup and Recovery Guide s Oracle8 i Application Developer’s Guide - Fundamentals s Oracle8 i Distributed Database Systems s Oracle8 i Replication s Oracle8 i Utilities s Oracle8 i Error Messages s Oracle8 i Migration s Oracle8 i Reference s Oracle8 i Designing and Tuning for... the maximum values for elements of SQL* Plus Appendix C SQL Command List Provides a list of major SQL commands and clauses Appendix D Security Explains how to restrict access to certain SQL* Plus and SQL commands Appendix E Obsolete SQL* Plus Commands Provides information on Obsolete SQL* Plus commands Appendix F Glossary Defines technical terms associated with Oracle and SQL* Plus Glossary xv Related Publications... details Leaving SQL* Plus When you are done working with SQL* Plus and wish to return to the operating system, enter the EXIT command at the SQL* Plus command prompt Example 2–2 Exiting SQL* Plus To leave SQL* Plus, enter the EXIT command at the SQL* Plus command prompt: SQL> EXIT SQL* Plus displays the version of Oracle from which you disconnected and the versions of tools available through SQL* Plus After... 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 s s enter, edit, store, retrieve, and run SQL commands and PL /SQL blocks format, perform calculations on, store, print and create web output of query results s list column definitions for any table s access and copy data... and editing and storing SQL commands and PL /SQL blocks The manner in which you continue a command on additional lines, end a command, or execute a command differs depending on the type of command you wish to enter and run Examples of how to run and execute these types of commands are found on the following pages Getting Help To get online help for SQL* Plus commands, type HELP at the command prompt followed... username and password is called logging in SQL* Plus displays the version of Oracle to which you connected and the versions of available tools such as PL /SQL Next, SQL* Plus displays the SQL* Plus command prompt: SQL> The command prompt indicates that SQL* Plus is ready to accept your commands If SQL* Plus does not start, you should see a message to help you correct the problem Shortcuts to Starting SQL* Plus... 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... data between SQL databases s send messages to and accept responses from an end user s perform database administration Basic Concepts The following definitions explain concepts central to SQL* Plus: command An instruction you give SQL* Plus or Oracle block A group of SQL and PL /SQL commands related to one another through procedural logic table The basic unit of storage in Oracle query A SQL command (specifically,... introduces you to SQL* Plus, covering the following topics: s Overview of SQL* Plus s Using this Guide s What You Need to Run SQL* Plus Introduction 1-1 Overview of SQL* Plus 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 . Programs. Oracle is a registered trademark, and JDeveloper, Oracle Designer, Oracle Developer, Oracle Discoverer, Oracle7 , Oracle8 , Oracle8 i, Oracle Media Objects, Oracle Mobile Agents, Oracle. elements of SQL* Plus. Appendix C SQL Command List Provides a list of major SQL commands and clauses. Appendix D Security Explains how to restrict access to certain SQL* Plus and SQL commands. Appendix. publications: ■ SQL* Plus Quick Reference ■ PL /SQL User’s Guide and Reference ■ Oracle8 i SQL Reference ■ Oracle8 i Concepts ■ Oracle8 i Administrator’s Guide ■ Oracle8 i Backup and Recovery Guide ■ Oracle8 i

Ngày đăng: 07/04/2014, 15:50