




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Part No. B10758-
December 2003
Oracle Database SQL Quick Reference, 10 g Release 1 (10.1)
Part No. B10758-
Copyright © 2003 Oracle Corporation. All rights reserved.
Contributors: Joan Gregoire, Diana Lorentz, Simon Watt
The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent and other intellectual and industrial property laws. Reverse engineering, disassembly or decompilation of the Programs, 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 Oracle Store, PL/SQL, SQLPlus, and iSQLPlus are trademarks or registered trademarks of Oracle Corporation. Other names may be trademarks of their respective owners.
iv
v
Send Us Your Comments
Part No. B10758-
vii
Preface
Audience
Organization
viii
Related Documentation
http://oraclestore.oracle.com/
http://otn.oracle.com/membership/
x
Conventions in Code Examples
SELECT username FROM dba_users WHERE username = 'MIGRATE';
lowercase monospace (fixed-width) font
Lowercase monospace typeface indicates executables, filenames, directory names, and sample user-supplied elements. Such elements include computer and database names, net service names, and connect identifiers, as well as user-supplied database objects and structures, column names, packages and classes, usernames and roles, program units, and parameter values. Note: Some programmatic elements use a mixture of UPPERCASE and lowercase. Enter these elements as shown.
Enter sqlplus to open SQL*Plus. The password is specified in the orapwd file. Back up the datafiles and control files in the /disk1/oracle/dbs directory. The department_id, department_name, and location_id columns are in the hr.departments table. Set the QUERY_REWRITE_ENABLED initialization parameter to true. Connect as oe user. The JRepUtil class implements these methods.
lowercase italic monospace (fixed-width) font
Lowercase italic monospace font represents placeholders or variables.
You can specify the parallel_clause. Run U old_release .SQL where old release_ refers to the release you installed prior to upgrading.
Convention Meaning Example
[ ] Brackets enclose one or more optional items. Do not enter the brackets.
DECIMAL ( digits [ , precision ])
{ } Braces enclose two or more items, one of which is required. Do not enter the braces.
| A vertical bar represents a choice of two or more options within brackets or braces. Enter one of the options. Do not enter the vertical bar.
Convention Meaning Example
xi
... Horizontal ellipsis points indicate either:
That we have omitted parts of the code that are not directly related to the example That you can repeat a portion of the code
CREATE TABLE ... AS subquery ;
SELECT col1 , col2 , ... , coln FROM employees;
Vertical ellipsis points indicate that we have omitted several lines of code not directly related to the example.
/fsl/dbs/tbs_01.dbf /fs1/dbs/tbs_02.dbf . . . /fsl/dbs/tbs_09.dbf 9 rows selected.
Other notation You must enter symbols other than brackets, braces, vertical bars, and ellipsis points as shown.
acctbal NUMBER(11,2); acct CONSTANT NUMBER(4) := 3;
Italics Italicized text indicates placeholders or variables for which you must supply particular values.
CONNECT SYSTEM/ system_password DB_NAME = database_name
UPPERCASE Uppercase typeface indicates elements supplied by the system. We show these terms in uppercase in order to distinguish them from terms you define. Unless terms appear in brackets, enter them in the order and with the spelling shown. However, because these terms are not case sensitive, you can enter them in lowercase.
SELECT last_name, employee_id FROM employees; SELECT * FROM USER_TABLES; DROP TABLE hr.employees;
lowercase Lowercase typeface indicates programmatic elements that you supply. For example, lowercase indicates names of tables, columns, or files. Note: Some programmatic elements use a mixture of UPPERCASE and lowercase. Enter these elements as shown.
SELECT last_name, employee_id FROM employees; sqlplus hr/hr CREATE USER mjones IDENTIFIED BY ty3MU9;
Convention Meaning Example
SQL Statements 1-
Syntax for SQL Statements
1-2 Oracle Database SQL Quick Reference
Table 1–1 Syntax for SQL Statements
SQL Statement Syntax
ALTER CLUSTER ALTER CLUSTER [ schema. ]cluster { physical_attributes_clause | SIZE size_clause | allocate_extent_clause | deallocate_unused_clause | { CACHE | NOCACHE } } [ physical_attributes_clause | SIZE size_clause | allocate_extent_clause | deallocate_unused_clause | { CACHE | NOCACHE } ]... [ parallel_clause ] ;
ALTER DATABASE ALTER DATABASE [ database ] { startup_clauses | recovery_clauses | database_file_clauses | logfile_clauses | controlfile_clauses | standby_database_clauses | default_settings_clauses | redo_thread_clauses | security_clause } ;
1-4 Oracle Database SQL Quick Reference
ALTER INDEX ALTER INDEX [ schema. ]index { { deallocate_unused_clause | allocate_extent_clause | shrink_clause | parallel_clause | physical_attributes_clause | logging_clause } [ deallocate_unused_clause | allocate_extent_clause | shrink_clause | parallel_clause | physical_attributes_clause | logging_clause ]... | rebuild_clause | PARAMETERS ('ODCI_parameters') | { ENABLE | DISABLE } | UNUSABLE | RENAME TO new_name | COALESCE | { MONITORING | NOMONITORING } USAGE | UPDATE BLOCK REFERENCES | alter_index_partitioning } ;
ALTER INDEXTYPE ALTER INDEXTYPE [ schema. ]indextype { { ADD | DROP } [ schema. ]operator (parameter_types) [, { ADD | DROP } [ schema. ]operator (parameter_types) ]... [ using_type_clause ] | COMPILE } ;
ALTER JAVA ALTER JAVA { SOURCE | CLASS } [ schema. ]object_name [ RESOLVER ( ( match_string [, ] { schema_name | - } ) [ ( match_string [, ] { schema_name | - } ) ]... ) ] { { COMPILE | RESOLVE } | invoker_rights_clause } ;
Table 1–1 (Cont.) Syntax for SQL Statements
SQL Statement Syntax
SQL Statements 1-
ALTER MATERIALIZED VIEW ALTER MATERIALIZED VIEW schema. [ physical_attributes_clause | table_compression | LOB_storage_clause [, LOB_storage_clause ]... | modify_LOB_storage_clause [, modify_LOB_storage_clause ]... | alter_table_partitioning | parallel_clause | logging_clause | allocate_extent_clause | shrink_clause | { CACHE | NOCACHE } ] [ alter_iot_clauses ] [ USING INDEX physical_attributes_clause ] [ MODIFY scoped_table_ref_constraint | alter_mv_refresh ] [ { ENABLE | DISABLE } QUERY REWRITE | COMPILE | CONSIDER FRESH ] ;
Table 1–1 (Cont.) Syntax for SQL Statements
SQL Statement Syntax
SQL Statements 1-
ALTER OUTLINE ALTER OUTLINE [ PUBLIC | PRIVATE ] outline { REBUILD | RENAME TO new_outline_name | CHANGE CATEGORY TO new_category_name | { ENABLE | DISABLE } } [ REBUILD | RENAME TO new_outline_name | CHANGE CATEGORY TO new_category_name | { ENABLE | DISABLE } ]... ;
ALTER PACKAGE ALTER PACKAGE [ schema. ]package COMPILE [ DEBUG ] [ PACKAGE | SPECIFICATION | BODY ] [ compiler_parameters_clause [ compiler_parameters_clause ] ... ] [ REUSE SETTINGS ] ;
ALTER PROCEDURE ALTER PROCEDURE [ schema. ]procedure COMPILE [ DEBUG ] [ compiler_parameters_clause [ compiler_parameters_clause ] ... ] [ REUSE SETTINGS ] ;
ALTER PROFILE ALTER PROFILE profile LIMIT { resource_parameters | password_parameters } [ resource_parameters | password_parameters ]... ;
ALTER RESOURCE COST ALTER RESOURCE COST { CPU_PER_SESSION | CONNECT_TIME | LOGICAL_READS_PER_SESSION | PRIVATE_SGA } integer [ { CPU_PER_SESSION | CONNECT_TIME | LOGICAL_READS_PER_SESSION | PRIVATE_SGA } integer ] ... ;
Table 1–1 (Cont.) Syntax for SQL Statements
SQL Statement Syntax
1-8 Oracle Database SQL Quick Reference
ALTER ROLE ALTER ROLE role { NOT IDENTIFIED | IDENTIFIED { BY password | USING [ schema. ]package | EXTERNALLY | GLOBALLY } } ;
ALTER ROLLBACK SEGMENT ALTER ROLLBACK SEGMENT rollback_segment { ONLINE | OFFLINE | storage_clause | SHRINK [ TO integer [ K | M ] ] };
ALTER SEQUENCE ALTER SEQUENCE [ schema. ]sequence { INCREMENT BY integer | { MAXVALUE integer | NOMAXVALUE } | { MINVALUE integer | NOMINVALUE } | { CYCLE | NOCYCLE } | { CACHE integer | NOCACHE } | { ORDER | NOORDER } } [ INCREMENT BY integer | { MAXVALUE integer | NOMAXVALUE } | { MINVALUE integer | NOMINVALUE } | { CYCLE | NOCYCLE } | { CACHE integer | NOCACHE } | { ORDER | NOORDER } ]... ;
ALTER SESSION ALTER SESSION { ADVISE { COMMIT | ROLLBACK | NOTHING } | CLOSE DATABASE LINK dblink | { ENABLE | DISABLE } COMMIT IN PROCEDURE | { ENABLE | DISABLE } GUARD | { ENABLE | DISABLE | FORCE } PARALLEL { DML | DDL | QUERY } [ PARALLEL integer ] | { ENABLE RESUMABLE [ TIMEOUT integer ] [ NAME string ] | DISABLE RESUMABLE } | alter_session_set_clause } ;
Table 1–1 (Cont.) Syntax for SQL Statements
SQL Statement Syntax