ebook img

Oracle 9i. SQL Reference PDF

1492 Pages·2001·9.601 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Oracle 9i. SQL Reference

Oracle9i SQL Reference Release 1 (9.0.1) June 2001 Part No. A90125-01 Oracle9i SQL Reference, Release 1 (9.0.1) Part No. A90125-01 Copyright © 1996, 2001, Oracle Corporation. All rights reserved. Primary Author: Diana Lorentz Contributors: Nipun Agarwal, David Alpern, Patrick Amor, Rick Anderson, Geeta Arora, Nimar Arora, Lance Ashdown, Cathy Baird, Sandeepan Banerjee, Cailein Barclay, Subrhansu Basu, Mark Bauer, Ruth Baylis, Harmeek Bedi, Barbara Benton, Paula Bingham, Steve Bobrowski, Tolga Bozkaya, Allen Brumm, Bridget Burke, Ted Burroughs, Greg Casbolt, Sivasankaran Chandrasekar, Thomas Chang, Eugene Chong, Greg Cook, Michele Cyran,RavindraDani,DineshDas,MaryAnnDavidson,NorbertDebes,ConnieDialeris,AlanDowning,Amit Ganesh, Bill Gietz, Govind Govindarajan, Ray Guzman, John Haydu, Shelley Higgins, Thuvan Hoang, Wei Hu, Jiansheng Huang, Alexander Hunold, Bob Jenkins, Mark Johnson, Nitin Karkhanis, Vishy Karra, Jonathan Klein, Susan Kotsovolos, Vishu Krishnamurthy, Ramkumar Krishnan, Muralidhar Krishnaprasad, Paul Lane, SimonLaw,ShilpaLawande,SeongYongAlbertLee,BillLee,YunruiLi,Li-SenLiu,Shih-HaoLiu,JingLiu,Phil Locke, Lenore Luscher, Kevin MacDowell, Steve McGee, Colin McGregor, Jack Melnick, Ben Meng, Magdi Morsi, Ari Mozes, Sreedhar Mukkamalla, Subramanian Muralidhar, Ravi Murthy, Sujatha Muthulingam, Gary Ngai, Ron Obermarck, Jeffrey Olkin, Kevin Osinski, Ananth Raghavan, Jack Raitto, Den Raphaely, Siva Ravada, John Russell, Vivian Schupmann, Ajay Sethi, Lei Sheng, Wayne Smith, Ekrem Soylemez, Jagannathan Srinivasan, Jim Stenoish, Mike Stewart, Seema Sundara, Ashish Thusoo, Rosanne Park Toohey, Anh-Tuan Tran, Kothanda Umamageswaran, Randy Urbano, Sandy Venning, Andre Vergison, Steve Vivian, Eric Voss, Rick Wessman, Daniel Wong, Aravind Yalamanchi, Adiel Yoaz, Qin Yu, Mohamed Zait, Fred Zemke, Mohamed Ziauddin, and many many others. 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. IftheProgramsaredeliveredtotheU.S.Governmentoranyonelicensingorusingtheprogramsonbehalfof the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computersoftware"anduse,duplication,anddisclosureofthePrograms,includingdocumentation,shallbe subjecttothelicensingrestrictionssetforthintheapplicableOraclelicenseagreement.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 ComputerSoftware-RestrictedRights(June,1987).OracleCorporation,500OracleParkway,RedwoodCity, 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, andOracle9i, Oracle Call Interface, Oracle Database Configuration Assistant, Oracle Enterprise Manager, OracleinterMedia, Oracle Net, Oracle Spatial, Oracle Store, Oracle Text, Oracle Trace, PL/SQL, Real Application Clusters, 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 the SQL Reference?........................................................................................ xxvii 1 Introduction 2 Basic Elements of Oracle SQL Datatypes ............................................................................................................................................. 2-2 Literals................................................................................................................................................ 2-51 Format Models.................................................................................................................................. 2-59 Nulls ................................................................................................................................................... 2-77 Pseudocolumns ................................................................................................................................ 2-79 Comments.......................................................................................................................................... 2-85 Database Objects............................................................................................................................ 2-102 Schema Object Names and Qualifiers........................................................................................ 2-106 Syntax for Schema Objects and Parts in SQL Statements...................................................... 2-111 3 Operators About SQL Operators........................................................................................................................ 3-2 Arithmetic Operators ........................................................................................................................ 3-3 Concatenation Operator.................................................................................................................... 3-4 Set Operators ...................................................................................................................................... 3-6 iii User-Defined Operators .................................................................................................................... 3-6 4 Expressions About SQL Expressions .................................................................................................................... 4-2 Simple Expressions............................................................................................................................ 4-3 Compound Expressions .................................................................................................................... 4-4 CASE Expressions .............................................................................................................................. 4-5 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 List.................................................................................................................................. 4-15 5 Conditions About SQL Conditions...................................................................................................................... 5-2 Comparison Conditions.................................................................................................................... 5-4 Logical Conditions.............................................................................................................................. 5-7 Membership Conditions................................................................................................................... 5-9 Range Conditions............................................................................................................................. 5-11 Null Conditions................................................................................................................................ 5-11 EXISTS Conditions .......................................................................................................................... 5-11 LIKE Conditions............................................................................................................................... 5-12 IS OFtype Conditions ..................................................................................................................... 5-16 Compound Conditions ................................................................................................................... 5-17 6 Functions SQL Functions .................................................................................................................................... 6-2 ABS ..................................................................................................................................................... 6-15 ACOS .................................................................................................................................................. 6-15 ADD_MONTHS............................................................................................................................... 6-16 iv ASCII .................................................................................................................................................. 6-16 ASCIISTR .......................................................................................................................................... 6-17 ASIN ................................................................................................................................................... 6-18 ATAN .................................................................................................................................................. 6-19 ATAN2 ................................................................................................................................................ 6-19 AVG .................................................................................................................................................... 6-20 BFILENAME ..................................................................................................................................... 6-21 BIN_TO_NUM ................................................................................................................................. 6-22 BITAND ............................................................................................................................................. 6-23 CAST .................................................................................................................................................. 6-24 CEIL .................................................................................................................................................... 6-27 CHARTOROWID ............................................................................................................................ 6-27 CHR .................................................................................................................................................... 6-28 COALESCE ....................................................................................................................................... 6-29 COMPOSE ........................................................................................................................................ 6-31 CONCAT ........................................................................................................................................... 6-31 CONVERT ......................................................................................................................................... 6-32 CORR ................................................................................................................................................. 6-34 COS..................................................................................................................................................... 6-36 COSH ................................................................................................................................................. 6-36 COUNT .............................................................................................................................................. 6-37 COVAR_POP .................................................................................................................................... 6-39 COVAR_SAMP ................................................................................................................................ 6-41 CUME_DIST ..................................................................................................................................... 6-43 CURRENT_DATE ............................................................................................................................ 6-45 CURRENT_TIMESTAMP .............................................................................................................. 6-46 DBTIMEZONE ................................................................................................................................. 6-47 DECODE............................................................................................................................................ 6-47 DECOMPOSE................................................................................................................................... 6-49 DENSE_RANK ................................................................................................................................. 6-50 DEREF ................................................................................................................................................ 6-52 DUMP ................................................................................................................................................ 6-53 EMPTY_BLOB, EMPTY_CLOB .................................................................................................... 6-55 EXISTSNODE................................................................................................................................... 6-55 EXP ...................................................................................................................................................... 6-56 v EXTRACT (datetime)....................................................................................................................... 6-57 EXTRACT (XML) ............................................................................................................................. 6-58 FIRST .................................................................................................................................................. 6-59 FIRST_VALUE .................................................................................................................................. 6-61 FLOOR ............................................................................................................................................... 6-63 FROM_TZ .......................................................................................................................................... 6-63 GREATEST ........................................................................................................................................ 6-64 GROUP_ID........................................................................................................................................ 6-65 GROUPING ...................................................................................................................................... 6-66 GROUPING_ID ............................................................................................................................... 6-67 HEXTORAW ..................................................................................................................................... 6-69 INITCAP ............................................................................................................................................ 6-69 INSTR................................................................................................................................................. 6-70 LAG..................................................................................................................................................... 6-72 LAST ................................................................................................................................................... 6-73 LAST_DAY ........................................................................................................................................ 6-75 LAST_VALUE ................................................................................................................................... 6-76 LEAD .................................................................................................................................................. 6-78 LEAST ................................................................................................................................................ 6-80 LENGTH ............................................................................................................................................ 6-80 LN ........................................................................................................................................................ 6-81 LOCALTIMESTAMP....................................................................................................................... 6-82 LOG .................................................................................................................................................... 6-83 LOWER .............................................................................................................................................. 6-83 LPAD................................................................................................................................................... 6-84 LTRIM ................................................................................................................................................ 6-85 MAKE_REF ....................................................................................................................................... 6-85 MAX .................................................................................................................................................... 6-86 MIN..................................................................................................................................................... 6-89 MOD ................................................................................................................................................... 6-90 MONTHS_BETWEEN .................................................................................................................... 6-91 NCHR ................................................................................................................................................. 6-92 NEW_TIME ....................................................................................................................................... 6-93 NEXT_DAY ........................................................................................................................................ 6-94 NLS_CHARSET_DECL_LEN ........................................................................................................ 6-94 vi NLS_CHARSET_ID ........................................................................................................................ 6-95 NLS_CHARSET_NAME ................................................................................................................ 6-96 NLS_INITCAP.................................................................................................................................. 6-96 NLS_LOWER .................................................................................................................................... 6-98 NLSSORT .......................................................................................................................................... 6-99 NLS_UPPER .................................................................................................................................... 6-100 NTILE ............................................................................................................................................... 6-101 NULLIF ............................................................................................................................................ 6-102 NUMTODSINTERVAL ................................................................................................................ 6-103 NUMTOYMINTERVAL ............................................................................................................... 6-104 NVL .................................................................................................................................................. 6-105 NVL2 ................................................................................................................................................ 6-106 PERCENT_RANK .......................................................................................................................... 6-107 PERCENTILE_CONT.................................................................................................................... 6-109 PERCENTILE_DISC...................................................................................................................... 6-112 POWER ............................................................................................................................................ 6-113 RANK ............................................................................................................................................... 6-114 RATIO_TO_REPORT.................................................................................................................... 6-116 RAWTOHEX ................................................................................................................................... 6-117 RAWTONHEX ................................................................................................................................ 6-118 REF .................................................................................................................................................... 6-118 REFTOHEX ..................................................................................................................................... 6-119 REGR_ (linear regression) functions ......................................................................................... 6-120 REPLACE......................................................................................................................................... 6-128 ROUND (number) ......................................................................................................................... 6-129 ROUND (date) ................................................................................................................................ 6-130 ROW_NUMBER............................................................................................................................. 6-131 ROWIDTOCHAR .......................................................................................................................... 6-132 ROWIDTONCHAR....................................................................................................................... 6-133 RPAD ................................................................................................................................................ 6-133 RTRIM.............................................................................................................................................. 6-134 SESSIONTIMEZONE ................................................................................................................... 6-135 SIGN................................................................................................................................................. 6-135 SIN .................................................................................................................................................... 6-136 SINH................................................................................................................................................. 6-136 vii SOUNDEX ....................................................................................................................................... 6-137 SQRT ................................................................................................................................................ 6-138 STDDEV .......................................................................................................................................... 6-139 STDDEV_POP ................................................................................................................................ 6-140 STDDEV_SAMP ............................................................................................................................ 6-142 SUBSTR ........................................................................................................................................... 6-144 SUM .................................................................................................................................................. 6-145 SYS_CONNECT_BY_PATH ......................................................................................................... 6-147 SYS_CONTEXT .............................................................................................................................. 6-148 SYS_DBURIGEN ........................................................................................................................... 6-153 SYS_EXTRACT_UTC .................................................................................................................... 6-154 SYS_GUID....................................................................................................................................... 6-155 SYS_TYPEID ................................................................................................................................... 6-156 SYS_XMLAGG ............................................................................................................................... 6-157 SYS_XMLGEN ................................................................................................................................ 6-158 SYSDATE ......................................................................................................................................... 6-159 SYSTIMESTAMP ........................................................................................................................... 6-160 TAN ................................................................................................................................................... 6-161 TANH ............................................................................................................................................... 6-161 TO_CHAR (character) ................................................................................................................... 6-162 TO_CHAR (datetime).................................................................................................................... 6-163 TO_CHAR (number) ..................................................................................................................... 6-165 TO_CLOB ........................................................................................................................................ 6-167 TO_DATE ........................................................................................................................................ 6-167 TO_DSINTERVAL ......................................................................................................................... 6-168 TO_LOB ........................................................................................................................................... 6-169 TO_MULTI_BYTE.......................................................................................................................... 6-170 TO_NCHAR (character) ................................................................................................................ 6-171 TO_NCHAR (datetime) ................................................................................................................ 6-172 TO_NCHAR (number) .................................................................................................................. 6-173 TO_NCLOB ..................................................................................................................................... 6-174 TO_NUMBER ................................................................................................................................. 6-174 TO_SINGLE_BYTE........................................................................................................................ 6-175 TO_TIMESTAMP........................................................................................................................... 6-176 TO_TIMESTAMP_TZ ................................................................................................................... 6-177 viii TO_YMINTERVAL ........................................................................................................................ 6-178 TRANSLATE................................................................................................................................... 6-179 TRANSLATE ... USING ................................................................................................................ 6-180 TREAT .............................................................................................................................................. 6-182 TRIM ................................................................................................................................................ 6-183 TRUNC (number) .......................................................................................................................... 6-184 TRUNC (date) ................................................................................................................................. 6-185 TZ_OFFSET..................................................................................................................................... 6-186 UID ................................................................................................................................................... 6-187 UNISTR ........................................................................................................................................... 6-187 UPPER .............................................................................................................................................. 6-188 USER ................................................................................................................................................ 6-189 USERENV........................................................................................................................................ 6-189 VALUE.............................................................................................................................................. 6-191 VAR_POP ........................................................................................................................................ 6-192 VAR_SAMP ..................................................................................................................................... 6-194 VARIANCE ..................................................................................................................................... 6-195 VSIZE ............................................................................................................................................... 6-197 WIDTH_BUCKET.......................................................................................................................... 6-198 ROUND and TRUNC Date Functions........................................................................................ 6-199 User-Defined Functions ................................................................................................................ 6-201 7 SQL Queries and Other SQL Statements Queries and Subqueries ................................................................................................................... 7-2 Types of SQL Statements................................................................................................................ 7-16 8 SQL Statements: ALTER CLUSTER to ALTER SEQUENCE ALTER CLUSTER .............................................................................................................................. 8-3 ALTER DATABASE ........................................................................................................................... 8-9 ALTER DIMENSION ...................................................................................................................... 8-44 ALTER FUNCTION......................................................................................................................... 8-48 ALTER INDEX .................................................................................................................................. 8-51 ALTER INDEXTYPE ....................................................................................................................... 8-72 ALTER JAVA ..................................................................................................................................... 8-74 ix ALTER MATERIALIZED VIEW ................................................................................................... 8-77 ALTER MATERIALIZED VIEW LOG ......................................................................................... 8-93 ALTER OUTLINE .......................................................................................................................... 8-100 ALTER PACKAGE ......................................................................................................................... 8-102 ALTER PROCEDURE ................................................................................................................... 8-106 ALTER PROFILE ............................................................................................................................ 8-109 ALTER RESOURCE COST .......................................................................................................... 8-113 ALTER ROLE .................................................................................................................................. 8-116 ALTER ROLLBACK SEGMENT................................................................................................. 8-118 ALTER SEQUENCE ....................................................................................................................... 8-122 9 SQL Statements: ALTER SESSION to ALTER SYSTEM ALTER SESSION ............................................................................................................................... 9-2 Initialization Parameters and ALTER SESSION...................................................................... 9-7 Session Parameters and ALTER SESSION ............................................................................. 9-11 ALTER SYSTEM............................................................................................................................... 9-20 Initialization Parameters and ALTER SYSTEM..................................................................... 9-33 10 SQL Statements: ALTER TABLE to ALTER TABLESPACE ALTER TABLE .................................................................................................................................. 10-2 ALTER TABLESPACE ................................................................................................................... 10-82 11 SQL Statements: ALTER TRIGGER toconstraint_clause ALTER TRIGGER ............................................................................................................................ 11-2 ALTER TYPE ..................................................................................................................................... 11-6 ALTER USER .................................................................................................................................. 11-20 ALTER VIEW .................................................................................................................................. 11-28 ANALYZE ........................................................................................................................................ 11-31 ASSOCIATE STATISTICS ........................................................................................................... 11-46 AUDIT .............................................................................................................................................. 11-50 CALL................................................................................................................................................. 11-64 x

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.