Professional Documents
Culture Documents
✦ ✦ ✦ ✦
data_source := [schema.]{table|view}
828 Appendixes
The following list explains all of the elements used in the ALTER RESOURCE COST
command syntax:
ALTER SESSION
You can use the ALTER SESSION command to change session options. Listing A-1
provides the syntax for the ALTER SESSION command.
session_option :=
{ CONSTRAINT[S] = {IMMEDIATE|DEFERRED|DEFAULT}
| CREATE_STORED_OUTLINES = {TRUE|FALSE|’category_name’}
| CURRENT_SCHEMA = schema
| DB_BLOCK_CHECKING = {TRUE|FALSE}
| DB_FILE_MULTIBLOCK_READ_COUNT = integer
| FAST_START_IO_TARGET = integer
| FLAGGER = {ENTRY|IMMEDIATE|FULL|OFF}
| GLOBAL_NAMES = {TRUE|FALSE}
| HASH_AREA_SIZE = integer
| HASH_JOIN_ENABLED = {TRUE|FALSE}
| HASH_MULTIBLOCK_IO_COUNT = integer
| INSTANCE = integer
| ISOLATION_LEVEL = {SERIALIZABLE|READ COMMITTED}
| LOG_ARCHIVE_DEST_n =
{ null_string
| { LOCATION = pathname | SERVICE = servicename }
[MANDATORY|OPTIONAL]
[REOPEN [=retry_time]]
}
| LOG_ARCHIVE_DEST_STATE_n = {ENABLE|DEFER}
| LOG_ARCHIVE_MIN_SUCCEED_DEST = integer
| MAX_DUMP_FILE_SIZE = {size|UNLIMITED}
| NLS_CALENDAR = ‘text’
| NLS_COMP = ‘text’
| NLS_CURRENCY = ‘text’
| NLS_DATE_FORMAT = ‘format’
| NLS_DATE_LANGUAGE = language
| NLS_ISO_CURRENCY = ‘text’
| NLS_LANGUAGE = language
| NLS_NUMERIC_CHARACTERS = ‘text’
| NLS_SORT = {sort|BINARY}
| NLS_TERRITORY = territory
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 830
830 Appendixes
The following list explains all of the elements used in the ALTER SESSION command
syntax:
CLOSE DATABASE LINK dblink Specifies that the database link dblink
is to be closed for the current session.
COMMIT IN PROCEDURE Specifies that PL/SQL commits in
stored functions or procedures are
enabled or disabled.
ENABLE PARALLEL Specifies that statements in a session
will be run in parallel.
DISABLE PARALLEL Specifies that statements in a session
will be run serially.
FORCE PARALLEL Specifies that statements in a session
will be run in parallel, overriding the
parallel clause if specified in the
statements themselves.
DML Specifies that DML statements are
executed with the default or specified
degree of parallelism.
DDL Specifies that DML statements are
executed with the default or specified
degree of parallelism.
PARALLEL integer Specifies the degree of parallelism,
overriding the parallel clause in the
statements.
SET Specifies new values for session
options.
CONSTRAINT[S] Specifies when the conditions specified
by deferrable constraints are enforced.
IMMEDIATE Specifies that the conditions of
deferrable constraints are checked
immediately after each DML statement.
DEFERRED Specifies that the conditions of
deferrable constraints are checked
when the transaction is committed.
DEFAULT Specifies that the deferrable
constraints are reset to their initial
values: either IMMEDIATE or DEFERRED.
CREATE_STORED_OUTLINES Enables or disables the automatic
creation of outlines when queries are
performed.
‘category_name’ Enables the creation of stored outlines
and specifies the name of the category
created for the stored outlines.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 832
832 Appendixes
834 Appendixes
836 Appendixes
ALTER SYSTEM
You can use the ALTER SYSTEM command to change settings dynamically in the
Oracle instance. The settings will be lost when the database is unmounted. Listing
A-2 provides the syntax for the ALTER SYSTEM command:
The following list explains all of the elements used in the ALTER SYSTEM command
syntax:
838 Appendixes
THREAD integer Specifies the thread in which the redo log files
are to be archived.
STOP Disables automatic archiving of redo log file
groups.
SEQUENCE integer Specifies that the online redo log file identified
by the sequence number is to be archived
manually.
CHANGE integer Specifies that the online redo log file containing
the redo log entry identified by the specified
system change number (SCN) is to be archived
manually.
CURRENT Specifies that the current online redo log file
group is to be archived manually.
GROUP integer Specifies that the online redo log files in the
specified redo log file group are to be archived
manually.
LOGFILE ‘filename’ Specifies that the online redo log file identified
by the specified file name is to be archived
manually.
NEXT Specifies that the next full online redo log file
that is not yet archived is to be archived
manually.
ALL Specifies that all full online redo log files that
aren’t yet archived are to be archived manually.
START Enables automatic archiving of redo log file
groups.
TO ‘location’ Specifies the location to which the redo log
files are archived.
ANALYZE
You can use the ANALYZE command to collect or delete statistics about a database
object to validate its structure, to identify migrated and chained rows, or to
validate and update object references. The results are stored in the data dictionary
so they are available for the Oracle optimizer. Listing A-3 provides the syntax for
the ANALYZE command.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 839
| DELETE STATISTICS
| VALIDATE REF UPDATE [SET DANGLING TO NULL]
| VALIDATE STRUCTURE [CASCADE] {INTO {schema.}table}
| LIST CHAINED ROWS {INTO {schema.}table}
]
for_clause :=
{ FOR TABLE
| FOR ALL {INDEXED} COLUMNS {SIZE integer}
| FOR COLUMNS {SIZE integer}
[ (column {SIZE integer}
[,column {SIZE integer}...])
| (attribute {SIZE integer}
[,attribute {SIZE integer}...])
]
| FOR ALL {LOCAL} INDEXES
}
The following list explains all of the elements used in the ANALYZE command
syntax:
840 Appendixes
AUDIT {ALL|object_option[,object_option...]} ON
{ DEFAULT
| DIRECTORY directory_name
| [schema.]object
}
[ BY {SESSION|ACCESS} ]
[ WHENEVER [NOT] SUCCESSFUL ]
The following list explains all of the elements used in the AUDIT command syntax:
842 Appendixes
option :=
{statement_option|system_privilege}
The following list explains all of the elements used in the AUDIT command syntax:
CALL
You can use the CALL command to execute a function, procedure, or method. The
executed object may reside in a user-defined type, in a package in the local
database, or in a remote database. The following is the syntax for the CALL
command:
CALL [ [schema.]type.function[@dblink]
| [schema.]type.procedure[@dblink]
| [schema.]type.method[@dblink]
| [schema.]package.function[@dblink]
| [schema.]package.procedure[@dblink]
| [schema.]package.method[@dblink]
] (expression[,expression...])
[INTO :host_variable]
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 844
844 Appendixes
The following list explains all of the elements used in the CALL command syntax:
COMMENT
Use COMMENT to add comments to a table, view, or snapshot. Comments are stored
in the data dictionary and can be viewed by querying ALL_COL_COMMENTS or
USER_COL_COMMENTS for column comments and ALL_TAB_COMMENTS or
USER_TAB_COMMENTS for table comments. The following is the syntax for the
COMMENT command:
COMMENT ON
{ TABLE [schema.]{table|view|snapshot}
| COLUMN [schema.]{table|view|snapshot}.column
} IS ‘text’
The following list explains all of the elements used in the COMMENT command
syntax:
COMMIT
The COMMIT command ends the current transaction and makes permanent all the
changes performed in the transaction. In addition, it will clear all savepoints and
remove all locks created in the transaction. By using the FORCE clause, you can
manually commit in-doubt transactions. Note that the FORCE clause isn’t allowed in
PL/SQL. The following is the syntax for the COMMIT command:
COMMIT [WORK]
[ COMMENT ‘text’
| FORCE ‘text’ [,SCN]
]
The following list explains all of the elements used in the COMMIT command syntax:
CREATE/ALTER/DROP CLUSTER
Clusters are schema objects that contain tables that all have one or more columns
in common. Use the CREATE/ALTER/DROP CLUSTER commands to create new
clusters, alter parameters of existing clusters, or remove clusters. The following is
the syntax for the CREATE CLUSTER command:
846 Appendixes
The following list explains all of the elements used in the CREATE/ALTER/DROP
CLUSTER command syntax:
848 Appendixes
CREATE CONTROLFILE
You can use the CREATE CONTROLFILE command to create a new control file for the
database. Before using this statement, create a full backup of the database files.
Listing A-5 provides the syntax for the CREATE CONTROLFILE command.
The following list explains all of the elements used in the CREATE CONTROLFILE
command syntax:
CREATE/ALTER DATABASE
You can use the CREATE/ALTER DATABASE commands to create, modify, maintain,
or recover a database. Listing A-6 provides the syntax for the CREATE DATABASE
command.
850 Appendixes
Listing A-7 provides the syntax for the ALTER DATABASE command.
}
}
autoextend_clause := AUTOEXTEND
[ OFF
| ON [NEXT integer [K|M]]
| MAXSIZE {UNLIMITED|integer [K|M]}
]
file_list :=
{ GROUP integer
| ‘filename’
| (‘filename’[,’filename’...])
)
The following list explains all of the elements used in the CREATE/ALTER DATABASE
command syntax:
852 Appendixes
854 Appendixes
856 Appendixes
The following is the syntax for the DROP DATABASE LINK command:
The following list explains all of the elements used in the CREATE/DROP DATABASE
LINK command syntax:
CREATE/ALTER/DROP DIMENSION
You can use the CREATE/ALTER/DROP DIMENSION commands to create, alter, or
drop dimension database objects. Dimension database objects define parent-child
relationships between columns from the same and/or from other tables. No data
storage is associated with dimension database objects. The following is the syntax
for the CREATE DIMENSION command:
Listing A-8 provides the syntax for the DROP DIMENSION command.
add_clause := ADD
{ level_clause
| hierarchy_clause
| attribute_clause
}
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 858
858 Appendixes
drop_clause := DROP
{ LEVEL level [RESTRICT|CASCADE]
| HIERARCHY hierarchy
| ATTRIBUTE level
}
The following list explains all of the elements used in the CREATE/ALTER/DROP
DIMENSION commands syntax:
CREATE/DROP DIRECTORY
You can use the CREATE/DROP DIRECTORY commands to create or drop a
directory database object that represents a file system directory. A DIRECTORY
object can be seen as an alias for a file system directory. You can use the
DIRECTORY objects to store objects of the BFILE type. The following is the syntax
for the CREATE DIRECTORY command:
The following list explains all of the elements used in the CREATE/DROP
DIRECTORY commands’ syntax:
860 Appendixes
CREATE/ALTER/DROP FUNCTION
You can use the CREATE/ALTER/DROP FUNCTION commands to create, alter, or
drop stored function database objects. You may define the function in PL/SQL or in
another language. The difference between a stored FUNCTION and a stored
PROCEDURE is that the function returns a value, whereas a procedure does not. The
following is the syntax for the CREATE FUNCTION command:
argument_list :=
( argument {IN|OUT|IN OUT} [NOCOPY] datatype
[,argument {IN|OUT|IN OUT} [NOCOPY] datatype...]
)
The following list explains all of the elements used in the CREATE/ALTER/DROP
FUNCTION commands’ syntax:
862 Appendixes
CREATE/ALTER/DROP INDEX
You can use the CREATE/ALTER/DROP INDEX commands to create, alter, or drop
index database objects. Use the CREATE and ALTER commands to specify a number
of options and parameters for the index. Furthermore, you can use the ALTER
command to split index partitions and to modify or rebuild an index subpartition.
An index is a database object that provides direct access to a row via one or more
indexed columns. Indexes can be created on tables and clusters. Listing A-9
provides the syntax for the CREATE INDEX command:
(column_list)
(global_partition_clause[,global_partition_clause...])
index_attributes
| LOCAL
[ ( on_range_table[,on_range_table..] )
| { store_in_clause
| ( on_hash_table[,on_hash_table...] )
}
| store_in_clause
[ (on_composite_table[,on_composite_table..]) ]
]
index_attributes
]
}
}
Listing A-10 provides the syntax for the ALTER INDEX command.
864 Appendixes
Listing A-11 provides the syntax for the DROP INDEX command:
index_attributes :=
[ [parallel_clause]
[ONLINE]
[COMPUTE STATISTICS]
[physical_attributes_clause]
[COMPRESS integer|NOCOMPRESS]
[LOGGING|NOLOGGING]
[TABLESPACE {tablespace|DEFAULT}]
[NOSORT|REVERSE]
]
on_range_table :=
PARTITION [ partition [segment_attributes_clause]]
on_hash_table :=
PARTITION [partition [TABLESPACE table space]]
on_composite_table :=
PARTITION
[ partition
[segment_attributes_clause]
{ store_in_clause
| (subpartition[,subpartition...])
}
]
partitioning_clauses :=
{ MODIFY DEFAULT ATTRIBUTES [FOR PARTITION partition]
{ [physical_attributes_clause]
[TABLESPACE {tablespace|DEFAULT}]
[LOGGING|NOLOGGING]
}
| MODIFY PARTITION partition
{ UNUSABLE
| COALESCE
| { [physical_attributes_clause]
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 865
[LOGGING|NOLOGGING]
[ allocate_extent_clause
| DEALLOCATE UNUSED [KEEP integer [K|M]]
]
}
}
| RENAME {PARTITION|SUBPARTITION} current_name TO new_name
| DROP PARTITION partition_name
| SPLIT PARTITION partition_name_old AT (value_list)
[INTO (partition_descr,partition_descr)]
[parallel_clause]
| MODIFY SUBPARTITION subpartition
{ UNUSABLE
| allocate_extent_clause
| DEALLOCATE UNUSED [KEEP integer [K|M]]
}
}
partition_description := PARTITION
[partition [ [segment_attributes_clause]
[COMPRESS integer|NOCOMPRESS]
]
]
segment_attributes_clause :=
[ [physical_attributes_clause]
[TABLESPACE table space]
[LOGGING|NOLOGGING]
]
store_in_clause :=
STORE IN ( {DEFAULT|tablespace[,table space...]} )
subpartition :=
SUBPARTITION [subpartition [TABLESPACE table space]]
The following list explains all of the elements used in the CREATE/ALTER/DROP
INDEX commands’ syntax:
866 Appendixes
868 Appendixes
CREATE/DROP INDEXTYPE
You can use the CREATE/DROP INDEXTYPE commands to create or drop indextype
database objects. The indextype objects manage application-specific indexes
called domain indexes. Domain indexes are used for indexing operations on
complex data. The indextype database object binds to an implementation type
that implements user-defined index functions and procedures. The following is the
syntax for the CREATE INDEXTYPE command:
for_list_item :=
[schema.]operator(parameter_type[,parameter_type...])
The following list explains all of the elements used in the CREATE/DROP INDEXTYPE
command syntax:
870 Appendixes
CREATE/DROP LIBRARY
You can use the commands CREATE/DROP LIBRARY to create or drop library
database objects. Libraries can be regarded as synonyms for DLLs on the database
server. You can use subroutines in these DLLs in PL/SQL using the EXTERNAL
clause. The following is the syntax for the CREATE LIBRARY command:
The following list explains all of the elements used in the CREATE/DROP LIBRARY
commands’ syntax:
CREATE/ALTER/DROP MATERIALIZED
VIEW/SNAPSHOT
You can use the commands CREATE/ALTER/DROP MATERIALIZED VIEW/SNAPSHOT
to create, alter, or drop materialized views. Snapshot is synonymous with
materialized view. Materialized views can be used to summarize, replicate, and
distribute data. Listing A-12 provides the syntax for the CREATE MATERIALIZED
VIEW command.
Listing A-13 provides the syntax for the ALTER MATERIALIZED VIEW command.
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 872
872 Appendixes
The following is the syntax for the DROP MATERIALIZED VIEW command:
refresh_clause :=
[FAST|COMPLETE|FORCE]
[ON DEMAND|ON COMMIT]
[START WITH date|NEXT date]
[WITH {PRIMARY KEY|ROWID}]
[ USING DEFAULT {MASTER|LOCAL} ROLLBACK SEGMENT
| USING {MASTER|LOCAL} ROLLBACK SEGMENT rollback_segment
]
The following list explains all of the elements used in the CREATE/ALTER/DROP
MATERIALIZED VIEW/SNAPSHOT command syntax:
874 Appendixes
876 Appendixes
]
[partitioning_clauses]
[parallel_clause]
[WITH {ROWID|PRIMARY KEY|ROWID,PRIMARY KEY|PRIMARY KEY,ROWID}
[(filter_column[,filter_column...])
]
[INCLUDING NEW VALUES|EXCLUDING NEW VALUES]
The following is the syntax for the ALTER MATERIALIZED VIEW LOG command:
The following is the syntax for the DROP MATERIALIZED VIEW LOG command:
The following list explains all of the elements used in the CREATE/ALTER/DROP
MATERIALIZED VIEW LOG/SNAPSHOT LOG commands’ syntax:
CREATE/DROP OPERATOR
You can use the CREATE/DROP OPERATOR commands to create or drop operator
database objects. Database operator objects can be used in index types, DML, and
queries. The following is the syntax for the CREATE OPERATOR command:
binding_clause := ( parameter_type[,parameter_type...] )
RETURN return_type
[ ANCILLARY TO
primary_operator( parameter_type[,parameter_type...] )
[,primary_operator( parameter_type[,parameter_type...]
)...]
| WITH INDEX CONTEXT,SCAN CONTEXT implementation_type
[COMPUTE ANCILLARY DATA]
]
USING [schema.][package.|type.]function_name
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 878
878 Appendixes
The following list explains all of the elements used in the CREATE/DROP OPERATOR
commands’ syntax:
CREATE/ALTER/DROP PACKAGE
You can use the CREATE/ALTER/DROP PACKAGE commands to create, alter, or
delete packages in the database. Package specifications and bodies can be created,
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 879
altered, or deleted separately. The following is the syntax for the CREATE PACKAGE
and CREATE PACKAGE BODY commands:
The following list explains all of the elements used in the CREATE/ALTER/DROP
PACKAGE commands’ syntax:
880 Appendixes
CREATE/ALTER/DROP PROCEDURE
You can use the CREATE/ALTER/DROP PROCEDURE commands to create, alter, or
delete procedure database objects. You can also use the CREATE PROCEDURE
command to register external procedures (3GL stored in a shared library). The
following is the syntax for the CREATE PROCEDURE command:
The following list explains all of the elements used in the CREATE/ALTER/DROP
PROCEDURE commands’ syntax:
882 Appendixes
CREATE/ALTER/DROP PROFILE
You can use the CREATE/ALTER/DROP PROFILE commands to create, alter, or drop
profile database objects. You can assign a profile to a user to limit the usage of
database resources. The following is the syntax for the CREATE PROFILE command:
Listing A-14 provides the syntax for the ALTER PROFILE command:
profile_option :=
{ PRIVATE_SGA {UNLIMITED|DEFAULT|integer {K|M}}
| SESSION_PER_USER {integer|UNLIMITED|DEFAULT}
| CPU_PER_CALL {integer|UNLIMITED|DEFAULT}
| CPU_PER_SESSION {integer|UNLIMITED|DEFAULT}
| CONNECT_TIME {integer|UNLIMITED|DEFAULT}
| IDLE_TIME {integer|UNLIMITED|DEFAULT}
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 883
| COMPOSITE_LIMIT {integer|UNLIMITED|DEFAULT}
| LOGICAL_READS_PER_SESSION {integer|UNLIMITED|DEFAULT}
| LOGICAL_READS_PER_CALL {integer|UNLIMITED|DEFAULT}
| PASSWORD_VERIFY_FUNCTION {function|NULL|DEFAULT}
| { FAILED_LOGIN_ATTEMPTS {expression|UNLIMITED|DEFAULT}
| PASSWORD_LIFE_TIME {expression|UNLIMITED|DEFAULT}
| PASSWORD_LOCK_TIME {expression|UNLIMITED|DEFAULT}
| PASSWORD_GRACE_TIME {expression|UNLIMITED|DEFAULT}
| PASSWORD_REUSE_TIME {expression|UNLIMITED|DEFAULT}
| PASSWORD_REUSE_MAX {expression|UNLIMITED|DEFAULT}
}
}
The following list explains all of the elements used in the CREATE/ALTER/DROP
PROFILE commands’ syntax:
884 Appendixes
The following is the syntax for the ALTER ROLLBACK SEGMENT command:
The following is the syntax for the DROP ROLLBACK SEGMENT command:
The following list explains all of the elements used in the CREATE/ALTER/DROP
ROLLBACK SEGMENT command syntax:
CREATE SCHEMA
You can use the CREATE SCHEMA command to create multiple tables and views and
issue multiple grants in one go. All the create and grant statements used should
not end with a semicolon (;). If one of the statements fails, all of the statements will
be rolled back. The following is the syntax for the CREATE SCHEMA command:
The following list explains all of the elements used in the CREATE SCHEMA command
syntax:
886 Appendixes
CREATE/ALTER/DROP SNAPSHOT
The CREATE/ALTER/DROP SNAPSHOT commands are synonymous with the
CREATE/ALTER/DROP MATERIALIZED VIEW commands. See the section,
“CREATE/ALTER/DROP MATERIALIZED VIEW,” for details.
CREATE/ALTER/DROP/LOCK TABLE
You can use the CREATE/ALTER/DROP/LOCK TABLE commands to create, alter,
drop, or lock table database objects. In the CREATE LOCK TABLE and ALTER LOCK
TABLE commands, many clauses can be used to specify options ranging from
referential integrity rules to storage parameters. You can use the LOCK TABLE
command to explicitly lock a whole table to prevent other sessions from changing
the data or structure of the table. The following is the syntax for the CREATE TABLE
command for relational tables:
The following is the syntax for the CREATE TABLE command for object tables:
Listing A-15 provides the syntax for the ALTER TABLE command:
Listing A-16 provides the syntax for the LOCK TABLE command:
add_column_options := add_column_option[,add_column_option...]
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 888
888 Appendixes
add_range_partition_clause :=
ADD PARTITION [partition] VALUES LESS THAN (value_list)
[partition_description]
add_subpartition_clause :=
ADD SUBPARTITION [subpartition [subpartition_description]]
alter_overflow_clause :=
{ overflow_clause
| add_overflow_clause
| [PCTTHRESHOLD integer]
[INCLUDING column]
}
| {UNIQUE|PRIMARY KEY}
| {REFERENCES [schema.]table[(column)]
[ON DELETE {CASCADE|SET NULL}]
| CHECK (condition)
}
constraint_state
column_ref_constraint :=
{ SCOPE FOR ( {ref_column|ref_attribute} )
IS [schema.]scope_table
| REF ( {ref_column|ref_attribute} ) WITH ROWID
| [CONSTRAINT constraint]
FOREIGN KEY ( {ref_column|ref_attribute} ) references_clause
}
composite_partitioning_clause :=
PARTITION BY RANGE (column_list)
[subpartition_clause]
( partition_definition[,partition_definition...] )
constraint_state :=
[ { [ [NOT] DEFERRABLE ]
[ INITIALLY {IMMEDIATE|DEFERRED} ]
| [ INITIALLY {IMMEDIATE|DEFERRED} ]
[ [NOT] DEFERRABLE ]
}
]
[RELY|NORELY]
[USING INDEX [ [physical_attributes_clause]
[NOSORT]
{LOGGING|NOLOGGING}
]
[ENABLE|DISABLE]
[VALIDATE|NOVALIDATE]
[EXCEPTIONS INTO [schema.]table]
drop_column_clause :=
{ DROP {UNUSED COLUMNS|COLUMNS CONTINUE} [CHECKPOINT integer]
| DROP {COLUMN ( column[,column...] )
[CASCADE CONSTRAINTS]
[INVALIDATE]
[CHECKPOINT integer]
| SET UNUSED {COLUMN column|( column[,column...] )}
[CASCADE CONSTRAINTS]
[INVALIDATE]
}
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 890
890 Appendixes
en/disable :=
{ enable_disable_clause
| {ENABLE|DISABLE} {TABLE LOCK|ALL TRIGGERS}
}
enable_disable_clause :=
{ENABLE|DISABLE}
[VALIDATE|NOVALIDATE]
{ UNIQUE ( column[,column...] )
| PRIMARY KEY
| CONSTRAINT constraint
}
[using_index_clause]
[EXCEPTION INTO [schema.]table]
[CASCADE]
exchange_partition/subpartition_clause :=
EXCHANGE {PARTITION partition|SUBPARTITION subpartition}
WITH TABLE nonpartitioned_table
[ {INCLUDING|EXCLUDING} INDEXES ]
[ {WITH|WITHOUT} VALIDATION ]
[ EXCEPTIONS INTO [schema.]table ]
hash_partitioning_clause :=
PARTITION BY HASH (column_list)
[ { PARTITIONS quantity
[STORE IN ( table space[,table space...] )]
| ( PARTITION
[ partition partitioning_storage_clause
[partitioning_storage_clause...]
]
)
}
]
index_organized_overflow_clause :=
[INCLUDING column] OVERFLOW [segment_attributes_clause]
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 891
index_organized_table_clause :=
{ [segment_attributes_clause] [index_organized_overflow_clause]
[PCTTHRESHOLD integer] [index_organized_overflow_clause]
[compression_clause] [index_organized_overflow_clause]
}
LOB_parameters :=
{ [TABLESPACE table space]
[{ENABLE|DISABLE} STORAGE IN ROW]
[storage_clause]
[CHUNK integer]
[PCTVERSION integer]
[CACHE|NOCACHE [LOGGING|NOLOGGING]]
}
LOB_storage_clause := LOB
{ ( LOB_item[,LOB_item...] ) STORE AS (LOB_parameters)
| (LOB_item) STORE AS
{ (LOB_parameters)
| LOB_segname
| LOB_segname (LOB_parameters)
}
}
merge_partitions_clause :=
MERGE PARTITIONS partition_1,partition_2
[INTO PARTITION [new_partition [partition_description]]]
modify_collection_retrieval_clause :=
MODIFY NESTED TABLE collection_item
RETURN AS {LOCATOR|VALUE}
modify_column_options :=
modify_column_option[,modify_column_option...]
modify_column_option :=
{ column [datatype] [DEFAULT expression]
column_constraint[column_constraint...]
| {VARRAY|NESTED TABLE}
collection_item
[RETURN AS {LOCATOR|VALUE}]
}
modify_default_attributes_clause :=
MODIFY DEFAULT ATTRIBUTES [FOR PARTITION partition]
segment_attributes_clause
[PCTTHRESHOLD integer]
[COMPRESS|DECOMPRESS]
[overflow_clause]
[ LOB LOB_item LOB_parameters[LOB LOB_item LOB_parameters...] ]
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 892
892 Appendixes
modify_LOB_storage_parameters :=
[storage_clause]
[PCTVERSION integer]
[CACHE|NOCACHE {LOGGING|NOLOGGING}]
[allocate_extent_clause]
[deallocate_unused_clause]
move_subpartition_clause :=
MOVE SUBPARTITION subpartition subpartition_description
nested_table_storage_clause :=
NESTED TABLE nested_item STORE AS storage_table
[((object_properties) physical_properties)]
[RETURN AS {LOCATOR|VALUE}]
object_properties :=
{ {table_constraint|table_ref_constraint}
| {column|attribute}
[DEFAULT expression]
[column_ref_constraint]
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 893
[column_constraint[column_constraint...]]
}
overflow_clause := OVERFLOW
[physical_attributes_clause]
[allocate_extent_clause]
[deallocate_unused_clause]
[LOGGING|NOLOGGING]
partition_attributes :=
[physical_attributes_clause]
[LOGGING|NOLOGGING]
[allocate_extent_clause|deallocate_unused_clause]
[OVERFLOW physical_attributes_clause]
[ LOB LOB_item modify_LOB_storage_parameters
[LOB LOB_item modify_LOB_storage_parameters...]
]
partitioning_clauses :=
{ modify_default_attributes_clause
| modify_partition_clause
| modify_subpartition_clause
| move_partition_clause
| move_subpartition_clause
| {add_range_partition_clause|add_hash_partition_clause}
| coalesce_partition_clause
| drop_partition_clause
| rename_partition/subpartition_clause
| truncate_partition/subpartition_clause
| split_partition_clause
| merge_partitions_clause
| exchange_partition/subpartition_clause
| row_movement_clause
}
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 894
894 Appendixes
partition_description := segment_attributes_clause
[compression_clause]
[OVERFLOW [compression_clause]]
[ [LOB_storage_clause]
[varray_storage_clause]
]
[partition_level_subpartitioning]
partition_level_subpartitioning :=
{ SUBPARTITIONS quantity
[STORE IN ( table space[,table space...] )
| ( SUBPARTITION [subpartition partitioning_storage_clause]
[SUBPARTITION [subpartition
partitioning_storage_clause],...]
)
}
partitioning_storage_clause :=
[TABLESPACE table space]
[ [LOB_storage_clause]
[varray_storage_clause]
]
physical_properties :=
[ segment_attributes_clause
| ORGANIZATION { INDEX index_organized_table_clause
| HEAP [segment_attributes_clause]
}
| CLUSTER cluster ( column[,column...] )
]
[ [LOB_storage_clause]
[varray_storage_clause]
[nested_table_storage_clause]
]
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 895
range_partitioning_clause :=
PARTITION BY RANGE (column_list)
( partition_definition[,partition_definition...] )
records_per_block_clause :=
{MINIMIZE|NOMINIMIZE} RECORDS_PER_BLOCK
relational_properties :=
relational_property[,relational_property...]
relational_property :=
{ [ column datatype
[DEFAULT expression]
[column_ref_constraint]
[column_constraint[column_constraint...]]
]
[ {table_constraint|table_ref_constraint} ]
}
rename_partition/subpartition_clause :=
RENAME {PARTITION|SUBPARTITION} current_name TO new_name
segment_attributes_clause :=
[ [physical_attributes_clause]
[LOGGING|NOLOGGING]
]
split_partition_clause :=
SPLIT PARTITION partition_name_old AT (value_list)
[INTO (partition_descr,partition_descr)]
[parallel_clause]
storage_clauses :=
{ modify_LOB_storage_clause[,modify_LOB_storage_clause...]
| varray_storage_clause[,varray_storage_clause...]
| modify_varray_storage_clause[modify_varray_storage_clause...]
| nested_table_storage_clause[,nested_table_storage_clause...]
}
subpartition_clause :=
SUBPARTITION BY HASH ( column_list[,column_list...] )
[SUBPARTITIONS quantity
[STORE IN ( table space[,table space...] )
]
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 896
896 Appendixes
table_ref_constraint :=
{ SCOPE FOR ( {ref_column|ref_attribute} ) IS
[schema.]scope_table
| REF ( {ref_column|ref_attribute} ) WITH ROWID
| [CONSTRAINT constraint]
FOREIGN KEY ( {ref_column|ref_attribute} ) references_clause
table_properties :=
[ range_partitioning_clause [row_movement_clause]
| hash_partitioning_clause [row_movement_clause]
| composite_partitioning_clause [row_movement_clause]
]
[CACHE|NOCACHE]
[MONITORING|NOMONITORING]
[parallel_clause]
[enable_disable_clause[enable_disable_clause...]]
[AS subquery]
truncate_partition/subpartition_clause :=
TRUNCATE {PARTITION partition|SUBPARTITION subpartition}
[ {DROP|REUSE} STORAGE ]
| LOB_segname
| (LOB_parameters)
}
898 Appendixes
900 Appendixes
902 Appendixes
904 Appendixes
906 Appendixes
908 Appendixes
CREATE/ALTER/DROP TABLESPACE
You use the CREATE/ALTER/DROP TABLESPACE commands to create, alter, and drop
tablespaces. Tablespaces are the logical storage units that make up a database. A
tablespace provides the storage for database objects. These objects can be stored
in one or more data files. You can specify the storage parameters and management
options using the CREATE and ALTER statements. The following is the syntax for the
CREATE TABLESPACE command:
Listing A-17 provides the syntax for the DROP TABLESPACE command:
autoextend_clause := AUTOEXTEND
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 909
{ OFF
| ON
[NEXT integer [K|M]]
[MAXSIZE {UNLIMITED|integer [K|M]}]
}
datafile_tempfile_clauses :=
{ ADD {DATAFILE|TEMPFILE} file_spec [autoextend_clause]
[file_spec
[autoextend_clause]...]
| RENAME DATAFILE ‘filename’[,’filename’...]
TO ‘filename’[,’filename’...]
}
The following list explains all of the elements used in the CREATE/ALTER/DROP
TABLESPACE commands’ syntax:
910 Appendixes
Temporary tablespaces can store only temporary objects. These may be temporary
tables or they may be temporary segments created by Oracle while processing
certain DML or DDL statements. There is a significant performance gain if
temporary segments are stored in a temporary tablespace.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 912
912 Appendixes
Note A temporary tablespace can only be a locally managed tablespace; whereas, you
can also create a temporary tablespace using the CREATE TABLESPACE com-
mand and specify TEMPORARY as an attribute. In that case you can then use dic-
tionary managed storage.
The following is the syntax for the CREATE TEMPORARY TABLESPACE command:
autoextend_clause := AUTOEXTEND
{ OFF
| ON [NEXT integer [K|M]
[MAXSIZE {UNLIMITED|integer [K|M]}]
}
The following list explains all of the elements used in the CREATE TEMPORARY
TABLESPACE command syntax:
CREATE/ALTER/DROP TRIGGER
The CREATE and DROP TRIGGER commands allow you to create or delete triggers
for events in the database. You can use the ALTER TRIGGER command to enable or
disable the trigger and to compile the trigger code. Listing A-18 provides the syntax
for the CREATE TRIGGER command:
Listing A-19 provides the syntax for the DROP TRIGGER command.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 914
914 Appendixes
database_event := {SERVERERROR|LOGON|LOGOFF|STARTUP|SHUTDOWN}
ddl_event := {CREATE|ALTER|DROP}
dml_event :=
{ DELETE
| INSERT
| UPDATE [OF column[,column...]]
} ON
{ [schema.]table
| [NESTED TABLE nested_table_column OF]
[schema.]view
}
referencing_clause := REFERENCING
{ OLD [AS] old
| NEW [AS] new
| PARENT [AS] parent
}
[FOR EACH ROW]
The following list explains all of the elements used in the CREATE/ALTER/DROP
TRIGGER commands’ syntax:
916 Appendixes
CREATE/ALTER/DROP TYPE
You can use the CREATE/ALTER/DROP TYPE commands to create, alter, or drop
user-defined type database objects. The user defined types may be any of the
following types:
You may also create an incomplete type, which is a forward definition of the type.
This can be used when creating types that reference each other. The following is
the syntax for the CREATE TYPE command for incomplete types:
The following is the syntax for the CREATE TYPE command for object types:
The following is the syntax for the CREATE TYPE command for varying array types:
The following is the syntax for the CREATE TYPE command for nested table types:
Listing A-20 provides the syntax for the DROP TYPE command:
directive := {RNDS|WNDS|RNPS|WNPS|TRUST}
pragma_clauses := pragma_clause[pragma_clause...]
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 918
918 Appendixes
The following list explains all of the elements used in the CREATE/ALTER/DROP
TYPE commands’ syntax:
920 Appendixes
Listing A-21 provides the syntax for the DROP TYPE BODY command:
The following list explains all of the elements used in the CREATE/DROP TYPE BODY
commands’ syntax:
922 Appendixes
CREATE/ALTER/DROP VIEW
You can use the CREATE/ALTER/DROP VIEW commands to create, alter, or drop
view database objects. Views are table-like structures that are based on a query on
one or more tables or views. A view doesn’t contain the data itself. Views can also
be created on object tables or object views.
Listing A-22 provides the syntax for the CREATE VIEW command:
924 Appendixes
The following list explains all of the elements used in the CREATE/ALTER/DROP
VIEW commands’ syntax:
DELETE
You use the DELETE command to remove some or all rows from a table or view.
Listing A-23 provides the syntax for the DELETE command:
The following list explains all of the elements used in the DELETE command syntax:
926 Appendixes
EXPLAIN PLAN
You can use the EXPLAIN PLAN command to generate the Oracle execution plan
for a SQL statement. The execution plan shows the operations Oracle performs
internally to execute the SQL statement. The output of EXPLAIN PLAN is stored in
an output table for which the details are specified in the list that follows. If you use
the cost-based optimization, EXPLAIN PLAN also determines the cost of executing
the statement. The following is the syntax for the EXPLAIN PLAN command:
The following list explains all of the elements used in the EXPLAIN PLAN command
syntax:
The output table in which the output from the EXPLAIN PLAN command is
collected is usually called plan_table and can be created using the utlxplan.sql
file. The following table provides the table description:
STATEMENT_ID VARCHAR2(30)
TIMESTAMP DATE
REMARKS VARCHAR2(80)
OPERATION VARCHAR2(30)
OPTIONS VARCHAR2(30)
OBJECT_NODE VARCHAR2(128)
OBJECT_OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
OBJECT_INSTANCE NUMBER(38)
OBJECT_TYPE VARCHAR2(30)
OPTIMIZER VARCHAR2(255)
SEARCH_COLUMNS NUMBER
ID NUMBER(38)
PARENT_ID NUMBER(38)
POSITION NUMBER(38)
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 928
928 Appendixes
COST NUMBER(38)
CARDINALITY NUMBER(38)
BYTES NUMBER(38)
OTHER_TAG VARCHAR2(255)
PARTITION_START VARCHAR2(255)
PARTITION_STOP VARCHAR2(255)
PARTITION_ID NUMBER(38)
OTHER LONG
object := {user|role|PUBLIC}
The following list explains all of the elements used in the GRANT command syntax:
WITH GRANT OPTION Specifies that the grantee can grant the object
privileges to other users or roles.
object_privilege Specifies the object privilege to be granted. See
Table A-5 in the section “Reference Tables” for all
object privileges.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 929
GRANT privilege[,privilege...]
TO object[,object...]
[WITH ADMIN OPTION]
object := {user|role|PUBLIC}
privilege := {system_privilege|role}
The following list explains all of the elements used in the GRANT command syntax:
WITH ADMIN OPTION Specifies that the grantee can grant/revoke the role
to/from another user or role. Also, the grantee can
alter and drop the role.
system_privilege Specifies the system privilege to be granted. See
Table A-4 in the section “Reference Tables” for all
system privileges.
user Specifies the user to grant the privileges to.
role Specifies the role to grant or the role to grant the
privileges to.
PUBLIC Specifies that the privileges are granted to all users.
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 930
930 Appendixes
INSERT
You use the INSERT statement to insert data into a table, a view, or an inline view.
The data to insert may be specifies as a list of values or a subquery. Listing A-25
provides the syntax for the INSERT command.
The following list explains all of the elements used in the INSERT command syntax:
NOAUDIT object_option[,object_option...] ON
{ DEFAULT
| DIRECTORY directory_name
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 932
932 Appendixes
| [schema.]object
}
[ BY {SESSION|ACCESS} ]
[ WHENEVER [NOT] SUCCESSFUL ]
The following list explains all of the elements used in the NOAUDIT command
syntax:
NOAUDIT option[,option...]
[BY { user[,user...]
| proxy [ON BEHALF OF
{ ANY
| user[,user...]
}
}
]
[WHENEVER [NOT] SUCCESSFUL]
option :=
{statement_option|system_privilege}
The following list explains all of the elements used in the NOAUDIT command
syntax:
object := {user|role|PUBLIC}
934 Appendixes
The following list explains all of the elements used in the REVOKE command syntax:
REVOKE privilege[,privilege...]
FROM object[,object...]
privilege := {system_privilege|role}
object := {user|role|PUBLIC}
The following list explains all of the elements used in the REVOKE command syntax:
SELECT
You can use the SELECT command to retrieve data from the database. Data can be
retrieved from tables, object tables, views, object views, and materialized views or
snapshots. Listing A-27 provides the syntax for the SELECT command:
data_source :=
{ TABLE (collection_expression) [(+)]
| (subquery [WITH { READ ONLY
| CHECK OPTION [CONSTRAINT constraint]
}
]
)
| [schema.]table[@dblink]
| [schema.]table PARTITION(partition_name)
| [schema.]table SUBPARTITION(subpartition_name)
| [schema.]table SAMPLE [BLOCK] (percent)
| [schema.]view[@dblink]
| [schema.]snapshot[@dblink]
} table_alias
order_item :=
{ expression [ASC|DESC]
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 936
936 Appendixes
outer_join := table1.column
{ = table2.column (+)
| (+) = table2.column
}
select_item :=
[ expression [AS] column_alias
| { [schema.]table.*
| [schema.]table.column
| [schema.]view.*
| [schema.]view.column
| [schema.]snapshot.*
| [schema.]snapshot.column
}
]
update_column :=
{ [schema.]table.column
| [schema.]view.column
}
The following list explains all of the elements used in the SELECT command syntax:
938 Appendixes
SET TRANSACTION
You can use the SET TRANSACTION command to alter the transaction settings. You
can set the transaction to be read only or read/write, and you can control how
Oracle handles DML statements that try to modify data that is currently modified in
other, uncommitted transactions. You can also use SET TRANSACTION to explicitly
specify the rollback segment. If omitted, Oracle will choose a rollback segment for
the transaction. The following is the syntax for the SET TRANSACTION command:
SET TRANSACTION
{ READ ONLY
| READ WRITE
| ISOLATION LEVEL {SERIALIZABLE|READ COMMITTED}
| USE ROLLBACK SEGMENT rollback_segment
}
The following list explains all of the elements used in the SET TRANSACTION
command syntax:
940 Appendixes
UPDATE
You can use the UPDATE command to update rows in tables, views, and snapshots.
Listing A-28 provides the syntax for the UPDATE command:
assignment_expression :=
{ column = {expression|(subquery)}
| (column[,column...]) = (subquery[,subquery...])
}
table_expression :=
{ TABLE (collection_expression) [(+)]
| (subquery [WITH { READ ONLY
| CHECK OPTION [CONSTRAINT constraint]
}
]
)
| { [schema.]view[@dblink]
| [schema.]snapshot[@dblink]
| [schema.]table[@dblink]
| [schema.]table
{ SAMPLE [BLOCK] (percent)
| {PARTITION (partition)|SUBPARTITION (subpartition)}
}
}
} table_alias
The following list explains all of the elements used in the UPDATE command syntax:
942 Appendixes
Common clauses
This section describes clauses that many commands use.
The following list explains all of the elements used in the file_spec clause syntax:
parallel_clause :=
{ NOPARALLEL
| PARALLEL [integer]
}
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 943
The following list explains all of the elements used in the parallel_clause clause
syntax:
physical_attributes :=
[PCTUSED integer]
[PCTFREE integer]
[INITRANS integer]
[MAXTRANS integer]
[SIZE integer [K|M]]
[TABLESPACE table space]
[storage_clause]
The following list explains all of the elements used in the physical_attributes
clause syntax:
944 Appendixes
storage_clause := STORAGE
( [INITIAL integer [K|M]]
[NEXT integer [K|M]]
[MINEXTENTS integer]
[MAXEXTENTS {integer|UNLIMITED}]
[PCTINCREASE integer]
[FREELISTS integer]
[FREELIST GROUPS integer]
[OPTIMAL [NULL|integer [K|M] ]]
[BUFFER_POOL {KEEP|RECYCLE|DEFAULT}
)
The following list explains all of the elements used in the storage_clause clause
syntax:
Reference tables
Tables A-1 through A-5 provide information about statement options, shortcuts for
statement privileges, system privileges, and object options and types.
Table A-1
Statement Options
statement_option Statements and Operations
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 946
946 Appendixes
Table A-2
Additional Statement Options
statement_option Statements and Operations
| COLUMN { table.column
| view.column
| snapshot.column
}
}
DELETE TABLE DELETE FROM {table|view}
EXECUTE PROCEDURE Audits whenever any package, procedure, function or
library is referenced; for example: executing a function
inside a package, a reading, or setting a variable inside
a package
GRANT DIRECTORY {GRANT|REVOKE} privilege ON directory
GRANT PROCEDURE {GRANT|REVOKE} privilege ON
{procedure|function|package}
GRANT SEQUENCE {GRANT|REVOKE} privilege ON sequence
GRANT TABLE {GRANT|REVOKE} privilege ON
{table|view|snapshot}
GRANT TYPE {GRANT|REVOKE} privilege ON TYPE
INSERT TABLE INSERT INTO {table|view}
LOCK TABLE LOCK TABLE {table|view}
SELECT SEQUENCE Audits whenever CURRVAL or NEXTVAL is used in a
statement
SELECT TABLE SELECT FROM {table|view|snapshot}
UPDATE TABLE UPDATE {table|view}
Table A-3
Shortcuts for Statement Privileges
Shortcut Equivalent
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 948
948 Appendixes
Table A-4
System Privileges
system_privilege Operations Authorized to Grantee
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 950
950 Appendixes
Continued
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 952
952 Appendixes
Table A-5
Object Options and the Object Types to
Which They Are Applicable
Procedure
object_ Function
option Directory Library Sequence Snapshot Table View Package
ALTER ✓ ✓ ✓
AUDIT ✓ ✓ ✓ ✓ ✓ ✓
COMMENT ✓ ✓ ✓ ✓
DELETE ✓ ✓ ✓ ✓
EXECUTE ✓ ✓
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 953
Procedure
object_ Function
option Directory Library Sequence Snapshot Table View Package
GRANT ✓ ✓ ✓ ✓ ✓ ✓ ✓
INDEX ✓ ✓ ✓
INSERT ✓ ✓ ✓ ✓
LOCK ✓ ✓ ✓ ✓
READ ✓
RENAME ✓ ✓ ✓ ✓ ✓
SELECT ✓ ✓ ✓ ✓
UPDATE ✓ ✓ ✓ ✓
Materialized User-
object_ View/ Defined Index
option Snapshot Directory Type Operator Type
ALTER
AUDIT
COMMENT
DELETE ✓
EXECUTE ✓ ✓ ✓
GRANT
INDEX
INSERT ✓
LOCK
READ ✓
RENAME
SELECT ✓
UPDATE ✓
✦ ✦ ✦
4623-6 AppA.f.qc 1/28/00 12:35 PM Page 954