Tải bản đầy đủ (.pdf) (135 trang)

Oracle Database 10g The Complete Reference phần 9 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (857.95 KB, 135 trang )

CONDITION
A condition is an expression whose value evaluates to either TRUE or FALSE, such as Age > 65.
CONNECT (Form 1—SQL*Plus))
SEE ALSO
COMMIT, DISCONNECT, Chapter 23
FORMAT
CON[NECT] [{
user
[/
password
] [@
connect_identifier
] |/} [AS SYSOPER|SYSDBA}]];
DESCRIPTION You must be in SQL*Plus to use this command, although you don’t need to be
logged onto Oracle (
see
DISCONNECT). CONNECT commits any pending changes, logs you off of
Oracle, and logs on as the specified
user.
If the
password
is absent, you are prompted for it. It is not
displayed when you type it in response to a prompt.
@connect_identifier
connects to the named database. It may be on your host, or on another computer
connected via Oracle Net.
CONNECT (Form 2—Embedded SQL)
SEE ALSO
COMMIT, DECLARE DATABASE, Chapter 23
FORMAT
EXEC SQL CONNECT


{ :user IDENTIFIED BY :
password
| :
user_password
}
[AT {
database
| :
host_variable
}]
[USING :
connect_string
]
[ALTER AUTHORIZATION :
new_password
| IN {SYSDBA | SYSOPER } MODE ]
DESCRIPTION
CONNECT connects a host program to a local or remote database. It may be used
more than once to connect to multiple databases. :
user_password
is a host variable that contains the
Oracle username and password separated by a slash (/). Alternatively, :
user
and :
password
can be entered
separately by using the second format.
AT is used to name a database other than the default for this user. It is a required clause to reach
any databases other than the user’s default database. This name can be used later in other SQL statements
with AT. This database must be first identified with DECLARE DATABASE. USING specifies an optional

Oracle Net string (such as a service name) used during the CONNECT operation. Without the USING
string, you will be connected to the user’s default database, regardless of the database named in the
AT line.
CONNECT BY
SEE ALSO Chapter 14
FORMAT
SELECT
expression
[,
expression
]
FROM [
user
.]
table
WHERE
condition
CONNECT BY [PRIOR]
expression
= [PRIOR]
expression
START WITH
expression
=
expression
ORDER BY
expression
CONNECT BY
1063
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1

Blind Folio 1:1063
P:\010Comp\Oracle8\351-7\Part9A.vp
Friday, August 13, 2004 3:14:12 PM
Color profile: Generic CMYK printer profile
Composite Default screen
DESCRIPTION
CONNECT BY is an operator used in a SELECT statement to create reports on
inheritance in tree-structured data, such as company organization, family trees, and so on. START
WITH tells where in the tree to begin. These are the rules:

The position of PRIOR with respect to the CONNECT BY expressions determines which
expression identifies the root and which identifies the branches of the tree.

A WHERE clause will eliminate individuals from the tree, but not their descendants (or ancestors,
depending on the location of PRIOR).

A qualification in the CONNECT BY (particularly a not equal sign instead of the equal sign)
will eliminate both an individual and all of its descendants.

CONNECT BY cannot be used with a table join in the WHERE clause.
EXAMPLE
select Cow, Bull, LPAD(' ',6*(Level-1))||Offspring AS Offspring,
Sex, Birthdate
from BREEDING
connect by Offspring = PRIOR Cow
start with Offspring = 'DELLA'
order by Birthdate;
In this example, the following clause:
connect by Offspring = PRIOR Cow
means the offspring is the cow PRIOR to this one.

CONSTRAINT
A constraint is a rule or restriction concerning a piece of data (such as a NOT NULL restriction on a
column) that is enforced at the data level rather than at the object or application level.
See
INTEGRITY
CONSTRAINT.
CONSTRAINTS
SEE ALSO
CREATE TABLE, INTEGRITY CONSTRAINT, Chapter 17
FORMAT
constraint::=
1064
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1064
inline_constraint
out_of_line_constraint
inline_ref_constraint
out_of_line_ref_constraint
P:\010Comp\Oracle8\351-7\Part9A.vp
Friday, August 13, 2004 3:14:13 PM
Color profile: Generic CMYK printer profile
Composite Default screen
inline_constraint::=
out_of_line_constraint::=
inline_ref_constraint::=
out_of_line_ref_constraint
CONSTRAINTS
1065
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1

Blind Folio 1:1065
CONSTRAINT constraint_name
NOT
NULL
UNIQUE
PRIMARY KEY
references_clause
CHECK ( condition )
constraint_state
CONSTRAINT constraint_name
UNIQUE ( column
,
)
PRIMARY KEY ( column
,
)
FOREIGN KEY ( column
,
) references_clause
CHECK ( condition )
constraint_state
SCOPE IS
schema .
scope_table
WITH ROWID
CONSTRAINT constraint_name
references_clause
constraint_state
SCOPE FOR (
ref_col

ref_attr
) IS
schema .
scope_table
REF (
ref_col
ref_attr
) WITH ROWID
CONSTRAINT constraint_name
FOREIGN KEY (
ref_col
ref_attr
) references_clause
constraint_state
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:46 PM
Color profile: Generic CMYK printer profile
Composite Default screen
references_clause::=
constraint_state::=
using_index_clause::=
index_properties::=
1066
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1066
NOT
DEFERRABLE
INITIALLY
IMMEDIATE

DEFERRED
ENABLE
DISABLE
VALIDATE
NOVALIDATE
RELY
NORELY
using_index_clause
exceptions_clause
USING INDEX
schema .
index
( create_index_statement )
index_properties
global_partitioned_index
local_partitioned_index
index_attributes
domain_index_clause
REFERENCES
schema .
object
( column )
ON DELETE
CASCADE
SET NULL
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:46 PM
Color profile: Generic CMYK printer profile
Composite Default screen
index_attributes::=

exceptions_clause::=
DESCRIPTION
Constraints are defined with the RELATIONAL_PROPERTIES clause of the CREATE
TABLE and ALTER TABLE commands. You use the constraints clauses to create a constraint or to alter
an existing constraint. You can enable and disable constraints. If you disable a constraint and then try
to re-enable it, Oracle will check the data. If the constraint cannot be re-enabled, Oracle can write the
exceptions out to a separate table for review.
For PRIMARY KEY and UNIQUE constraints, Oracle creates indexes. As part of the constraint clause for
those constraints, you can use the USING INDEX clause to specify the tablespace and storage for the index.
CONTAINS
CONTAINS is used to evaluate text searches that use CONTEXT indexes within Oracle Text.
See
Chapter 25. Supported text search operators for CONTAINS are shown in the following table:
Operator Description
OR Returns a record if either search term has a score that exceeds the threshold.
| Same as OR.
AND Returns a record if both search terms have a score that exceeds the threshold.
& Same as AND.
ACCUM Returns a record if the sum of the search terms’ scores exceeds the threshold.
, Same as ACCUM.
CONTAINS
1067
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1067
EXCEPTIONS INTO
schema .
table
physical_attributes_clause
logging_clause
ONLINE

COMPUTE STATISTICS
TABLESPACE
tablespace
DEFAULT
key_compression
SORT
NOSORT
REVERSE
parallel_clause
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:47 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Operator Description
MINUS Returns a record if the score of the first search minus the score of the second search exceeds
the threshold.
- Same as MINUS.
* Assigns different weights to the score of the searches.
NEAR The score will be based on how near the search terms are to each other in the searched text.
; Same as NEAR.
{} Encloses reserved words such as AND if they are part of the search term.
% Multiple-character wildcard.
_ Single-character wildcard.
$ Performs stem expansion of the search term prior to performing the search.
? Performs a fuzzy match (allowing for misspellings) of the search term prior to performing
the search.
!
Performs a SOUNDEX (phonetic) search.
() Specifies the order in which search criteria are evaluated.
CONTEXT AREA

A context area is work area in memory where Oracle stores the current SQL statement and, if the statement
is a query, one row of the result. The context area holds the state of a cursor.
CONTEXT INDEX
Oracle Text supports three types of text indexes: CONTEXT indexes, CTXCAT indexes, and CTXRULE
indexes. CONTEXT indexes use the CONTAINS operator and support a wider array of text search
capabilities. CTXCAT indexes support a narrower set of search operators but support the creation of
index sets. CTXRULE indexes are indexes on columns that contain a set of text queries.
See
Chapter 25
for details.
CONTROL FILE (DATABASE)
A control file is a small administrative file that is required by every database to enable the database to
start and run a database system. Multiple identical control files are created for redundancy.
CONTROL FILE (SQL*LOADER)
A SQL*Loader control file tells the SQL*Loader executable where to find the data to be loaded, and
how to process the data during the load. Every SQL*Loader session has an associated control file.
For control file syntax, see SQLLDR. For details on the use of SQL*Loader, see Chapter 21.
CONVERSION FUNCTIONS
SEE ALSO CHARACTER FUNCTIONS, NUMBER FUNCTIONS, AGGREGATE FUNCTIONS,
Chapter 11
DESCRIPTION The following is an alphabetical list of all current conversion and transformation
functions in Oracle version of SQL.
1068
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1068
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:47 PM
Color profile: Generic CMYK printer profile
Composite Default screen

Function Name Definition
ASCIISTR
Translates a string in any character set and returns an ASCII string in the database
character set.
BIN_TO_NUM
Converts a binary value to its numerical equivalent.
CAST
CASTs one built-in or collection type to another; commonly used with nested tables
and varying arrays.
CHARTOROWID
Changes a character string to act like an internal Oracle row identifier, or ROWID.
COMPOSE
Translates a string in any datatype to a Unicode string in its fully normalized form in the
same character set as the input.
CONVERT
CONVERTs a character string from one national language character set to another.
DECOMPOSE
Translates a string in any datatype to a Unicode string after canonical decomposition in
the same character set as the input.
HEXTORAW
Changes a character string of hex numbers into binary.
NUMTODSINTERVAL
Converts a NUMBER to an INTERVAL DAY TO SECOND literal.
NUMTOYMINTERVAL
Converts a NUMBER to an INTERVAL YEAR TO MONTH literal.
RAWTOHEX
Changes a string of binary numbers to a character string of hex numbers.
RAWTONHEX
Converts RAW to an NVARCHAR2 character value containing its hexadecimal
equivalent.

ROWIDTOCHAR
Changes an internal Oracle row identifier, or ROWID, to a character string.
ROWIDTONCHAR
Converts a ROWID value to an NVARCHAR2 datatype.
SCN_TO_TIMESTAMP
Converts a system change number to an approximate timestamp.
TIMESTAMP_TO_SCN
Converts a timestamp to an approximate system change number.
TO_BINARY_DOUBLE
Returns a double-precision floating-point number.
TO_BINARY_FLOAT
Returns a single-precision floating-point number.
TO_CHAR
Converts a NUMBER or DATE to a character string.
TO_CLOB
Converts NCLOB values in a LOB column or other character strings to CLOB values.
TO_DATE
Converts a NUMBER, CHAR, or VARCHAR2 to a DATE (an Oracle datatype).
TO_DSINTERVAL
Converts a character string of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype
to an INTERVAL DAY TO SECOND type.
TO_LOB Converts a LONG to a LOB as part of an INSERT AS SELECT.
TO_MULTI_BYTE
Converts the single-byte characters in a character string to multibyte characters.
TO_NCHAR
Converts a character string, NUMBER, or DATE from the database character set to the
national character set.
TO_NCLOB
Converts CLOB values in a LOB column or other character strings to NCLOB values.
TO_NUMBER

Converts a CHAR or VARCHAR2 to a number.
TO_SINGLE_BYTE
Converts the multibyte characters in a CHAR or VARCHAR2 to single bytes.
TO_TIMESTAMP
Converts a character string to a value of TIMESTAMP datatype.
CONVERSION FUNCTIONS
1069
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1069
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:47 PM
Color profile: Generic CMYK printer profile
Composite Default screen
Function Name Definition
TO_TIMESTAMP_TZ
Converts a character string to a value of TIMESTAMP WITH TIME ZONE datatype.
TO_YMINTERVAL
Converts a character string of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype
to an INTERVAL YEAR TO MONTH type.
TRANSLATE…USING TRANSLATEs characters in a string into different characters.
UNISTR
Converts a string into Unicode in the database Unicode character set.
CONVERT
SEE ALSO CONVERSION FUNCTIONS
FORMAT
CONVERT(string,[destination_set,[source_set]])
DESCRIPTION
CONVERT is used to convert the characters in
string
from one standard bit

representation to another, such as from US7ASCII (the default if either set isn’t entered) to WE8DEC.
This is typically done when data entered into a column on one computer contains characters that can’t
be properly displayed or printed on another computer. CONVERT allows a reasonable translation of
one standard to the other in most cases. The most common sets include:
F7DEC DEC’s 7-bit ASCII set for France
US7ASCII Standard U.S. 7-bit ASCII set
WE8DEC DEC’s 8-bit ASCII set for Western Europe
WE8HP HP’s 8-bit ASCII set for Western Europe
WE8ISO8859P1 ISO 8859-1 Western Europe 8-bit character set
WE8EBCDIC500
WE8PC850
IBM West European EBCDIC Code Page 500
IBM PC Code Page 850
COPY (SQL*Plus)
NOTE
The SQL*Plus COPY command is not being enhanced to handle
datatypes or features introduced with, or after, Oracle8
i
. The COPY
command is likely to be made obsolete in a future release.
SEE ALSO
CREATE DATABASE LINK, Chapter 23
FORMAT
COPY [FROM
user
/
password@database
]
[TO
user

/
password@database
]
{APPEND | CREATE | INSERT | REPLACE}
table
[ (
column
[,
column
] ) ]
USING
query
1070
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1070
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:49 PM
Color profile: Generic CMYK printer profile
Composite Default screen
DESCRIPTION
COPY copies FROM a table TO a table in another computer using Oracle Net.
FROM is the username, password, and database of the source table, and TO is the destination table.
Either FROM or TO may be omitted, in which case the user’s default database will be used for the
missing clause. The source and destination databases must not be the same, so only one of the FROM
and TO clauses may be absent.
APPEND adds to the destination table; if the table does not exist, it is created. CREATE requires
that the destination table be created; if it already exists, a 'table already exists' error occurs. INSERT
adds to the destination table; if the table does not exist, a 'table does not exist' error occurs. REPLACE
drops the data in the destination table and replaces it with the data from the source table; if the table

does not exist, it is created.
table
is the name of the destination table.
column
is the name(s) of the column(s) in the destination
table. If named, the number of columns must be the same as in the query. If no columns are named,
the copied columns will have the same names in the destination table as they had in the source table.
query
identifies the source table and determines which rows and columns will be copied from it.
SET LONG (
see
SET) determines the length of a long field that can be copied. LONG columns with
data longer than the value of LONG will be truncated. SET COPYCOMMIT determines how many sets
of rows get copied before a commit. SET ARRAYSIZE determines how many rows are in a set.
EXAMPLE This example copies BOOKSHELF_CHECKOUT from the EDMESTON database to the
database the local SQL*Plus user is connected to. The table LOCAL_CHECKOUT is created by the copy.
The columns may be renamed at the destination. Note the use of the dash (-) at the end of each line.
This is required. The command does not end with a semicolon (since it is a SQL*Plus command, not
a SQL command).
See
the SET command for options related to the COPY command.
copy from PRACTICE/PRACTICE@EDMESTON -
create LOCAL_CHECKOUT (Borrower, Title) -
using select Name, Title -
from BOOKSHELF_CHECKOUT
COPYCOMMIT (SQL*Plus)
See
SET and COPY.
COPYTYPECHECK (SQL*Plus)
See

SET and COPY.
CORR
SEE ALSO AGGREGATE FUNCTIONS
FORMAT
CORR (
expr1
,
expr2
) [OVER (
analytic_clause
)]
DESCRIPTION
CORR returns the coefficient of correlation of a set of number pairs. Both
expr1
and
expr2
are number expressions. Oracle applies the function to the set of (
expr1
,
expr2
) after eliminating
the pairs for which either
expr1
or
expr2
is NULL. Then Oracle makes the following computation:
COVAR_POP(
expr1
,
expr2

) / (STDDEV_POP(
expr1
) * STDDEV_POP(
expr2
))
The function returns a value of type NUMBER. If the function is applied to an empty set, it
returns NULL.
CORR
1071
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1071
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:50 PM
Color profile: Generic CMYK printer profile
Composite Default screen
CORR
SEE ALSO
CORR_K and CORR_S
FORMAT
CORR (
expr1
,
expr2
) OVER (
analytic clause
)
DESCRIPTION
CORR returns the coefficient of correlation on a set of number pairs. CORR can
be used as an aggregate or analytic function.
CORR_K and CORR_S

SEE ALSO
CORR
FORMAT
{CORR_K | CORR_S }
(
expr1
,
expr2
[, { COEFFICIENT |ONE_SIDED_SIG|TWO_SIDED_SIG}])
DESCRIPTION
The CORR_K and CORR_S functions support nonparametric or rank correlations.
Correlation coefficients take a value ranging from 1 to –1 where 1 indicates a perfect relationship and
–1 a perfect inverse relationship. The arguments must either be numeric or implicitly converted to a
numeric datatype. ONE_SIDED_SIG is for one-tailed significance of the correlation, TWO_SIDED_SIG
is for two-tailed significance.
CORRELATED QUERY
A correlated query is a subquery that is executed repeatedly, once for each value of a candidate row
selected by the main query. The outcome of each execution of the subquery depends on the values of
one or more fields in the candidate row; that is, the subquery is correlated with the main query.
See
Chapter 13.
COS
SEE ALSO
ACOS, ASIN, ATAN, ATAN2, COSH, EXP, LN, LOG, SIN, SINH, TAN, TANH
FORMAT
COS(
value
)
DESCRIPTION
COS returns the cosine of a value, an angle expressed in radians. You can convert

a degree angle into radians by multiplying it by pi/180.
COSH
SEE ALSO
ACOS, ASIN, ATAN, ATAN2, COS, EXP, LN, LOG, SIN, SINH, TAN, TANH
FORMAT
COSH(
value
)
DESCRIPTION
COSH returns the hyperbolic cosine of a
value
.
1072
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1072
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:51 PM
Color profile: Generic CMYK printer profile
Composite Default screen
COUNT
SEE ALSO AGGREGATE FUNCTIONS, Chapters 9 and 12
FORMAT
COUNT ( { * | [ DISTINCT | ALL ]
expr
} ) [OVER (
analytic_clause
)]
DESCRIPTION
COUNT counts the number of rows in which

expression
is non-NULL, which is
then returned by the query. With DISTINCT, COUNT counts only the distinct non-NULL rows. With *,
COUNT counts all rows, whether NULL or not.
COVAR_POP
SEE ALSO AGGREGATE FUNCTIONS
FORMAT
COVAR_POP (
expr1
,
expr2
) [OVER (
analytic_clause
)]
DESCRIPTION
COVAR_POP returns the population covariance of a set of number pairs. You can
use it as an aggregate or analytic function.
Both
expr1
and
expr2
are number expressions. Oracle applies the function to the set of (
expr1
,
expr2
)
pairs after eliminating all pairs for which either
expr1
or
expr2

is NULL. Then Oracle makes the following
computation:
(SUM(
expr1
*
expr2
) - SUM(
expr2
) * SUM(
expr1
) /
n
) /
n
where
n
is the number of (
expr1
,
expr2
) pairs where neither
expr1
nor
expr2
is NULL.
COVAR_SAMP
SEE ALSO AGGREGATE FUNCTIONS
FORMAT
COVAR_POP (
expr1

,
expr2
) [OVER (
analytic_clause
)]
DESCRIPTION
COVAR_SAMP returns the sample covariance of a set of number pairs. You can
use it as an aggregate or analytic function.
Both
expr1
and
expr2
are number expressions. Oracle applies the function to the set of (
expr1
,
expr2
)
pairs after eliminating all pairs for which either
expr1
or
expr2
is NULL. Then Oracle makes the following
computation:
(SUM(
expr1
*
expr2
) - SUM(
expr1
) * SUM(

expr2
) / n) / (n-1)
where
n
is the number of (
expr1
,
expr2
) pairs where neither
expr1
nor
expr2
is NULL.
CREATE CLUSTER
SEE ALSO
CREATE INDEX, CREATE TABLE, Chapter 17
CREATE CLUSTER
1073
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1073
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:52 PM
Color profile: Generic CMYK printer profile
Composite Default screen
FORMAT
create_cluster::=
physical_attributes_clause::=
size_clause::=
parallel_clause::=
1074

Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1074
PCTFREE integer
PCTUSED integer
INITRANS integer
storage_clause
integer
K
M
G
T
NOPARALLEL
PARALLEL
integer
CREATE CLUSTER
schema .
cluster ( column datatype
SORT
,
)
physical_attributes_clause
SIZE size_clause
TABLESPACE tablespace
INDEX
SINGLE TABLE
HASHKEYS integer
HASH IS expr
parallel_clause
N0ROWDEPENDENCIES

ROWDEPENDENCIES
CACHE
N0CACHE
;
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:53 PM
Color profile: Generic CMYK printer profile
Composite Default screen
DESCRIPTION
CREATE CLUSTER creates a cluster for one or more tables. Tables are added to the
cluster using CREATE TABLE with the CLUSTER clause. CREATE CLUSTER requires at least one cluster
column from each of the tables. These must have the same datatype and size, but are not required to
have the same name. For the tables in a cluster, rows with the same cluster column values are kept
together on disk in the same area, the same logical block(s). This can improve performance when the
cluster columns are the columns by which the tables are usually joined.
Each distinct value in each cluster column is stored only once, regardless of whether it occurs once
or many times in the tables and rows. This typically can reduce the amount of disk space needed to
store the tables, but each table continues to appear as if it contains all of its own data. Tables with LONG
columns cannot be clustered.
cluster
is the name created for the cluster.
column
and
datatype
follow the method of CREATE TABLE,
except that NULL and NOT NULL cannot be specified. However, in the actual CREATE TABLE statement,
at least one cluster column in a cluster must be NOT NULL. SIZE sets the size in bytes for a logical
block (not a physical block). SPACE is the cluster’s initial disk allocation, as used in CREATE TABLE.
SIZE should be the average amount of space needed to store all the rows from all the clustered
tables that are associated with a single cluster key. A small SIZE value may increase the time needed

to access tables in the cluster, but can reduce disk space usage. SIZE should be a proper divisor of the
physical block size. If not, Oracle will use the next larger divisor. If SIZE exceeds the physical block
size, Oracle will use the physical block size instead.
By default, the cluster is indexed, and you must create an index on the cluster key before putting
any data in the cluster. If you specify the hash cluster form, however, you don’t need to (and can’t)
create an index on the cluster key. Instead, Oracle uses a hash function to store the rows of the table.
You can create your own hash value as a column of the table and use that for hashing with the HASH
IS clause to tell Oracle to use that column as the hash value. Otherwise, Oracle uses an internal hash
function based on the columns of the cluster key. The HASHKEYS clause actually creates the hash cluster
and specifies the number of hash values, rounded to the nearest prime number. The minimum value is 2.
See
STORAGE for details on the common storage clause parameters.
CREATE CONTEXT
SEE ALSO
ALTER CONTEXT
FORMAT
CREATE [OR REPLACE] CONTEXT
namespace
USING [
schema
.]
package
[ INITIALIZED { EXTERNALLY | GLOBALLY }
| ACCESSED GLOBALLY ] ;
DESCRIPTION
A context is a set of attributes used to secure an application. CREATE CONTEXT
creates a namespace for a context and associates the namespace with the externally created package
that sets the context. To create a context namespace, you must have the CREATE ANY CONTEXT system
privilege.
CREATE CONTROLFILE

SEE ALSO
ALTER DATABASE, CREATE DATABASE
CREATE CONTROLFILE
1075
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1075
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:53 PM
Color profile: Generic CMYK printer profile
Composite Default screen
FORMAT
create_controlfile::=
logfile_clause::=
character_set_clause::=
DESCRIPTION
You can use the CREATE CONTROLFILE command to re-create a control file if
you have lost your current control file to media failure, if you want to change the name of your database,
or if you want to change one of the options for the redo log file or a datafile. In general, this command
should be used only by experienced database administrators.
NOTE
Perform a full offline backup of all of your database files before using
this command.
1076
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1076
LOGFILE
GROUP integer
file_specification
,

CHARACTER SET character_set
CREATE CONTROLFILE
REUSE SET
DATABASE database
logfile_clause
RESETL0GS
NORESETL0GS
DATAFILE file_specification
,
MAXLOGFILES integer
MAXLOGMEMBERS integer
MAXLOGHISTORY integer
MAXDATAFILES integer
MAXINSTANCES integer
ARCHIVELOG
NOARCHIVELOG
FORCE LOGGING character_set_clause
;
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:54 PM
Color profile: Generic CMYK printer profile
Composite Default screen
The REUSE option lets existing control files be reused. If you specify the name of an existing control
file but do not use the REUSE option, the command will return an error. The SET option changes the
name of the database, specified by the DATABASE clause. The LOGFILE clause specifies the redo log
file groups, all of which must exist. The RESETLOGS versus NORESETLOGS clause tells Oracle to reset
the current logs or not. The DATAFILE line specifies the datafiles for the database, all of which must exist.
The MAXLOGFILES option specifies the maximum number of redo log file groups that can be
created. The MAXLOGMEMBERS option specifies the number of copies for a redo log group. The
MAXLOGHISTORY option specifies the number of archived redo log file groups for Real Application

Clusters. The MAXDATAFILES option specifies the maximum number of datafiles that can ever be
created for the database. The MAXINSTANCES option gives the maximum number of Oracle instances
that can mount and open the database. The ARCHIVELOG and NOARCHIVELOG options turn archiving
of the redo log files on and off, respectively.
The CREATE CONTROLFILE command needed for an existing database can be generated via the
ALTER DATABASE BACKUP CONTROLFILE TO TRACE command.
As of Oracle Database 10
g
, you can specify Automatic Storage Management files as well as file
system files.
CREATE DATABASE
SEE ALSO
ALTER DATABASE, CREATE CONTROLFILE, CREATE ROLLBACK SEGMENT, CREATE
TABLESPACE, SHUTDOWN, STARTUP, Chapters 2 and 46
FORMAT
create_database::=
CREATE DATABASE
1077
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1077
CREATE DATABASE
database
USER SYS IDENTIFIED BY password
USER SYSTEM IDENTIFIED BY password
CONTROLFILE REUSE
MAXDATAFILES integer
MAXINSTANCES integer
CHARACTER SET charset
NATIONAL CHARACTER SET charset
SET DEFAULT

BIGFILE
SMALLFILE
TABLESPACE
database_logging_clauses
tablespace_clauses
set_time_zone_clause
;
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:54 PM
Color profile: Generic CMYK printer profile
Composite Default screen
database_logging_clauses::=
tablespace_clauses::=
default_tablespace::=
default_temp_tablespace::=
1078
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1078
EXTENT MANAGEMENT LOCAL
DATAFILE file_specification
,
SYSAUX DATAFILE file_specification
,
default_tablespace
default_temp_tablespace
undo_tablespace
DEFAULT TABLESPACE tablespace
DATAFILE datafile_tempfile_spec
extent_management_clause

BIGFILE
SMALLFILE
DEFAULT TEMPORARY TABLESPACE tablespace
TEMPFILE file_specification
,
extent_management_clause
LOGFILE
GROUP integer
file_specification
,
MAXLOGFILES integer
MAXLOGMEMBERS integer
MAXLOGHISTORY integer
ARCHIVELOG
NOARCHIVELOG
FORCE LOGGING
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:55 PM
Color profile: Generic CMYK printer profile
Composite Default screen
extent_management_clause::=
size_clause::=
undo_tablespace::=
set_time_zone_clause::=
DESCRIPTION
database
is the database name, and must have eight characters or fewer. DB_NAME
in init.ora contains the default database name. In general, this command should be used only by
experienced database administrators.
NOTE

Using this command in an existing database will erase the specified
datafiles.
file_definition
defines the redo log file and datafile names and sizes.
'file' [SIZE
integer
[K | M] [REUSE]
SIZE is the number of bytes set aside for this file. Suffixing this with K multiplies the value by 1024;
M multiplies it by 1048576 (G and T are also supported). REUSE (without SIZE) means destroy the contents
CREATE DATABASE
1079
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1079
integer
K
M
G
T
BIGFILE
SMALL
UNDO TABLESPACE tablespace
DATAFILE file_specification
,
SET TIME_ZONE = ’
+

hh : mi
time_zone_region

EXTENT MANAGEMENT

DICTIONARY
LOCAL
AUTOALLOCATE
UNIFORM
SIZE size_clause
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:56 PM
Color profile: Generic CMYK printer profile
Composite Default screen
of any file by this name and associate the name with this database. REUSE with SIZE creates the file
if it doesn’t exist, and checks its size if it does exist. CONTROLFILE REUSE overwrites the existing
control files defined by the CONTROL_FILES parameter in the initialization parameter file.
LOGFILE names the files to be used as redo log files. If this parameter is not used, Oracle creates two
by default. MAXLOGFILES overrides the LOG_FILES initialization parameter, and defines the maximum
number of redo log files that can ever be created for this database. This number cannot be increased later
except by re-creating the control file. The minimum number for files is two. A high number only makes a
somewhat larger control file.
DATAFILE names the files to be used for the database itself. MAXDATAFILES sets the absolute upper
limit for files that can be created for this database, and overrides the DB_FILES initialization parameter.
A high number only makes a somewhat larger control file.
As of Oracle Database 10
g
, you can specify Automatic Storage Management files as well as file
system files. When the AUTOEXTEND option is turned ON for a datafile, the datafile will dynamically
extend as needed in increments of NEXT size, to a maximum of MAXSIZE (or UNLIMITED).
MAXINSTANCES overrides the INSTANCES parameter in init.ora and sets the maximum number
of simultaneous instances that can mount and open this database.
ARCHIVELOG and NOARCHIVELOG define the way redo log files are used when the database
is first created. NOARCHIVELOG is the default, and means that redo log files will get reused without
saving their contents elsewhere. This provides instance recovery but will not recover from a media

failure, such as a disk crash. ARCHIVELOG forces redo log files to be archived (usually to another disk
or a tape), so that you can recover from a media failure. This mode also supports instance recovery.
This parameter can be reset by ALTER DATABASE.
The MAXLOGMEMBERS option specifies the maximum number of copies of a redo log file group.
The MAXLOGHISTORY option specifies the maximum number of archived redo log files, useful only
for the Real Application Clusters when you are archiving redo log files. The CHARACTER SET option
specifies the character set used to store data, which depends on the operating system.
For more automated handling of undo (rollback) segments, you can specify the UNDO TABLESPACE
clause to allocate a tablespace specifically to hold undo data. The database must be started in Automatic
Undo Management (AUM) mode.
You can use the DEFAULT TEMPORARY TABLESPACE clause to designate a non-SYSTEM tablespace
as the default temporary tablespace for all new users created in the database.
As of Oracle Database 10
g
, you can use the CREATE DATABASE command to do the following:

Create a default permanent tablespace for the database

Specify datafiles for the SYSAUX tablespace

Specify a bigfile tablespace as the default for the database

Override the default for the undo and default temporary tablespaces
CREATE DATABASE LINK
SEE ALSO
CREATE SYNONYM, SELECT, Chapter 23
FORMAT
CREATE [SHARED] [PUBLIC] DATABASE LINK
dblink
[ CONNECT TO { CURRENT_USER |

user
IDENTIFIED BY
password
[AUTHENTICATED BY
user
IDENTIFIED BY
password
] }
| AUTHENTICATED BY
user
IDENTIFIED BY
password
]
[USING '
connect
_
string'
];
1080
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1080
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:57 PM
Color profile: Generic CMYK printer profile
Composite Default screen
DESCRIPTION
dblink
is the name given to the link.
connect_string

is the definition of the remote
database that can be accessed through Oracle Net and defines the link between a local database and a
username on a remote database. PUBLIC links can be created only by a user with the CREATE PUBLIC
DATABASE LINK system privilege, but are then available to all users except those who have created a
private link with the same name. If PUBLIC isn’t specified, the link is only available to the user who
executed the CREATE DATABASE LINK statement.
connect_string
is the Oracle Net service name for
the remote database.
Remote tables can be accessed just like local tables, except that the table name must be suffixed
by @
link
in the FROM clause of the SELECT statement. Most systems set the maximum number of
simultaneous links to four. The DBA can increase this number with the OPEN_LINKS parameter in init.ora.
Tree-structured queries are limited. They may not use the PRIOR operator except in the CONNECT
BY clause. START WITH cannot contain a subquery. CONNECT BY and START WITH cannot use the
function USERENV('ENTRYID'), or the pseudo-column RowNum.
To create a database link, you must have CREATE DATABASE LINK privilege in the local database,
and the CREATE SESSION privilege in a remote database. To create a public database link, you must
have the CREATE PUBLIC DATABASE LINK system privilege.
If you use the CONNECT TO CURRENT_USER clause, the link will attempt to open a connection
in the remote database by using your current username and password. You therefore need to coordinate
any password changes you make between the local database and the remote database, or else database
links may stop working.
If you use the shared server architecture, you can create SHARED database links that eliminate
the need for many separate dedicated connections via links. When you create a SHARED link, you
must supply a valid username and password in the remote database to use as an authentication for
the connection.
EXAMPLES The following defines a link named EDMESTON_BOOKS that connects to the Practice
username in the EDMESTON database:

create database link EDMESTON_BOOKS
connect to Practice identified by Practice
using 'EDMESTON';
You now can query Practice’s tables like this:
select Title, Publisher
from BOOKSHELF@EDMESTON_BOOKS;
A synonym could also be created to hide the remoteness of the tables:
create synonym BOOKSHELF for BOOKSHELF@EDMESTON_BOOKS;
CREATE DIMENSION
SEE ALSO
ALTER DIMENSION, DROP DIMENSION, Chapter 24
FORMAT
create_dimension::=
CREATE DIMENSION
1081
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1081
CREATE DIMENSION
schema .
dimension level_clause
hierarchy_clause
attribute_clause
extended_attribute_clause
;
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:58 PM
Color profile: Generic CMYK printer profile
Composite Default screen
level_clause::=
hierarchy_clause::=

dimension_join_clause::=
attribute_clause::=
extended_attribute_clause::=
DESCRIPTION
CREATE DIMENSION creates hierarchies among related columns in tables, for
use by the optimizer. The optimizer uses dimension values when determining whether a materialized
view will return the same data as its base table. To create a dimension, you must have CREATE
DIMENSION privilege; to create a dimension in another user’s schema, you must have the CREATE
ANY DIMENSION privilege.
LEVEL defines the level within the dimension. HIERARCHY defines the relationships among the
levels. ATTRIBUTE assigns specific attributes to levels within the dimension. JOIN_KEY defines the
join clauses between the levels.
As of Oracle Database 10
g
, you can assign a name to a dimension attribute that is different from
the level name.
EXAMPLES Consider a geography dimension. Continents are divided into countries, so there is
a hierarchy between country data and continent data. For a table named COUNTRY, with columns
Country and Continent, and a second table named CONTINENT, with a column named Continent:
1082
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1082
HIERARCHY hierarchy ( child_level CHILD OF parent_level
dimension_join_clause
)
JOIN KEY
child_key_column
( child_key_column
,

)
REFERENCES parent_level
ATTRIBUTE level DETERMINES
dependent_column
( dependent_column
,
)
ATTRIBUTE attribute LEVEL level DETERMINES
dependent_column
( dependent_column
,
)
LEVEL level IS
level_table . level_column
( level_table . level_column
,
)
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:25:59 PM
Color profile: Generic CMYK printer profile
Composite Default screen
create table CONTINENT (
Continent VARCHAR2(30));
create table COUNTRY (
Country VARCHAR2(30) not null,
Continent VARCHAR2(30));
create dimension GEOGRAPHY
level COUNTRY_ID is COUNTRY.Country
level CONTINENT_ID is CONTINENT.Continent
hierarchy COUNTRY_ROLLUP (

COUNTRY_ID child of
CONTINENT_ID
join key COUNTRY.Continent references CONTINENT_ID);
CREATE DIRECTORY
SEE ALSO BFILE, Chapters 22, 26, and 35
FORMAT
CREATE [OR REPLACE] DIRECTORY
directory
AS '
path
_
name
';
DESCRIPTION Within Oracle, a “directory” is an alias for an operating system directory. You
must create a directory prior to accessing BFILE datatype values or external tables.
See
Chapter 26 for
details on the creation and management of external tables.
CREATE DISKGROUP
SEE ALSO
ALTER DISKGROUP, DROP DISKGROUP, Chapter 46
FORMAT
create_diskgroup::=
qualified_disk_clause::=
CREATE DISKGROUP
1083
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1083
CREATE DISKGROUP diskgroup_name
HIGH

NORMAL
EXTERNAL
REDUNDANCY
FAILGROUP failgroup_name
DISK qualified_disk_clause
,
;
’ search_string ’
NAME disk_name SIZE size_clause
FORCE
NOFORCE
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:26:00 PM
Color profile: Generic CMYK printer profile
Composite Default screen
size_clause::=
DESCRIPTION
NOTE
CREATE DISKGROUP is valid only if you are using Automatic Storage
Management (ASM) and you have started an ASM instance.
CREATE DISKGROUP creates a collection of disks. Oracle manages a disk group as a logical unit
and evenly spreads each file across the disks to balance I/O. Oracle automatically distributes database
files across the available disks in disk groups and rebalances the storage when the storage configuration
changes. CREATE DISKGROUP creates a disk group, assigns disks to the disk group, and mounts the
disk group for the first time.
CREATE FUNCTION
SEE ALSO
ALTER FUNCTION, BLOCK STRUCTURE, CREATE LIBRARY, CREATE PACKAGE,
CREATE PROCEDURE, DATATYPES, DROP FUNCTION, Chapter 31
FORMAT

create_function::=
1084
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1084
integer
K
M
G
T
CREATE
OR REPLACE
FUNCTION
schema .
function
( argument
IN
OUT
IN OUT NOCOPY
datatype
,
)
RETURN datatype
invoker_rights_clause
DETERMINISTIC
parallel_enable_clause
AGGREGATE
PIPELINED
USING
schema .

implementation_type
PIPELINED
IS
AS
pl/sql_function_body
call_spec
;
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:26:01 PM
Color profile: Generic CMYK printer profile
Composite Default screen

specified by the RETURN clause. The PL/SQL block defines the behavior of the function as a series of
declarations, PL/SQL program statements, and exceptions.
The IN qualifier means that you have to specify a value for the parameter when you call the function,
but since you always have to do this for a function, the syntax is optional. In a procedure, you can
have other kinds of parameters. The difference between a function and a procedure is that a function
returns a value to the calling environment.
In order to create a function, you must have the CREATE PROCEDURE system privilege. To create
a function in another user’s account, you must have the CREATE ANY PROCEDURE system privilege.
Your function can use C libraries that are stored outside of the database (see CREATE LIBRARY).
If you use Java within your function, you can provide a Java declaration within the LANGUAGE clause.
The INVOKER_RIGHTS clause lets you specify whether the function executes with the privileges of
the function owner (the definer) or the current user (the invoker).
CREATE INDEX
SEE ALSO
ANALYZE, ALTER INDEX, DROP INDEX, INTEGRITY CONSTRAINT, STORAGE,
Chapters 17 and 43
FORMAT
create_index::=

cluster_index_clause::=
table_index_clause::=
1086
Part IX: Alphabetical Reference
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1086
CREATE
UNIQUE
BITMAP
INDEX
schema .
index ON
cluster_index_clause
table_index_clause
bitmap_join_index_clause
;
CLUSTER
schema .
cluster index_attributes
schema .
table
t_alias
( index_expr
ASC
DESC
,
)
index_properties
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:26:02 PM

Color profile: Generic CMYK printer profile
Composite Default screen
bitmap_join_index_clause::=
index_expr::=
index_properties::=
index_attributes::=
CREATE INDEX
1087
ORACLE Series TIGHT / Oracle Database 10g: TCR / Loney / 225351-7 / Chapter 1
Blind Folio 1:1087
column
column_expression
global_partitioned_index
local_partitioned_index
index_attributes
domain_index_clause
schema .
table (
schema .
table .
t_alias .
column
ASC
DESC
,
)
FROM
schema .
table
t_alias

,
WHERE condition
local_partitioned_index
index_attributes
physical_attributes_clause
logging_clause
ONLINE
COMPUTE STATISTICS
TABLESPACE
tablespace
DEFAULT
key_compression
SORT
NOSORT
REVERSE
parallel_clause
P:\010Comp\Oracle8\351-7\CD\Ventura\Part9B.vp
Friday, August 13, 2004 4:26:03 PM
Color profile: Generic CMYK printer profile
Composite Default screen

×