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

Oracle® Database SQL Reference ppt

1,4K 1,8K 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 1.428
Dung lượng 11,87 MB

Nội dung

Oracle® Database SQL Reference 10g Release 2 (10.2) B14200-02 December 2005 Oracle Database SQL Reference, 10g Release 2 (10.2) B14200-02 Copyright © 1996, 2005 Oracle. All rights reserved. Primary Author: Diana Lorentz Contributor: Special thanks to Lex de Haan, who has for over ten years been a great source of information and inspiration in the management of this book. Contributors: Sundeep Abraham, Drew Adams, Patrick Amor, Geeta Arora, Lance Ashdown, Hermann Baer, Vladimir Barriere, Subhransu Basu, Mark Bauer, Tammy Bednar, Eric Belden, Tolga Bozkaya, Bill Bridge, Allen Brumm, Mark Callaghan, Thomas Chang, Timothy Chien, Dinesh Das, Jay Davison, Steve Fogel, Amit Ganesh, John Haydu, Min-Hank Ho, Lilian Hobbs, Chandrasekharan Iyer, Ken Jacobs, Bob Jenkins, Ramkumar Krishnan, Muralidhar Krishnaprasad, Joydip Kundu, Paul Lane, Simon Law, Bill Lee, Geoff Lee, Jeff Levinger, Nina Lewis, Brian Lin, Peter Linsley, Zhen Liu, Bryn Llewellyn, Rich Long, Qianrong Ma, Anand Manikutty, Paul Manning, Robert McGuirk, Jim Melton, Mughees Minhas, Michael Möller, Daniel Morgan, Ari Mozes, Niloy Mukherjee, Chuck Murray, Sujatha Muthulingam, Ananth Raghavan, Kathy Rich, Antonio Romero, John Russell, Vivian Schupmann, Cathy Shea, Vikram Shukla, Bipul Sinha, Mike Stewart, Sankar Subramanian, Srividya Tata, Kathy Taylor, Barry Trute, Randy Urbano, Rama Vissapragada, Douglas Voss, Daniel Wong, Jianping Yang, Adiel Yoaz, Qin Yu, Tsae-Feng Yu, Fred Zemke, Weiran Zhang The Programs (which include both the software and documentation) contain proprietary information; 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. This document is not warranted to be 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. If the Programs are delivered to the United States Government or anyone licensing or using the Programs on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement, and, to the extent applicable, the additional rights set forth 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 we disclaim liability for any damages caused by such use of the Programs. Oracle, JD Edwards, PeopleSoft, and Retek are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. The Programs may provide links to Web sites and access to content, products, and services from third parties. Oracle is not responsible for the availability of, or any content provided on, third-party Web sites. You bear all risks associated with the use of such content. If you choose to purchase any products or services from a third party, the relationship is directly between you and the third party. Oracle is not responsible for: (a) the quality of third-party products or services; or (b) fulfilling any of the terms of the agreement with the third party, including delivery of products or services and warranty obligations related to purchased products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from dealing with any third party. iii Contents Preface xxi Intended Audience xxi Documentation Accessibility xxi Related Documents xxii Conventions xxii What's New in the SQL Reference? xxiii Oracle Database 10g Release 2 New Features in the SQL Reference xxiii Oracle Database 10g Release 1 New Features in the SQL Reference xxv 1 Introduction to Oracle SQL History of SQL 1-1 SQL Standards 1-1 How SQL Works 1-2 Common Language for All Relational Databases 1-3 Recent Enhancements 1-3 Lexical Conventions 1-3 Tools Support 1-4 2 Basic Elements of Oracle SQL Datatypes 2-1 Oracle Built-in Datatypes 2-6 CHAR Datatype 2-8 NCHAR Datatype 2-9 NVARCHAR2 Datatype 2-9 VARCHAR2 Datatype 2-9 VARCHAR Datatype 2-10 NUMBER Datatype 2-10 Floating-Point Numbers 2-11 BINARY_FLOAT 2-12 BINARY_DOUBLE 2-12 Numeric Precedence 2-13 DATE Datatype 2-16 Using Julian Days 2-16 TIMESTAMP Datatype 2-17 iv TIMESTAMP WITH TIME ZONE Datatype 2-17 TIMESTAMP WITH LOCAL TIME ZONE Datatype 2-18 INTERVAL YEAR TO MONTH Datatype 2-18 INTERVAL DAY TO SECOND Datatype 2-19 Datetime/Interval Arithmetic 2-19 Support for Daylight Saving Times 2-21 Datetime and Interval Examples 2-22 RAW and LONG RAW Datatypes 2-23 BFILE Datatype 2-26 BLOB Datatype 2-26 CLOB Datatype 2-27 NCLOB Datatype 2-27 Restricted Rowids 2-27 Extended Rowids 2-28 Compatibility and Migration 2-28 UROWID Datatype 2-28 ANSI, DB2, and SQL/DS Datatypes 2-29 User-Defined Types 2-30 Object Types 2-30 REF Datatypes 2-31 Varrays 2-31 Nested Tables 2-31 Oracle-Supplied Types 2-32 Any Types 2-32 ANYTYPE 2-32 ANYDATA 2-32 ANYDATASET 2-32 XML Types 2-33 XMLType 2-33 URI Datatypes 2-33 URIFactory Package 2-34 Spatial Types 2-34 SDO_GEOMETRY 2-35 SDO_TOPO_GEOMETRY 2-35 SDO_GEORASTER 2-35 Media Types 2-35 ORDAudio 2-36 ORDImage 2-36 ORDImageSignature 2-36 ORDVideo 2-36 ORDDoc 2-36 SI_StillImage 2-36 SI_Color 2-36 SI_AverageColor 2-36 SI_ColorHistogram 2-36 SI_PositionalColor 2-36 SI_Texture 2-36 v SI_FeatureList 2-37 Expression Filter Type 2-37 Expression 2-37 Datatype Comparison Rules 2-37 Numeric Values 2-37 Date Values 2-37 Character Values 2-37 Object Values 2-40 Varrays and Nested Tables 2-40 Data Conversion 2-40 Implicit and Explicit Data Conversion 2-40 Implicit Data Conversion 2-41 Implicit Data Conversion Examples 2-43 Explicit Data Conversion 2-43 Literals 2-44 Text Literals 2-45 Numeric Literals 2-46 Integer Literals 2-46 NUMBER and Floating-Point Literals 2-47 Datetime Literals 2-49 Interval Literals 2-51 INTERVAL YEAR TO MONTH 2-52 INTERVAL DAY TO SECOND 2-53 Format Models 2-54 Number Format Models 2-55 Number Format Elements 2-56 Datetime Format Models 2-58 Datetime Format Elements 2-59 Uppercase Letters in Date Format Elements 2-59 Punctuation and Character Literals in Datetime Format Models 2-59 Datetime Format Elements and Globalization Support 2-62 ISO Standard Date Format Elements 2-62 The RR Datetime Format Element 2-63 RR Datetime Format Examples 2-63 Datetime Format Element Suffixes 2-64 Format Model Modifiers 2-64 Format Model Examples 2-65 String-to-Date Conversion Rules 2-67 XML Format Model 2-67 Nulls 2-68 Nulls in SQL Functions 2-69 Nulls with Comparison Conditions 2-69 Nulls in Conditions 2-69 Comments 2-70 Comments Within SQL Statements 2-70 Comments on Schema Objects 2-71 Using Hints 2-71 vi Alphabetical Listing of Hints 2-75 ALL_ROWS Hint 2-75 APPEND Hint 2-75 CACHE Hint 2-76 CLUSTER Hint 2-76 CURSOR_SHARING_EXACT Hint 2-76 DRIVING_SITE Hint 2-77 DYNAMIC_SAMPLING Hint 2-77 FACT Hint 2-78 FIRST_ROWS Hint 2-78 FULL Hint 2-78 HASH Hint 2-79 INDEX Hint 2-79 INDEX_ASC Hint 2-80 INDEX_COMBINE Hint 2-80 INDEX_DESC Hint 2-80 INDEX_FFS Hint 2-81 INDEX_JOIN Hint 2-81 INDEX_SS Hint 2-81 INDEX_SS_ASC Hint 2-82 INDEX_SS_DESC Hint 2-82 LEADING Hint 2-83 MERGE Hint 2-83 MODEL_MIN_ANALYSIS Hint 2-83 NOAPPEND Hint 2-84 NOCACHE Hint 2-84 NO_EXPAND Hint 2-84 NO_FACT Hint 2-85 NO_INDEX Hint 2-85 NO_INDEX_FFS Hint 2-85 NO_INDEX_SS Hint 2-86 NO_MERGE Hint 2-86 NO_PARALLEL Hint 2-86 NOPARALLEL Hint 2-87 NO_PARALLEL_INDEX Hint 2-87 NOPARALLEL_INDEX Hint 2-87 NO_PUSH_PRED Hint 2-87 NO_PUSH_SUBQ Hint 2-87 NO_PX_JOIN_FILTER Hint 2-88 NO_REWRITE Hint 2-88 NOREWRITE Hint 2-88 NO_QUERY_TRANSFORMATION Hint 2-88 NO_STAR_TRANSFORMATION Hint 2-88 NO_UNNEST Hint 2-88 NO_USE_HASH Hint 2-89 NO_USE_MERGE Hint 2-89 NO_USE_NL Hint 2-89 vii NO_XML_QUERY_REWRITE Hint 2-89 ORDERED Hint 2-90 PARALLEL Hint 2-90 PARALLEL_INDEX Hint 2-91 PQ_DISTRIBUTE Hint 2-91 PUSH_PRED Hint 2-92 PUSH_SUBQ Hint 2-93 PX_JOIN_FILTER Hint 2-93 QB_NAME Hint 2-93 REWRITE Hint 2-94 RULE Hint 2-94 STAR_TRANSFORMATION Hint 2-94 UNNEST Hint 2-95 USE_CONCAT Hint 2-95 USE_HASH Hint 2-96 USE_MERGE Hint 2-96 USE_NL Hint 2-96 USE_NL_WITH_INDEX Hint 2-97 Database Objects 2-97 Schema Objects 2-97 Nonschema Objects 2-98 Schema Object Names and Qualifiers 2-98 Schema Object Naming Rules 2-98 Schema Object Naming Examples 2-101 Schema Object Naming Guidelines 2-102 Syntax for Schema Objects and Parts in SQL Statements 2-102 How Oracle Database Resolves Schema Object References 2-103 Referring to Objects in Other Schemas 2-104 Referring to Objects in Remote Databases 2-104 Creating Database Links 2-104 Database Link Names 2-104 Username and Password 2-105 Database Connect String 2-105 Referring to Database Links 2-105 Referring to Partitioned Tables and Indexes 2-106 Referring to Object Type Attributes and Methods 2-107 3 Pseudocolumns Hierarchical Query Pseudocolumns 3-1 CONNECT_BY_ISCYCLE Pseudocolumn 3-1 CONNECT_BY_ISLEAF Pseudocolumn 3-2 LEVEL Pseudocolumn 3-2 Sequence Pseudocolumns 3-3 Where to Use Sequence Values 3-3 How to Use Sequence Values 3-4 Version Query Pseudocolumns 3-5 COLUMN_VALUE Pseudocolumn 3-6 viii OBJECT_ID Pseudocolumn 3-7 OBJECT_VALUE Pseudocolumn 3-7 ORA_ROWSCN Pseudocolumn 3-8 ROWID Pseudocolumn 3-8 ROWNUM Pseudocolumn 3-9 XMLDATA Pseudocolumn 3-10 4 Operators About SQL Operators 4-1 Unary and Binary Operators 4-2 Operator Precedence 4-2 Arithmetic Operators 4-3 Concatenation Operator 4-3 Hierarchical Query Operators 4-5 PRIOR 4-5 CONNECT_BY_ROOT 4-5 Set Operators 4-5 Multiset Operators 4-5 MULTISET EXCEPT 4-6 MULTISET INTERSECT 4-7 MULTISET UNION 4-8 User-Defined Operators 4-9 5 Functions SQL Functions 5-1 Single-Row Functions 5-3 Numeric Functions 5-3 Character Functions Returning Character Values 5-3 NLS Character Functions 5-4 Character Functions Returning Number Values 5-4 Datetime Functions 5-4 General Comparison Functions 5-5 Conversion Functions 5-5 Large Object Functions 5-6 Collection Functions 5-6 Hierarchical Function 5-6 Data Mining Functions 5-6 XML Functions 5-7 Encoding and Decoding Functions 5-7 NULL-Related Functions 5-7 Environment and Identifier Functions 5-8 Aggregate Functions 5-8 Analytic Functions 5-9 Object Reference Functions 5-14 Model Functions 5-15 Alphabetical Listing of SQL Functions 5-15 ABS 5-15 ix ACOS 5-16 ADD_MONTHS 5-16 APPENDCHILDXML 5-17 ASCIISTR 5-18 ASCII 5-18 ASIN 5-19 ATAN 5-19 ATAN2 5-20 AV G 5-20 BFILENAME 5-21 BIN_TO_NUM 5-22 BITAND 5-23 CARDINALITY 5-24 CAST 5-24 CEIL 5-27 CHARTOROWID 5-27 CHR 5-28 CLUSTER_ID 5-29 CLUSTER_PROBABILITY 5-30 CLUSTER_SET 5-32 COALESCE 5-34 COLLECT 5-35 COMPOSE 5-36 CONCAT 5-36 CONVERT 5-37 CORR 5-38 CORR_* 5-39 CORR_S 5-40 CORR_K 5-41 COS 5-41 COSH 5-42 COUNT 5-42 COVAR_POP 5-44 COVAR_SAMP 5-45 CUME_DIST 5-46 CURRENT_DATE 5-47 CURRENT_TIMESTAMP 5-48 CV 5-49 DBTIMEZONE 5-50 DECODE 5-51 DECOMPOSE 5-52 DELETEXML 5-53 DENSE_RANK 5-54 DEPTH 5-55 DEREF 5-56 DUMP 5-57 EMPTY_BLOB, EMPTY_CLOB 5-58 x EXISTSNODE 5-58 EXP 5-59 EXTRACT (datetime) 5-60 EXTRACT (XML) 5-62 EXTRACTVALUE 5-63 FEATURE_ID 5-63 FEATURE_SET 5-65 FEATURE_VALUE 5-67 FIRST 5-68 FIRST_VALUE 5-70 FLOOR 5-71 FROM_TZ 5-71 GREATEST 5-72 GROUP_ID 5-72 GROUPING 5-73 GROUPING_ID 5-74 HEXTORAW 5-75 INITCAP 5-76 INSERTCHILDXML 5-76 INSERTXMLBEFORE 5-78 INSTR 5-79 ITERATION_NUMBER 5-80 LAG 5-81 LAST 5-82 LAST_DAY 5-83 LAST_VALUE 5-83 LEAD 5-85 LEAST 5-86 LENGTH 5-86 LN 5-87 LNNVL 5-88 LOCALTIMESTAMP 5-89 LOG 5-90 LOWER 5-90 LPAD 5-91 LTRIM 5-91 MAKE_REF 5-92 MAX 5-93 MEDIAN 5-94 MIN 5-96 MOD 5-97 MONTHS_BETWEEN 5-98 NANVL 5-98 NCHR 5-99 NEW_TIME 5-100 NEXT_DAY 5-101 NLS_CHARSET_DECL_LEN 5-101 [...]... latest SQL standard was adopted in July 2003 and is often called SQL: 2003 The formal names of this standard are: ■ ANSI/ISO/IEC 9075:2003, "Database Language SQL" , Parts 1 ( "SQL/ Framework"), 2 ( "SQL/ Foundation"), 3 ( "SQL/ CLI"), 4 ( "SQL/ PSM"), 9 Introduction to Oracle SQL 1-1 SQL Standards ( "SQL/ MED"), 10 ( "SQL/ OLB"), 11 ( "SQL/ Schemata"), 13 ( "SQL/ JRT") and 14 ( "SQL/ XML") ■ ISO/IEC 9075:2003, "Database. .. 9075:2003, "Database Language SQL" , Parts 1 ( "SQL/ Framework"), 2 ( "SQL/ Foundation"), 3 ( "SQL/ CLI"), 4 ( "SQL/ PSM"), 9 ( "SQL/ MED"), 10 ( "SQL/ OLB"), 11 ( "SQL/ Schemata"), 13 ( "SQL/ JRT") and 14 ( "SQL/ XML") Appendix B, "Oracle and Standard SQL" for a detailed description of Oracle Database conformance to the SQL: 2003 standards See Also: At this writing, the next edition of Part 14, SQL/ XML (ISO/IEC 9075-14)... Controlling access to the database and its objects ■ Guaranteeing database consistency and integrity SQL unifies all of the preceding tasks in one consistent language 1-2 Oracle Database SQL Reference Lexical Conventions Common Language for All Relational Databases All major relational database management systems support SQL, so you can transfer all skills you have gained with SQL from one database to another... quarter of 2005 How SQL Works The strengths of SQL provide benefits for all types of users, including application programmers, database administrators, managers, and end users Technically speaking, SQL is a data sublanguage The purpose of SQL is to provide an interface to a relational database such as Oracle Database, and all SQL statements are instructions to the database In this SQL differs from general-purpose... compiling, and debugging PL /SQL applications Oracle HTML DB is a hosted environment for developing and deploying database- related Web applications SQL Workshop is a component of Oracle HTML DB that lets you view and manage database objects from a Web browser SQL Workshop offers quick access to a SQL command processor and a SQL script repository SQL* Plus User's Guide and Reference and Oracle HTML DB... enter What's New in the SQL Reference? This section describes new features of Oracle Database 10g and provides pointers to additional information For information on features that were new in earlier versions of Oracle Database, please refer to the documentation for the earlier release Oracle Database 10g Release 2 New Features in the SQL Reference The following top-level SQL statements are new or... Database Objects B Oracle and Standard SQL ANSI Standards ISO Standards Oracle Compliance To Core SQL: 2003 Oracle Support for Optional Features of SQL/ Foundation:2003 Oracle Compliance with SQL/ CLI:2003 Oracle Compliance with SQL/ PSM:2003 Oracle Compliance with SQL/ MED:2003 Oracle Compliance with SQL/ XML:2005... users access to the database without using SQL directly, but these applications in turn must use SQL when executing the user's request This chapter provides background information on SQL as used by most database systems This chapter contains these topics: ■ History of SQLSQL Standards ■ Recent Enhancements ■ Lexical Conventions ■ Tools Support History of SQL Dr E F Codd published the paper, "A Relational... Documents For more information, see these Oracle resources: ■ ■ Oracle Database PL /SQL User's Guide and Reference for information on PL /SQL, the procedural language extension to Oracle SQL Pro*C/C++ Programmer's Guide, Oracle SQL* Module for Ada Programmer's Guide, and the Pro*COBOL Programmer's Guide for detailed descriptions of Oracle embedded SQL Many of the examples in this book use the sample schemas, which... from one database to another In addition, all programs written in SQL are portable They can often be moved from one database to another with very little modification Recent Enhancements The Oracle Database SQL engine is the underpinning of all Oracle Database applications Oracle SQL continually evolves to meet the growing demands of database applications and to support emerging computing architectures, . the SQL Reference? xxiii Oracle Database 10g Release 2 New Features in the SQL Reference xxiii Oracle Database 10g Release 1 New Features in the SQL Reference. Oracle® Database SQL Reference 10g Release 2 (10.2) B14200-02 December 2005 Oracle Database SQL Reference, 10g Release 2 (10.2)

Ngày đăng: 23/03/2014, 16:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w