
- •Contents
- •Send Us Your Comments
- •Preface
- •What’s New in SQL Reference?
- •1 Introduction to Oracle SQL
- •History of SQL
- •SQL Standards
- •Embedded SQL
- •Lexical Conventions
- •Tools Support
- •2 Basic Elements of Oracle SQL
- •Datatypes
- •Oracle Built-in Datatypes
- •ANSI, DB2, and SQL/DS Datatypes
- •Oracle-Supplied Types
- •"Any" Types
- •XML Types
- •Spatial Type
- •Media Types
- •Datatype Comparison Rules
- •Data Conversion
- •Literals
- •Text Literals
- •Integer Literals
- •Number Literals
- •Interval Literals
- •Format Models
- •Number Format Models
- •Date Format Models
- •String-to-Date Conversion Rules
- •XML Format Model
- •Nulls
- •Nulls in SQL Functions
- •Nulls with Comparison Conditions
- •Nulls in Conditions
- •Pseudocolumns
- •CURRVAL and NEXTVAL
- •LEVEL
- •ROWID
- •ROWNUM
- •XMLDATA
- •Comments
- •Comments Within SQL Statements
- •Comments on Schema Objects
- •Hints
- •Database Objects
- •Schema Objects
- •Nonschema Objects
- •Parts of Schema Objects
- •Schema Object Names and Qualifiers
- •Schema Object Naming Rules
- •Schema Object Naming Examples
- •Schema Object Naming Guidelines
- •Syntax for Schema Objects and Parts in SQL Statements
- •How Oracle Resolves Schema Object References
- •Referring to Objects in Other Schemas
- •Referring to Objects in Remote Databases
- •Referencing Object Type Attributes and Methods
- •3 Operators
- •About SQL Operators
- •Unary and Binary Operators
- •Operator Precedence
- •Arithmetic Operators
- •Concatenation Operator
- •Set Operators
- •4 Expressions
- •About SQL Expressions
- •Simple Expressions
- •Compound Expressions
- •CASE Expressions
- •CURSOR Expressions
- •Datetime Expressions
- •Function Expressions
- •INTERVAL Expressions
- •Object Access Expressions
- •Scalar Subquery Expressions
- •Type Constructor Expressions
- •Variable Expressions
- •Expression Lists
- •5 Conditions
- •About SQL Conditions
- •Condition Precedence
- •Comparison Conditions
- •Simple Comparison Conditions
- •Group Comparison Conditions
- •Logical Conditions
- •Membership Conditions
- •Range Conditions
- •Null Conditions
- •EQUALS_PATH
- •EXISTS Conditions
- •LIKE Conditions
- •IS OF type Conditions
- •UNDER_PATH
- •Compound Conditions
- •6 Functions
- •SQL Functions
- •Single-Row Functions
- •Aggregate Functions
- •Analytic Functions
- •Object Reference Functions
- •Alphabetical Listing of SQL Functions
- •ACOS
- •ADD_MONTHS
- •ASCII
- •ASCIISTR
- •ASIN
- •ATAN
- •ATAN2
- •BFILENAME
- •BITAND
- •CAST
- •CEIL
- •CHARTOROWID
- •COALESCE
- •COMPOSE
- •CONCAT
- •CONVERT
- •CORR
- •COSH
- •COUNT
- •COVAR_POP
- •COVAR_SAMP
- •CUME_DIST
- •CURRENT_DATE
- •CURRENT_TIMESTAMP
- •DBTIMEZONE
- •DECODE
- •DECOMPOSE
- •DENSE_RANK
- •DEPTH
- •DEREF
- •DUMP
- •EMPTY_BLOB, EMPTY_CLOB
- •EXISTSNODE
- •EXTRACT (datetime)
- •EXTRACT (XML)
- •EXTRACTVALUE
- •FIRST
- •FIRST_VALUE
- •FLOOR
- •FROM_TZ
- •GREATEST
- •GROUP_ID
- •GROUPING
- •GROUPING_ID
- •HEXTORAW
- •INITCAP
- •INSTR
- •LAST
- •LAST_DAY
- •LAST_VALUE
- •LEAD
- •LEAST
- •LENGTH
- •LOCALTIMESTAMP
- •LOWER
- •LPAD
- •LTRIM
- •MAKE_REF
- •MONTHS_BETWEEN
- •NCHR
- •NEW_TIME
- •NEXT_DAY
- •NLS_CHARSET_DECL_LEN
- •NLS_CHARSET_ID
- •NLS_CHARSET_NAME
- •NLS_INITCAP
- •NLS_LOWER
- •NLSSORT
- •NLS_UPPER
- •NTILE
- •NULLIF
- •NUMTODSINTERVAL
- •NUMTOYMINTERVAL
- •PATH
- •PERCENT_RANK
- •PERCENTILE_CONT
- •PERCENTILE_DISC
- •POWER
- •RANK
- •RATIO_TO_REPORT
- •RAWTOHEX
- •RAWTONHEX
- •REFTOHEX
- •REGR_ (Linear Regression) Functions
- •REPLACE
- •ROUND (number)
- •ROUND (date)
- •ROW_NUMBER
- •ROWIDTOCHAR
- •ROWIDTONCHAR
- •RPAD
- •RTRIM
- •SESSIONTIMEZONE
- •SIGN
- •SINH
- •SOUNDEX
- •SQRT
- •STDDEV
- •STDDEV_POP
- •STDDEV_SAMP
- •SUBSTR
- •SYS_CONNECT_BY_PATH
- •SYS_CONTEXT
- •SYS_DBURIGEN
- •SYS_EXTRACT_UTC
- •SYS_GUID
- •SYS_TYPEID
- •SYS_XMLAGG
- •SYS_XMLGEN
- •SYSDATE
- •SYSTIMESTAMP
- •TANH
- •TO_CHAR (character)
- •TO_CHAR (datetime)
- •TO_CHAR (number)
- •TO_CLOB
- •TO_DATE
- •TO_DSINTERVAL
- •TO_MULTI_BYTE
- •TO_NCHAR (character)
- •TO_NCHAR (datetime)
- •TO_NCHAR (number)
- •TO_NCLOB
- •TO_NUMBER
- •TO_SINGLE_BYTE
- •TO_TIMESTAMP
- •TO_TIMESTAMP_TZ
- •TO_YMINTERVAL
- •TRANSLATE
- •TRANSLATE ... USING
- •TREAT
- •TRIM
- •TRUNC (number)
- •TRUNC (date)
- •TZ_OFFSET
- •UNISTR
- •UPDATEXML
- •UPPER
- •USER
- •USERENV
- •VALUE
- •VAR_SAMP
- •VARIANCE
- •VSIZE
- •WIDTH_BUCKET
- •XMLAGG
- •XMLCOLATTVAL
- •XMLCONCAT
- •XMLELEMENT
- •XMLFOREST
- •XMLSEQUENCE
- •XMLTRANSFORM
- •ROUND and TRUNC Date Functions
- •User-Defined Functions
- •Prerequisites
- •Name Precedence
- •7 Common SQL DDL Clauses
- •allocate_extent_clause
- •constraints
- •deallocate_unused_clause
- •file_specification
- •logging_clause
- •parallel_clause
- •physical_attributes_clause
- •storage_clause
- •8 SQL Queries and Subqueries
- •About Queries and Subqueries
- •Creating Simple Queries
- •Hierarchical Queries
- •The UNION [ALL], INTERSECT, MINUS Operators
- •Sorting Query Results
- •Joins
- •Using Subqueries
- •Unnesting of Nested Subqueries
- •Selecting from the DUAL Table
- •Distributed Queries
- •9 SQL Statements: ALTER CLUSTER to ALTER SEQUENCE
- •Types of SQL Statements
- •Organization of SQL Statements
- •ALTER CLUSTER
- •ALTER DATABASE
- •ALTER DIMENSION
- •ALTER FUNCTION
- •ALTER INDEX
- •ALTER INDEXTYPE
- •ALTER JAVA
- •ALTER MATERIALIZED VIEW
- •ALTER MATERIALIZED VIEW LOG
- •ALTER OPERATOR
- •ALTER OUTLINE
- •ALTER PACKAGE
- •ALTER PROCEDURE
- •ALTER PROFILE
- •ALTER RESOURCE COST
- •ALTER ROLE
- •ALTER ROLLBACK SEGMENT
- •ALTER SEQUENCE
- •10 SQL Statements: ALTER SESSION to ALTER SYSTEM
- •ALTER SESSION
- •ALTER SYSTEM
- •ALTER TABLE
- •ALTER TABLESPACE
- •ALTER TRIGGER
- •ALTER TYPE
- •ALTER USER
- •ALTER VIEW
- •ANALYZE
- •ASSOCIATE STATISTICS
- •AUDIT
- •CALL
- •COMMENT
- •COMMIT
- •13 SQL Statements: CREATE CLUSTER to CREATE JAVA
- •CREATE CLUSTER
- •CREATE CONTEXT
- •CREATE CONTROLFILE
- •CREATE DATABASE
- •CREATE DATABASE LINK
- •CREATE DIMENSION
- •CREATE DIRECTORY
- •CREATE FUNCTION
- •CREATE INDEX
- •CREATE INDEXTYPE
- •CREATE JAVA
- •14 SQL Statements: CREATE LIBRARY to CREATE SPFILE
- •CREATE LIBRARY
- •CREATE MATERIALIZED VIEW
- •CREATE MATERIALIZED VIEW LOG
- •CREATE OPERATOR
- •CREATE OUTLINE
- •CREATE PACKAGE
- •CREATE PACKAGE BODY
- •CREATE PFILE
- •CREATE PROCEDURE
- •CREATE PROFILE
- •CREATE ROLE
- •CREATE ROLLBACK SEGMENT
- •CREATE SCHEMA
- •CREATE SEQUENCE
- •CREATE SPFILE
- •15 SQL Statements: CREATE SYNONYM to CREATE TRIGGER
- •CREATE SYNONYM
- •CREATE TABLE
- •CREATE TABLESPACE
- •CREATE TEMPORARY TABLESPACE
- •CREATE TRIGGER
- •CREATE TYPE
- •CREATE TYPE BODY
- •CREATE USER
- •CREATE VIEW
- •DELETE
- •DISASSOCIATE STATISTICS
- •DROP CLUSTER
- •DROP CONTEXT
- •DROP DATABASE LINK
- •DROP DIMENSION
- •DROP DIRECTORY
- •DROP FUNCTION
- •DROP INDEX
- •DROP INDEXTYPE
- •DROP JAVA
- •DROP LIBRARY
- •DROP MATERIALIZED VIEW
- •DROP MATERIALIZED VIEW LOG
- •DROP OPERATOR
- •DROP OUTLINE
- •DROP PACKAGE
- •DROP PROCEDURE
- •DROP PROFILE
- •DROP ROLE
- •DROP ROLLBACK SEGMENT
- •17 SQL Statements: DROP SEQUENCE to ROLLBACK
- •DROP SEQUENCE
- •DROP SYNONYM
- •DROP TABLE
- •DROP TABLESPACE
- •DROP TRIGGER
- •DROP TYPE
- •DROP TYPE BODY
- •DROP USER
- •DROP VIEW
- •EXPLAIN PLAN
- •GRANT
- •INSERT
- •LOCK TABLE
- •MERGE
- •NOAUDIT
- •RENAME
- •REVOKE
- •ROLLBACK
- •18 SQL Statements: SAVEPOINT to UPDATE
- •SAVEPOINT
- •SELECT
- •SET CONSTRAINT[S]
- •SET ROLE
- •SET TRANSACTION
- •TRUNCATE
- •UPDATE
- •Required Keywords and Parameters
- •Optional Keywords and Parameters
- •Syntax Loops
- •Multipart Diagrams
- •Database Objects
- •ANSI Standards
- •ISO Standards
- •Oracle Compliance
- •FIPS Compliance
- •Oracle Extensions to Standard SQL
- •Character Set Support
- •Using Extensible Indexing
- •Using XML in SQL Statements
- •Index

Oracle9i
SQL Reference
Release 2 (9.2)
October 2002
Part No. A96540-02

Oracle9i SQL Reference, Release 2 (9.2)
Part No. A96540-02
Copyright © 2000, 2002 Oracle Corporation. All rights reserved.
Primary Author: Diana Lorentz
Contributing Author: Joan Gregoire
Contributors: Sundeep Abraham, Nipun Agarwal, Dave Alpern, Angela Amor, Patrick Amor, Rick Anderson, Vikas Arora, Lance Ashdown, Hermann Baer, Subhransu Basu, Ruth Baylis, Paula Bingham, Rae Burns, Yujie Cao, Larry Carpenter, Sivasankaran Chandrasekar, Thomas Chang, Tim Chorma, Lex de Haan, Norbert Debes, George Eadon, Bill Gietz, Ray Guzman, John Haydu, Lilian Hobbs, Jiansheng Huang, Ken Jacobs, Archna Johnson, Vishy Karra, Thomas Keefe, Susan Kotsovolos, Muralidhar Krishnaprasad, Goutam Kulkarni, Paul Lane, Shilpa Lawande, Geoff Lee, Yunrui Li, Lenore Luscher, Kevin MacDowell, Anand Manikutty, Vineet Marwah, Steve McGee, Bill McGuirk, Bill McKenna, Meghna Mehta, Tony Morales, Sujatha Muthulingam, Michael Orlowski, Jennifer Polk, Dmitry Potapov, Rebecca Reitmeyer, Kathy Rich, John Russell, Vivian Schupmann, Shrikanth Shankar, Vikram Shukla, Mike Stewart, Sankar Subramanian, Seema Sundara, Hal Takahara, Ashish Thusoo, Anh-Tuan Tran, Randy Urbano, Guhan Viswanathan, David Wang, Jim Warner, Andy Witkowski, Daniel Wong, Jianping Yang, Adiel Yoaz, Qin Yu, Tim Yu, Mohamed Zait, Fred Zemke
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, Oracle Store, PL/SQL, Pro*Ada, Pro*C, Pro*C/C++, Pro*COBOL, Pro*FORTRAN, Pro*Pascal, Pro*PL/1, and SQL*Plus are trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their respective owners.

|
Contents |
Send Us Your Comments .................................................................................................................. |
xv |
Preface......................................................................................................................................................... |
xvii |
What’s New in SQL Reference?................................................................................................. |
xxvii |
1 Introduction to Oracle SQL |
|
2 Basic Elements of Oracle SQL |
|
Datatypes ............................................................................................................................................. |
2-2 |
Literals ................................................................................................................................................ |
2-53 |
Format Models .................................................................................................................................. |
2-61 |
Nulls ................................................................................................................................................... |
2-80 |
Pseudocolumns ................................................................................................................................ |
2-82 |
Comments .......................................................................................................................................... |
2-90 |
Database Objects ............................................................................................................................ |
2-106 |
Schema Object Names and Qualifiers ........................................................................................ |
2-110 |
Syntax for Schema Objects and Parts in SQL Statements ...................................................... |
2-115 |
3 Operators |
|
About SQL Operators ........................................................................................................................ |
3-2 |
Arithmetic Operators ........................................................................................................................ |
3-3 |
Concatenation Operator .................................................................................................................... |
3-4 |
Set Operators ...................................................................................................................................... |
3-6 |
User-Defined Operators .................................................................................................................... |
3-6 |
iii
4 Expressions |
|
About SQL Expressions .................................................................................................................... |
4-2 |
Simple Expressions ............................................................................................................................ |
4-3 |
Compound Expressions .................................................................................................................... |
4-5 |
CASE Expressions .............................................................................................................................. |
4-6 |
CURSOR Expressions ........................................................................................................................ |
4-7 |
Datetime Expressions ........................................................................................................................ |
4-9 |
Function Expressions ....................................................................................................................... |
4-11 |
INTERVAL Expressions .................................................................................................................. |
4-11 |
Object Access Expressions ............................................................................................................. |
4-12 |
Scalar Subquery Expressions ......................................................................................................... |
4-13 |
Type Constructor Expressions ....................................................................................................... |
4-13 |
Variable Expressions ....................................................................................................................... |
4-15 |
Expression Lists ................................................................................................................................ |
4-16 |
5 Conditions |
|
About SQL Conditions ...................................................................................................................... |
5-2 |
Comparison Conditions .................................................................................................................... |
5-4 |
Logical Conditions.............................................................................................................................. |
5-8 |
Membership Conditions ................................................................................................................... |
5-9 |
Range Conditions ............................................................................................................................. |
5-12 |
Null Conditions ................................................................................................................................ |
5-13 |
EQUALS_PATH ................................................................................................................................ |
5-13 |
EXISTS Conditions .......................................................................................................................... |
5-14 |
LIKE Conditions ............................................................................................................................... |
5-15 |
IS OF type Conditions ..................................................................................................................... |
5-19 |
UNDER_PATH .................................................................................................................................. |
5-20 |
Compound Conditions ................................................................................................................... |
5-21 |
6 Functions
SQL Functions .................................................................................................................................... |
6-2 |
ABS ..................................................................................................................................................... |
6-17 |
ACOS .................................................................................................................................................. |
6-17 |
ADD_MONTHS ............................................................................................................................... |
6-18 |
ASCII .................................................................................................................................................. |
6-18 |
iv
ASCIISTR .......................................................................................................................................... |
6-19 |
ASIN ................................................................................................................................................... |
6-20 |
ATAN .................................................................................................................................................. |
6-21 |
ATAN2 ................................................................................................................................................ |
6-21 |
AVG .................................................................................................................................................... |
6-22 |
BFILENAME ..................................................................................................................................... |
6-23 |
BIN_TO_NUM ................................................................................................................................. |
6-25 |
BITAND ............................................................................................................................................. |
6-25 |
CAST .................................................................................................................................................. |
6-27 |
CEIL .................................................................................................................................................... |
6-30 |
CHARTOROWID ............................................................................................................................ |
6-30 |
CHR .................................................................................................................................................... |
6-31 |
COALESCE ....................................................................................................................................... |
6-33 |
COMPOSE ........................................................................................................................................ |
6-34 |
CONCAT ........................................................................................................................................... |
6-35 |
CONVERT ......................................................................................................................................... |
6-36 |
CORR ................................................................................................................................................. |
6-37 |
COS ..................................................................................................................................................... |
6-39 |
COSH ................................................................................................................................................. |
6-40 |
COUNT .............................................................................................................................................. |
6-40 |
COVAR_POP .................................................................................................................................... |
6-42 |
COVAR_SAMP ................................................................................................................................ |
6-44 |
CUME_DIST ..................................................................................................................................... |
6-47 |
CURRENT_DATE ............................................................................................................................ |
6-49 |
CURRENT_TIMESTAMP .............................................................................................................. |
6-50 |
DBTIMEZONE ................................................................................................................................. |
6-51 |
DECODE ............................................................................................................................................ |
6-52 |
DECOMPOSE ................................................................................................................................... |
6-53 |
DENSE_RANK ................................................................................................................................. |
6-55 |
DEPTH ................................................................................................................................................ |
6-57 |
DEREF ................................................................................................................................................ |
6-58 |
DUMP ................................................................................................................................................ |
6-59 |
EMPTY_BLOB, EMPTY_CLOB .................................................................................................... |
6-61 |
EXISTSNODE ................................................................................................................................... |
6-61 |
EXP ...................................................................................................................................................... |
6-62 |
v
EXTRACT (datetime) ....................................................................................................................... |
6-63 |
EXTRACT (XML) ............................................................................................................................. |
6-65 |
EXTRACTVALUE ............................................................................................................................ |
6-66 |
FIRST .................................................................................................................................................. |
6-67 |
FIRST_VALUE .................................................................................................................................. |
6-69 |
FLOOR ............................................................................................................................................... |
6-71 |
FROM_TZ .......................................................................................................................................... |
6-71 |
GREATEST ........................................................................................................................................ |
6-72 |
GROUP_ID ........................................................................................................................................ |
6-72 |
GROUPING ...................................................................................................................................... |
6-74 |
GROUPING_ID ............................................................................................................................... |
6-75 |
HEXTORAW ..................................................................................................................................... |
6-77 |
INITCAP ............................................................................................................................................ |
6-77 |
INSTR ................................................................................................................................................. |
6-78 |
LAG ..................................................................................................................................................... |
6-80 |
LAST ................................................................................................................................................... |
6-81 |
LAST_DAY ........................................................................................................................................ |
6-83 |
LAST_VALUE ................................................................................................................................... |
6-84 |
LEAD .................................................................................................................................................. |
6-86 |
LEAST ................................................................................................................................................ |
6-87 |
LENGTH ............................................................................................................................................ |
6-88 |
LN ........................................................................................................................................................ |
6-89 |
LOCALTIMESTAMP ....................................................................................................................... |
6-90 |
LOG .................................................................................................................................................... |
6-91 |
LOWER .............................................................................................................................................. |
6-91 |
LPAD ................................................................................................................................................... |
6-92 |
LTRIM ................................................................................................................................................ |
6-93 |
MAKE_REF ....................................................................................................................................... |
6-94 |
MAX .................................................................................................................................................... |
6-95 |
MIN ..................................................................................................................................................... |
6-97 |
MOD ................................................................................................................................................... |
6-98 |
MONTHS_BETWEEN .................................................................................................................... |
6-99 |
NCHR ............................................................................................................................................... |
6-100 |
NEW_TIME ..................................................................................................................................... |
6-100 |
NEXT_DAY ...................................................................................................................................... |
6-102 |
vi
NLS_CHARSET_DECL_LEN ...................................................................................................... |
6-102 |
NLS_CHARSET_ID ...................................................................................................................... |
6-103 |
NLS_CHARSET_NAME .............................................................................................................. |
6-104 |
NLS_INITCAP ................................................................................................................................ |
6-104 |
NLS_LOWER .................................................................................................................................. |
6-106 |
NLSSORT ........................................................................................................................................ |
6-107 |
NLS_UPPER .................................................................................................................................... |
6-108 |
NTILE ............................................................................................................................................... |
6-109 |
NULLIF ............................................................................................................................................ |
6-110 |
NUMTODSINTERVAL ................................................................................................................ |
6-111 |
NUMTOYMINTERVAL ............................................................................................................... |
6-112 |
NVL .................................................................................................................................................. |
6-113 |
NVL2 ................................................................................................................................................ |
6-114 |
PATH ................................................................................................................................................. |
6-115 |
PERCENT_RANK .......................................................................................................................... |
6-116 |
PERCENTILE_CONT .................................................................................................................... |
6-118 |
PERCENTILE_DISC ...................................................................................................................... |
6-121 |
POWER ............................................................................................................................................ |
6-122 |
RANK ............................................................................................................................................... |
6-123 |
RATIO_TO_REPORT .................................................................................................................... |
6-125 |
RAWTOHEX ................................................................................................................................... |
6-126 |
RAWTONHEX ................................................................................................................................ |
6-126 |
REF .................................................................................................................................................... |
6-127 |
REFTOHEX ..................................................................................................................................... |
6-128 |
REGR_ (Linear Regression) Functions ...................................................................................... |
6-129 |
REPLACE ......................................................................................................................................... |
6-137 |
ROUND (number) ......................................................................................................................... |
6-138 |
ROUND (date) ................................................................................................................................ |
6-139 |
ROW_NUMBER ............................................................................................................................. |
6-139 |
ROWIDTOCHAR .......................................................................................................................... |
6-141 |
ROWIDTONCHAR ....................................................................................................................... |
6-141 |
RPAD ................................................................................................................................................ |
6-142 |
RTRIM .............................................................................................................................................. |
6-143 |
SESSIONTIMEZONE ................................................................................................................... |
6-143 |
SIGN ................................................................................................................................................. |
6-144 |
vii
SIN .................................................................................................................................................... |
6-145 |
SINH ................................................................................................................................................. |
6-145 |
SOUNDEX ....................................................................................................................................... |
6-146 |
SQRT ................................................................................................................................................ |
6-147 |
STDDEV .......................................................................................................................................... |
6-148 |
STDDEV_POP ................................................................................................................................ |
6-149 |
STDDEV_SAMP ............................................................................................................................ |
6-151 |
SUBSTR ........................................................................................................................................... |
6-152 |
SUM .................................................................................................................................................. |
6-154 |
SYS_CONNECT_BY_PATH ......................................................................................................... |
6-155 |
SYS_CONTEXT .............................................................................................................................. |
6-156 |
SYS_DBURIGEN ........................................................................................................................... |
6-161 |
SYS_EXTRACT_UTC .................................................................................................................... |
6-162 |
SYS_GUID ....................................................................................................................................... |
6-163 |
SYS_TYPEID ................................................................................................................................... |
6-164 |
SYS_XMLAGG ............................................................................................................................... |
6-165 |
SYS_XMLGEN ................................................................................................................................ |
6-166 |
SYSDATE ......................................................................................................................................... |
6-167 |
SYSTIMESTAMP ........................................................................................................................... |
6-168 |
TAN ................................................................................................................................................... |
6-169 |
TANH ............................................................................................................................................... |
6-169 |
TO_CHAR (character) ................................................................................................................... |
6-170 |
TO_CHAR (datetime) .................................................................................................................... |
6-171 |
TO_CHAR (number) ..................................................................................................................... |
6-173 |
TO_CLOB ........................................................................................................................................ |
6-175 |
TO_DATE ........................................................................................................................................ |
6-175 |
TO_DSINTERVAL ......................................................................................................................... |
6-177 |
TO_LOB ........................................................................................................................................... |
6-178 |
TO_MULTI_BYTE .......................................................................................................................... |
6-179 |
TO_NCHAR (character) ................................................................................................................ |
6-180 |
TO_NCHAR (datetime) ................................................................................................................ |
6-181 |
TO_NCHAR (number) .................................................................................................................. |
6-182 |
TO_NCLOB ..................................................................................................................................... |
6-182 |
TO_NUMBER ................................................................................................................................. |
6-183 |
TO_SINGLE_BYTE ........................................................................................................................ |
6-184 |
viii
TO_TIMESTAMP .......................................................................................................................... |
6-185 |
TO_TIMESTAMP_TZ ................................................................................................................... |
6-186 |
TO_YMINTERVAL ....................................................................................................................... |
6-187 |
TRANSLATE ................................................................................................................................... |
6-188 |
TRANSLATE ... USING ................................................................................................................ |
6-189 |
TREAT .............................................................................................................................................. |
6-191 |
TRIM ................................................................................................................................................ |
6-192 |
TRUNC (number) .......................................................................................................................... |
6-194 |
TRUNC (date) ................................................................................................................................. |
6-194 |
TZ_OFFSET ..................................................................................................................................... |
6-195 |
UID ................................................................................................................................................... |
6-196 |
UNISTR ........................................................................................................................................... |
6-196 |
UPDATEXML ................................................................................................................................. |
6-197 |
UPPER .............................................................................................................................................. |
6-199 |
USER ................................................................................................................................................ |
6-199 |
USERENV ........................................................................................................................................ |
6-200 |
VALUE .............................................................................................................................................. |
6-202 |
VAR_POP ........................................................................................................................................ |
6-202 |
VAR_SAMP ..................................................................................................................................... |
6-204 |
VARIANCE ..................................................................................................................................... |
6-206 |
VSIZE ............................................................................................................................................... |
6-207 |
WIDTH_BUCKET .......................................................................................................................... |
6-208 |
XMLAGG ......................................................................................................................................... |
6-210 |
XMLCOLATTVAL .......................................................................................................................... |
6-212 |
XMLCONCAT ................................................................................................................................. |
6-213 |
XMLELEMENT ............................................................................................................................... |
6-214 |
XMLFOREST ................................................................................................................................... |
6-217 |
XMLSEQUENCE............................................................................................................................. |
6-218 |
XMLTRANSFORM......................................................................................................................... |
6-219 |
ROUND and TRUNC Date Functions........................................................................................ |
6-221 |
User-Defined Functions ................................................................................................................ |
6-222 |
7 Common SQL DDL Clauses
allocate_extent_clause........................................................................................................................ |
7-2 |
constraints ........................................................................................................................................... |
7-5 |
ix
deallocate_unused_clause................................................................................................................. |
7-37 |
file_specification ............................................................................................................................... |
7-39 |
logging_clause .................................................................................................................................... |
7-45 |
parallel_clause ................................................................................................................................... |
7-49 |
physical_attributes_clause............................................................................................................... |
7-52 |
storage_clause .................................................................................................................................... |
7-56 |
8 SQL Queries and Subqueries
About Queries and Subqueries ....................................................................................................... |
8-2 |
Creating Simple Queries .................................................................................................................. |
8-2 |
Hierarchical Queries .......................................................................................................................... |
8-3 |
The UNION [ALL], INTERSECT, MINUS Operators ................................................................. |
8-7 |
Sorting Query Results ..................................................................................................................... |
8-10 |
Joins .................................................................................................................................................... |
8-10 |
Using Subqueries.............................................................................................................................. |
8-13 |
Unnesting of Nested Subqueries .................................................................................................. |
8-15 |
Selecting from the DUAL Table .................................................................................................... |
8-16 |
Distributed Queries ......................................................................................................................... |
8-16 |
9 SQL Statements: ALTER CLUSTER to ALTER SEQUENCE
Types of SQL Statements .................................................................................................................. |
9-2 |
Organization of SQL Statements .................................................................................................... |
9-4 |
ALTER CLUSTER .............................................................................................................................. |
9-6 |
ALTER DATABASE ......................................................................................................................... |
9-11 |
ALTER DIMENSION ...................................................................................................................... |
9-56 |
ALTER FUNCTION ......................................................................................................................... |
9-59 |
ALTER INDEX .................................................................................................................................. |
9-62 |
ALTER INDEXTYPE ........................................................................................................................ |
9-85 |
ALTER JAVA ..................................................................................................................................... |
9-87 |
ALTER MATERIALIZED VIEW ................................................................................................... |
9-90 |
ALTER MATERIALIZED VIEW LOG ....................................................................................... |
9-110 |
ALTER OPERATOR ....................................................................................................................... |
9-117 |
ALTER OUTLINE .......................................................................................................................... |
9-118 |
ALTER PACKAGE ......................................................................................................................... |
9-120 |
ALTER PROCEDURE ................................................................................................................... |
9-124 |
x
ALTER PROFILE ............................................................................................................................ |
9-127 |
ALTER RESOURCE COST .......................................................................................................... |
9-131 |
ALTER ROLE .................................................................................................................................. |
9-134 |
ALTER ROLLBACK SEGMENT ................................................................................................ |
9-136 |
ALTER SEQUENCE ....................................................................................................................... |
9-140 |
10 SQL Statements: ALTER SESSION to ALTER SYSTEM
ALTER SESSION ............................................................................................................................. |
10-2 |
ALTER SYSTEM ............................................................................................................................ |
10-20 |
11 SQL Statements: ALTER TABLE to ALTER TABLESPACE
ALTER TABLE .................................................................................................................................. |
11-2 |
ALTER TABLESPACE ................................................................................................................. |
11-102 |
12 SQL Statements: ALTER TRIGGER to COMMIT
ALTER TRIGGER ............................................................................................................................ |
12-2 |
ALTER TYPE ..................................................................................................................................... |
12-6 |
ALTER USER .................................................................................................................................. |
12-22 |
ALTER VIEW .................................................................................................................................. |
12-31 |
ANALYZE ........................................................................................................................................ |
12-34 |
ASSOCIATE STATISTICS ........................................................................................................... |
12-50 |
AUDIT .............................................................................................................................................. |
12-54 |
CALL ................................................................................................................................................ |
12-68 |
COMMENT ..................................................................................................................................... |
12-72 |
COMMIT ......................................................................................................................................... |
12-75 |
13 SQL Statements: CREATE CLUSTER to CREATE JAVA
CREATE CLUSTER .......................................................................................................................... |
13-2 |
CREATE CONTEXT ...................................................................................................................... |
13-12 |
CREATE CONTROLFILE ............................................................................................................. |
13-15 |
CREATE DATABASE .................................................................................................................... |
13-23 |
CREATE DATABASE LINK ......................................................................................................... |
13-37 |
CREATE DIMENSION ................................................................................................................. |
13-43 |
CREATE DIRECTORY .................................................................................................................. |
13-49 |
CREATE FUNCTION .................................................................................................................... |
13-52 |
xi
|
CREATE INDEX ............................................................................................................................. |
13-65 |
|
CREATE INDEXTYPE ................................................................................................................... |
13-95 |
|
CREATE JAVA ................................................................................................................................. |
13-98 |
14 |
SQL Statements: CREATE LIBRARY to CREATE SPFILE |
|
|
CREATE LIBRARY .......................................................................................................................... |
14-2 |
|
CREATE MATERIALIZED VIEW ................................................................................................ |
14-5 |
|
CREATE MATERIALIZED VIEW LOG .................................................................................... |
14-34 |
|
CREATE OPERATOR .................................................................................................................... |
14-44 |
|
CREATE OUTLINE ........................................................................................................................ |
14-48 |
|
CREATE PACKAGE ...................................................................................................................... |
14-52 |
|
CREATE PACKAGE BODY ......................................................................................................... |
14-57 |
|
CREATE PFILE ............................................................................................................................... |
14-62 |
|
CREATE PROCEDURE ................................................................................................................. |
14-64 |
|
CREATE PROFILE ......................................................................................................................... |
14-71 |
|
CREATE ROLE ............................................................................................................................... |
14-79 |
|
CREATE ROLLBACK SEGMENT .............................................................................................. |
14-82 |
|
CREATE SCHEMA ........................................................................................................................ |
14-86 |
|
CREATE SEQUENCE .................................................................................................................... |
14-89 |
|
CREATE SPFILE ............................................................................................................................. |
14-94 |
15 SQL Statements: CREATE SYNONYM to CREATE TRIGGER |
|
|
|
CREATE SYNONYM ....................................................................................................................... |
15-2 |
|
CREATE TABLE ............................................................................................................................... |
15-7 |
|
CREATE TABLESPACE ................................................................................................................ |
15-80 |
|
CREATE TEMPORARY TABLESPACE ..................................................................................... |
15-92 |
|
CREATE TRIGGER ....................................................................................................................... |
15-95 |
16 SQL Statements: CREATE TYPE to DROP ROLLBACK SEGMENT |
|
|
|
CREATE TYPE .................................................................................................................................. |
16-3 |
|
CREATE TYPE BODY ................................................................................................................... |
16-25 |
|
CREATE USER ................................................................................................................................ |
16-32 |
|
CREATE VIEW ............................................................................................................................... |
16-39 |
|
DELETE ............................................................................................................................................ |
16-55 |
|
DISASSOCIATE STATISTICS .................................................................................................... |
16-64 |
xii
DROP CLUSTER ........................................................................................................................... |
16-67 |
DROP CONTEXT .......................................................................................................................... |
16-69 |
DROP DATABASE LINK ............................................................................................................. |
16-70 |
DROP DIMENSION ..................................................................................................................... |
16-72 |
DROP DIRECTORY ...................................................................................................................... |
16-74 |
DROP FUNCTION ........................................................................................................................ |
16-75 |
DROP INDEX ................................................................................................................................. |
16-77 |
DROP INDEXTYPE ....................................................................................................................... |
16-79 |
DROP JAVA .................................................................................................................................... |
16-81 |
DROP LIBRARY ............................................................................................................................ |
16-83 |
DROP MATERIALIZED VIEW ................................................................................................... |
16-84 |
DROP MATERIALIZED VIEW LOG ........................................................................................ |
16-86 |
DROP OPERATOR ........................................................................................................................ |
16-88 |
DROP OUTLINE ........................................................................................................................... |
16-90 |
DROP PACKAGE .......................................................................................................................... |
16-91 |
DROP PROCEDURE ..................................................................................................................... |
16-93 |
DROP PROFILE ............................................................................................................................. |
16-95 |
DROP ROLE ................................................................................................................................... |
16-97 |
DROP ROLLBACK SEGMENT .................................................................................................. |
16-98 |
17 SQL Statements: DROP SEQUENCE to ROLLBACK
DROP SEQUENCE .......................................................................................................................... |
17-2 |
DROP SYNONYM ........................................................................................................................... |
17-4 |
DROP TABLE ................................................................................................................................... |
17-6 |
DROP TABLESPACE .................................................................................................................... |
17-10 |
DROP TRIGGER ........................................................................................................................... |
17-13 |
DROP TYPE .................................................................................................................................... |
17-15 |
DROP TYPE BODY ....................................................................................................................... |
17-18 |
DROP USER ................................................................................................................................... |
17-20 |
DROP VIEW ................................................................................................................................... |
17-22 |
EXPLAIN PLAN ............................................................................................................................. |
17-24 |
GRANT ............................................................................................................................................ |
17-29 |
INSERT ............................................................................................................................................ |
17-53 |
LOCK TABLE .................................................................................................................................. |
17-73 |
MERGE ............................................................................................................................................ |
17-77 |
xiii
NOAUDIT ........................................................................................................................................ |
17-81 |
RENAME ......................................................................................................................................... |
17-86 |
REVOKE .......................................................................................................................................... |
17-88 |
ROLLBACK ..................................................................................................................................... |
17-99 |
18 SQL Statements: SAVEPOINT to UPDATE
SAVEPOINT ...................................................................................................................................... |
18-2 |
SELECT .............................................................................................................................................. |
18-4 |
SET CONSTRAINT[S] .................................................................................................................. |
18-45 |
SET ROLE ........................................................................................................................................ |
18-47 |
SET TRANSACTION .................................................................................................................... |
18-50 |
TRUNCATE ..................................................................................................................................... |
18-54 |
UPDATE ........................................................................................................................................... |
18-59 |
AHow to Read Syntax Diagrams
BOracle and Standard SQL
COracle Reserved Words
DExamples
Using Extensible Indexing .............................................................................................................. |
D-2 |
Using XML in SQL Statements ..................................................................................................... |
D-11 |
Index
xiv