1. Trang chủ
  2. » Công Nghệ Thông Tin

Oracle Database 10g The Complete Reference phần 10 ppsx

133 312 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Oracle Database 10g The Complete Reference Part 10
Trường học Not specified
Chuyên ngành Database Technology
Thể loại Textbook
Năm xuất bản Not specified
Thành phố Not specified
Định dạng
Số trang 133
Dung lượng 642,55 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Oracle supports several large object datatypes, including BLOBs binary large objects, CLOBs character large objects, and BFILEs binary files, stored outside the database.See Chapter 35 a

Trang 1

LEAST(value1, value2, )

DESCRIPTION LEAST is the value of a list of columns, expressions, or values Values may be

VARCHAR2, CHAR, DATE, or NUMBER datatypes, although LEAST will not properly evaluate literal

dates (such as '20-MAY-04') without the TO_DATE function See GREATEST for a discussion of

evaluating relative values

LENGTH

SEE ALSO CHARACTER FUNCTIONS, VSIZE, Chapter 7

FORMAT

LENGTH(string)

DESCRIPTION LENGTH tells the length of a string, number, date, or expression Thestring can

be CHAR (returned length will include all trailing blanks), VARCHAR2, NCHAR, NVARCHAR2, CLOB,

or NCLOB There are several LENGTH functions, all following the same format:

LENGTH calculates the length using characters as defined by the input character set.

LENGTHB uses bytes instead of characters.

LENGTHC uses Unicode complete characters.

LENGTH2 uses UCS2 code points.

LENGTH4 uses UCS4 code points.

LEVEL

SEE ALSO CONNECT BY, PSEUDO-COLUMNS, Chapter 14

FORMAT

LEVEL

DESCRIPTION Level is a pseudo-column, used with CONNECT BY, that is equal to 1 for a root

node, 2 for a child of a root, 3 for a child of a child of a root, and so on Level tells basically how far

down a tree you’ve traveled

LGWR

LGWR (LoG WRiter process) writes redo log entries from the System Global Area to the online redo

logs.See BACKGROUND PROCESS

WHERE string LIKE string

DESCRIPTION LIKE performs pattern matching An underline represents exactly one space A percent

sign represents any number of spaces or characters, including zero If LIKE uses either the _ or % in the first

position of a comparison (as in the second and third examples following), any index on the column is ignored

Trang 3

DESCRIPTION LN is the “natural,” or basee, logarithm of a number If number is BINARY_FLOAT,

then the function returns BINARY_DOUBLE

LNNVL

SEE ALSO SELECT

FORMAT

LNNVL ( condition )

DESCRIPTION LNNVL provides a way to evaluate a condition when one or both operands of the

condition may be null The function can be used only in the WHERE clause of a query It takes as an

argument a condition and returns TRUE if the condition is FALSE or UNKNOWN and returns FALSE if

the condition is TRUE LNNVL can be used anywhere a scalar expression can appear, even in contexts

where the IS [NOT] NULL, AND, or OR conditions are not valid but would otherwise be required to

account for potential nulls LNNVL may show up in explain plans when Oracle internally requires

NOT IN conditions as NOT EXISTS conditions.

EXAMPLES If you want to retrieve all rows for which a column is greater than a given value, the

standard format would be

where column > value

To also return the rows for whichcolumn is NULL, use LNNVL:

where LNNVL(column > value)

LOADJAVA

LOADJAVA is a utility for loading Java classes, resources, and sources into the database You must

load your Java classes into the database if you plan to use them in stored procedures To remove the

Java classes from the database, use the DROPJAVA utility.See Chapter 39

LOB

A LOB is a large object Oracle supports several large object datatypes, including BLOBs (binary large

objects), CLOBs (character large objects), and BFILEs (binary files, stored outside the database).See

Chapter 35 and the LOB clause of CREATE TABLE.

When a table is partitioned, its data is stored in separate tables When an index is created on the partitioned

table, the index can be partitioned so that each of the table partitions has a matching index partition The

matching index partitions are calledlocal indexes See Chapter 17

LOCALTIMESTAMP

SEE ALSO DATE FUNCTIONS, Chapter 10

Trang 4

LOCALTIMESTAMP [( timestamp_precision )]

DESCRIPTION LOCALTIMESTAMP returns the current date and time in the session time zone as

a value of datatype TIMESTAMP

EXAMPLE

SELECT LOCALTIMESTAMP FROM DUAL;

LOCALLY MANAGED TABLESPACE

A locally managed tablespace maintains its extent usage information in bitmaps within the

tablespace’s datafiles.See CREATE TABLESPACE.

LOCK

To lock data is to temporarily restrict other users’ access to data The restriction that is placed on such

data is called “a lock.” Lock modes are SHARE, SHARE UPDATE, EXCLUSIVE, SHARE EXCLUSIVE,

ROW SHARE, and ROW EXCLUSIVE Not all locks can be acquired in all modes

LOCK TABLE

SEE ALSO COMMIT, DELETE, INSERT, ROLLBACK, SAVEPOINT, UPDATE

FORMAT

LOCK TABLE

[schema.] { table | view }

[ { PARTITION ( partition ) | SUBPARTITION ( subpartition ) }

| @ dblink ]

[, [schema.] { table | view }

[ { PARTITION ( partition ) | SUBPARTITION ( subpartition ) }

| @ dblink ] ]

IN lockmode MODE [NOWAIT];

DESCRIPTION LOCK TABLE locks a table in one of several specified modes, allowing it to be

shared, but without loss of data integrity Using LOCK TABLE allows you to give other users continued

but restricted access to the table Regardless of which option you choose, the table will remain in that

lock mode until you COMMIT or ROLLBACK your transactions.

Lock modes include ROW SHARE, ROW EXCLUSIVE, SHARE UPDATE, SHARE, SHARE ROWEXCLUSIVE, and EXCLUSIVE

EXCLUSIVE locks permit users to query the locked table but not to do anything else No other usermay lock the table SHARED locks permit concurrent queries but no updates to the locked table

With a ROW SHARE or SHARE UPDATE lock, no user can lock the whole table for exclusive access,allowing concurrent access for all users to the table The two types of lock are synonymous, and SHARE

UPDATE exists for compatibility with previous versions of Oracle

ROW EXCLUSIVE locks are similar to ROW SHARE but they prohibit shared locking, so only oneuser may access the table at a time

If a LOCK TABLE command cannot be completed (usually because someone else has executed a prior and competing LOCK TABLE of some sort), then your LOCK TABLE will wait until it can complete.

If you wish to avoid this, and simply have control returned to you, use the NOWAIT option Note that

you can lock specific partitions and subpartitions

Trang 5

SEE ALSO PRECEDENCE

FORMAT The following lists all current logical operators in the Oracle version of SQL Most of

these are listed elsewhere in this reference under their own names with their proper format and use

All of these operators work with columns or literals

Logical Operators that Test a Single Value

= expression is equal to expression

> expression is greater than expression

>= expression is greater than or equal to expression

< expression is less than expression

<= expression is less than or equal to expression

!= expression is not equal to expression

^= expression is not equal to expression

<> expression is not equal to expression

expression IS NOT NULL

Logical Operators that Test More than a Single Value

ANY (expression [,expression] | query)

ALL (expression [,expression] | query)

ANY and ALL require an equality operator as a prefix, such as >ANY, =ALL, and so on.

IN (expression [,expression] | query)

NOT IN (expression [,expression] | query)

Trang 6

NOT BETWEEN expression AND expression

Other Logical Operators

AND Combines logical expressions

OR Combines logical expressions

UNION Combines results of queries

UNION ALL Combines results of queries without eliminating duplicates

INTERSECT Combines results of queries

MINUS Combines results of queries

LOGIN ACCOUNT

A login account is a username and password combination that allows people to use the Oracle RDBMS

This account is usually separate from your operating system account

LONG RAW DATATYPE

A LONG RAW column contains raw binary data, but is otherwise the same as a LONG column Values

entered into LONG RAW columns must be in hex notation

LOOP

You can use loops to process multiple records within a single PL/SQL block PL/SQL supports three types

of loops:

Simple loops A loop that keeps repeating until an EXIT or EXIT WHEN statement is reached within the loop

FOR loops A loop that repeats a specified number of times WHILE loops A loop that repeats until a condition is met

Trang 7

You can use loops to process multiple records from a cursor The most common cursor loop is acursor FOR loop.See CURSOR FOR LOOP and Chapter 29 for details on using loops for both simple

and cursor-based processing logic

DESCRIPTION Left PAD makes astring a certain length by adding a certain set of characters to

the left of the string Ifset is not specified, the default pad character is a space

Trang 8

MAKE_REF constructs a REF (reference) from the foreign key of a table that references

the base table of an object view MAKE_REF allows you to construct references superimposed on existing

foreign key relationships.See Chapter 36 for examples

MATERIALIZED VIEW

You can use materialized views to pre-aggregate data and improve query performance When you

create a materialized view, Oracle creates a physical table to hold data that would usually be read via

a view When you create a materialized view, you specify the view’s base query as well as a schedule

for the refreshes of its data You can then index the materialized view to enhance the performance of

queries against it As a result, you can provide data to your users in the format they need, indexed

appropriately.See CREATE MATERIALIZED VIEW and Chapter 24.

MATERIALIZED VIEW LOG

When you refresh a materialized view, you can perform a full or incremental refresh An incremental

refresh, called a “fast” refresh, sends only the DML changes from the master table to the materialized

view To track changes to the master table for the materialized view, you must create a materialized view

log The materialized view log must be in the same schema as the master table for the materialized

view Fast refreshes are not available for complex materialized views.See CREATE MATERIALIZED

VIEW LOG and Chapter 24.

MAX

SEE ALSO AGGREGATE FUNCTIONS, COMPUTE, MIN, Chapter 9

FORMAT

MAX([DISTINCT | ALL] value) [OVER analytic_clause]

DESCRIPTION MAX is the maximum of all values for a group of rows MAX ignores NULL values.

The DISTINCT option is not meaningful, since the maximum of all values is identical to the maximum of

the distinct values

MEDIA RECOVERY

Media recovery is recovery in the event of hardware failure that would prevent reading or writing of

data and thus operation of the database.See also INSTANCE RECOVERY

MEDIAN

SEE ALSO AVG, COUNT

FORMAT

MEDIAN ( expr ) [OVER (query_partition_clause)]

DESCRIPTION MEDIAN takes a numeric or datetime value and returns the middle value or an

interpolated value that would be the middle value once the values are sorted NULLs are ignored.

MERGE

SEE ALSO INSERT, UPDATE, Chapter 15

Trang 9

DESCRIPTION MERGE performs updates and inserts of a target table in a single command, based on

a selected set of rows You specify the conditions to determine whether an insert or update is performed on

a row-by-row basis.See Chapter 15 for detailed examples

NOTE

Since MERGE performs queries, you can use hints.

As of Oracle Database 10g, you can specify either the UPDATE or the INSERT operation, or both

Also, you can delete rows from the target table during the UPDATE operation.

where_clause DELETE where_clause

, )

VALUES (

expr ,

DEFAULT

) where_clause

WHERE condition

Trang 10

A method is a block of code In reference to user-defined datatypes, a method is a block of PL/SQL

code used to encapsulate the data access method for an object Methods are specified as part of the

datatype specification (see CREATE TYPE) and their body is specified as part of the CREATE TYPE

BODY command Users can execute methods on the datatypes for which the methods are defined.

The constructor method created for each user-defined datatype is an example of a method.See

Chapter 33 for examples of methods

In Java, a method is a member of a class You can call a class method and pass parameters to itfor it to use when executing its commands.See Chapter 33 for examples

MIN

SEE ALSO AGGREGATE FUNCTIONS, COMPUTE, MAX, Chapter 9

FORMAT

MIN([DISTINCT | ALL] value) [OVER (analytic_clause)]

DESCRIPTION MIN is the minimum of all values for a group of rows MIN ignores NULL values.

The DISTINCT option is not meaningful, since the minimum of all values is identical to the minimum

of the distinct values

where CONTAINS(Text,'text MINUS text') >0;

DESCRIPTION MINUS combines two queries It returns only those rows from the first SELECT

statement that are not produced by the second SELECT statement (the first SELECT MINUS the second

SELECT) The number of columns and datatypes must be identical between SELECT statements, although

the names of the columns do not need to be The data, however, must be identical in the rows produced

for the MINUS to reject them.See Chapter 13 for a discussion of the important differences and effects

of INTERSECT, MINUS, and UNION.

Within text searches against CONTEXT indexes, MINUS tells the text search of two terms to subtract

the score of the second term’s search from the score of the first term’s search before comparing the result

to the threshold score

MOD

SEE ALSO NUMBER FUNCTIONS, Chapter 9

FORMAT

MOD(value, divisor)

Trang 11

DESCRIPTION MOD divides a value by a divisor, and gives the remainder MOD(23,6) = 5 means

divide 23 by 6 The answer is 3 with 5 left over, so 5 is the result of the modulus.value and divisor can

both be any real number, except thatdivisor cannot be 0

The second example shows what MOD does whenever the divisor is larger than the dividend (the

number being divided) It produces the dividend as a result Also note this important case:

MOD(value,1) = 0

ifvalue is an integer This is a good test to see if a number is an integer

MODEL FUNCTIONS

Model functions are relevant only for interrow calculations and can be used only in the MODEL clause

of the SELECT statement They are nonrecursive The model functions are CV, ITERATION_NUMBER,

PRESENTNNV, PRESENTV, and PREVIOUS.

To mount a database is to make it available to the database administrator

MOUNT AND OPEN A DATABASE

To mount and open a database is to make it available to users

DESCRIPTION NANVL is useful only for floating-point numbers of type BINARY_FLOAT or

BINARY_DOUBLE Oracle will return an alternative valuen if the input value m is not a number;

otherwise it returnsm

Trang 12

NATURAL JOIN

A natural join joins two tables based on the key columns they have in common The syntax is

FROM TableA NATURAL JOIN TableB

which is equivalent to

FROM TableA, TableB

WHERE TableA.KeyColumn = TableB.KeyColumn

See Chapter 13 for examples of different types of join syntax

NCHAR

NCHAR is a multibyte version of the CHAR datatype It stores fixed-length character data up to 2000 bytes

in length.See DATATYPES

The NCLOB datatype is the multibyte version of the CLOB datatype NCLOB stores character large

objects containing Unicode characters, up to a maximum length of 4GB.See DATATYPES

NEAR

SEE ALSO CONTAINS, Chapter 25

DESCRIPTION Within CONTEXT indexes, NEAR indicates that a proximity search should be

executed for the specified text strings If the search terms are 'summer' and 'lease', then a proximity

search for the two terms could be

select Text

from SONNET

where CONTAINS(Text,'summer NEAR lease') >0;

When evaluating the text search results, text with the words 'summer' and 'lease' near each other in

the text will have higher scores than text with the words 'summer' and 'lease' farther apart

NESTED TABLE

A nested table is a table within a table In this case, it is a table that is represented as a column within

another table You can have multiple rows in the nested table for each row in the main table There is

no limit to the number of entries per row.See Chapter 34 for details on creating, using, and querying

nested tables

NEWPAGE (SQL*Plus)

See SET.

Trang 13

NLS_CHARSET_DECL_LEN ( byte_count , char_set_id )

DESCRIPTION NLS_CHARSET_DECL_LEN returns the declaration width (in number of characters)

DESCRIPTION NLS_CHARSET_ID returns the character set ID number corresponding to the

character set nametext

DESCRIPTION NLS_INITCAP is like the INITCAP function except with the addition of a parameter

string Thenls_parameters string, enclosed in single quotation marks, gives a sort sequence for capitalizing

special linguistic sequences You would usually use INITCAP with the default sort sequence for the

session, but this function lets you specify the exact sort sequence to use

Trang 14

SEE ALSO CHARACTER FUNCTIONS, LOWER, Chapter 7

FORMAT

NLS_LOWER(number[, nls_parameters])

DESCRIPTION NLS_LOWER is like the LOWER function except with the addition of a parameter

string Thenls_parameters string, enclosed in single quotation marks, gives a sort sequence for lowercasing

special linguistic sequences You would usually use LOWER with the default sort sequence for the

session, but this function lets you specify the exact sort sequence to use

NLS_UPPER

SEE ALSO CHARACTER FUNCTIONS, UPPER, Chapter 7

FORMAT

NLS_UPPER(number[, nls_parameters])

DESCRIPTION NLS_UPPER is like the UPPER function except with the addition of a parameter

string Thenls_parameters string, enclosed in single quotation marks, gives a sort sequence for capitalizing

special linguistic sequences You would usually use UPPER with the default sort sequence for the

session, but this function lets you specify the exact sort sequence to use

NLSSORT

SEE ALSO CREATE DATABASE

FORMAT

NLSSORT(character[, nls_parameters])

DESCRIPTION NLSSORT (National Language Support SORT) gives the collating sequence value

(an integer) of the givencharacter based on the National Language Support option chosen for the site

Thenls_parameters string, enclosed in single quotation marks, gives a sort sequence for special linguistic

sequences if you do not want to use the session or database default

schema_object_clause ,

WHENEVER

NOT

SUCCESSFUL

;

Trang 15

auditing_by_clause::=

schema_object_clause::=

auditing_on_clause::=

DESCRIPTION NOAUDIT stops auditing of SQL statements being audited as a result of the AUDIT

command It stops auditing either a statement (see AUDIT) or a statement authorized by a system

privilege (see PRIVILEGE) If there is a BY clause with a list of users, the command stops the auditing of

statements issued by these users If there is no BY clause, Oracle stops auditing the statements for all

users The WHENEVER SUCCESSFUL option stops auditing only for those statements that successfully

complete; WHENEVER NOT SUCCESSFUL stops only for those statements that result in an error.

NOAUDIT also stops the audit for an option of the use of a table, view, or synonym To stop the

audit of any table, view, or synonym, you must either own them or have DBA authority.option refers

to the options described shortly.user is the username of the object owner object is a table, view, or

synonym.option specifies what commands the audit should be stopped for ON object names the

object being audited, and includes a table, view, or synonym of a table, view, or sequence ALL stops

the audits of all commands on the object

See Chapter 42 for details on the auditing views in the data dictionary

BY

proxy ,

user ,

object_option ,

statement_option ALL

,

system_privilege ALL PRIVILEGES ,

auditing_by_clause

Trang 16

The following stops auditing of all attempts at UPDATE or DELETE on the BOOKSHELF

table:

noaudit update, delete on BOOKSHELF;

This stops auditing of all unsuccessful access to BOOKSHELF:

noaudit all on BOOKSHELF whenever not successful;

NODE

Node can be either of two definitions:

■ In a tree-structured table, a node is one row.

■ In a network, a node is the location in the network where a computer is attached.

NOLOGGING

The NOLOGGING clause for object creation (tables, LOBs, indexes, partitions, etc.) specifies that the

creation of the object will not be logged in the online redo log files, and thus will not be recoverable

following a media failure The object creation is not logged, and neither are certain types of transactions

against the object.See Chapters 21 and 46

NON-EQUI-JOIN

A non-equi-join is a join condition other than “equals” (=).See EQUI-JOIN

NOT

SEE ALSO LOGICAL OPERATORS, Chapter 5

DESCRIPTION NOT comes before and reverses the effect of any of these logical operators:

BETWEEN, IN, LIKE, and EXISTS NOT can also come before NULL, as in IS NOT NULL.

NOT EXISTS

SEE ALSO ALL, ANY, EXISTS, IN, Chapter 13

FORMAT

select

where NOT EXISTS (select );

DESCRIPTION NOT EXISTS returns false in a WHERE clause if the subquery that follows it returns

one or more rows The SELECT clause in the subquery can be a column, a literal, or an asterisk—it doesn’t

matter The only part that matters is whether the WHERE clause in the subquery will return a row.

EXAMPLE NOT EXISTS is frequently used to determine which records in one table do not have

matching records in another table.See Chapter 13 for examples of the use of NOT EXISTS.

Trang 17

DESCRIPTION NTILE is an analytic function It divides an ordered dataset into a number of buckets

indicated by an expression and assigns the appropriate bucket number to each row The buckets are

numbered and the expression must resolve to a positive constant for each partition

NULL (Form 1—PL/SQL)

SEE ALSO BLOCK STRUCTURE

FORMAT

NULL;

DESCRIPTION The NULL statement has nothing to do with NULL values Its main purpose is

to make a section of code more readable by saying, in effect, “do nothing.” It also provides a means

of having a null block (since PL/SQL requires at least one executable statement between BEGIN and

END) It is usually used as the statement following one (usually the last) of a series of condition tests.

NULL (Form 2—SQL Column Value)

SEE ALSO AGGREGATE FUNCTIONS, CREATE TABLE, INDICATOR VARIABLE, NVL, Chapter 5

DESCRIPTION A NULL value is one that is unknown, irrelevant, or not meaningful Any Oracle

datatype can be NULL That is, any Oracle column in a given row can be without a value (unless the table

was created with NOT NULL for that column) NULL in a NUMBER datatype is not the same as zero.

Few procedural languages directly support the idea of a variable with a NULL or unknown value,

although Oracle and SQL do so easily In order to extend languages for which Oracle has developed

precompilers to support the NULL concept, an INDICATOR VARIABLE is associated with the host

variable, almost like a flag, to indicate whether it is NULL The host variable and its indicator variable

may be referenced and set separately in the host language code, but are always concatenated in SQL

or PL/SQL

You use the NVL function to detect the absence of a value for a column, and convert the NULL value into a real value of the datatype of the column For instance, NVL(Name,'NOT KNOWN')

converts a NULL value in the column Name into the words NOT KNOWN For a non-NULL value

(that is, where a name is present), the NVL function simply returns the name NVL works similarly with

NUMBERs and DATEs

Except for COUNT(*) and COMPUTE NUMBER, aggregate functions ignore NULL values Other functions return a NULL value when a NULL is present in the value or values they are evaluating:

Trang 18

is not a valid WHERE clause NULL requires the word IS:

where Name IS NULL

During ORDER BY sorts, NULL values always come first when the order is ascending, and last

when it is descending

When NULL values are stored in the database, they are represented with a single byte if they fall

between two columns that have real values, and no bytes if they fall at the end of the row (last in the

column definition in the CREATE TABLE) If some of the columns in a table are likely to often contain

NULL values, those columns can be usefully grouped near the end of the CREATE TABLE column list;

this will save a minor amount of disk space

NULL values do not appear in indexes, except in the single case where all the values in a cluster

key are NULL.

NULLIF

SEE ALSO COALESCE, DECODE, NULL, Chapter 16

FORMAT

NULLIF ( expr1 , expr2 )

DESCRIPTION NULLIF compares expr1 and expr2 If they are equal, the function returns NULL.

If they are not equal, the function returnsexpr1 You cannot specify the literal NULL for expr1.

The NULLIF function is logically equivalent to the following CASE expression:

CASE WHEN expr1 = expr2 THEN NULL

ELSE expr1 END

NUMBER DATATYPE

A NUMBER datatype is a standard Oracle datatype that may contain a number, with or without a decimal

point and a sign Valid values are 0, and positive and negative numbers NUMBER datatypes are defined as

having precision and scale Precision can range from 1 to 38; scale can range from –84 to 127

NUMBER FORMATS

SEE ALSO COLUMN, Chapter 9

DESCRIPTION These options work with both the SET NUMFORMAT and COLUMN FORMAT

commands:

9999990 The count of nines and zeros determines the maximum digits that can be displayed.

999,999,999.99 Commas and decimals will be placed in the pattern shown.

999990 Displays trailing zeroes.

099999 Displays leading zeroes.

$99999 A dollar sign is placed in front of every number.

B99999 Displays a blank for the integer portion of a fixed-point number when the integer is zero.

99999MI If the number is negative, a minus sign follows the number The default is for the negative

sign to be on left.

Trang 19

S9999 Returns leading + for positive values, – for negative values.

9999S Returns trailing + for positive values, – for negative values.

99999PR Negative numbers are displayed within < and >.

99D99 Displays the decimal in the position indicated.

9G999 Displays the group separator in the position shown.

C9999 Displays the ISO currency symbol in this position.

L999 Displays the local currency symbol in the position specified.

9.999EEEE The display will be in scientific notation (4 E’s are required).

999V99 Multiplies number by 10n, wherenis the number of digits to the right of V 999V99 turns

1234 into 123400.

9999RN Displays Roman numeral values, for integer values between 1 and 3999.

TM Returns the smallest number of characters possible (text minimum).

U999 Returns the Euro or other dual currency symbol in the specified position.

X Returns the hexadecimal value of the specified number of digits.

NUMBER FUNCTIONS

The following is an ordered list of all current single-value number functions in the Oracle version of

SQL Each of these is listed elsewhere in this reference under its own name, with its proper format

and use Each can be used as a regular SQL function as well as a PL/SQL function.See AGGREGATE

FUNCTIONS and LIST FUNCTIONS

ACOS(value) Arc COSine ofvalue, in radians ASIN(value) Arc SINe ofvalue, in radians ATAN(value) Arc TANgent ofvalue, in radians ATAN2(value1, value2) Arc TANgent ofvalue1andvalue2, in radians BITAND (value1, value2) BITwise AND ofvalue1andvalue2, both of which must resolve to

nonnegative integers, and returns an integer CEIL(value) Numeric CEILing: the smallest integer larger than or equal tovalue

Trang 20

Function Definition

FLOOR(value) Largest integer smaller than or equal tovalue

NANVL(value1,value2) For BINARY_FLOAT and BINARY_DOUBLE numbers, returnsvalue2

ifvalue1is not a number POWER(value, exponent) valueraised to anexponentPOWER REMAINDER(value1,value2) Remainder ofvalue1divided byvalue2

ROUND(value, precision) ROUNDing ofvaluetoprecision

SIGN(value) 1 ifvalueis positive, –1 if negative, 0 if zero

TRUNC(value, precision) valueTRUNCated toprecision

WIDTH_BUCKET(expr,min,max,num) Constructs equal-width histograms

NUMTODSINTERVAL

SEE ALSO DATATYPES, Chapter 11

FORMAT

NUMTODSINTERVAL ( n , 'char_expr' )

DESCRIPTION NUMTODSINTERVAL convertsn to an INTERVAL DAY TO SECOND literal n can

be a number or an expression resolving to a number.char_expr can be of CHAR, VARCHAR2, NCHAR,

or NVARCHAR2 datatype The value forchar_expr specifies the unit of n and must resolve to one of

the following string values: 'DAY', 'HOUR', 'MINUTE', or 'SECOND'

NUMTOYMINTERVAL

SEE ALSO DATATYPES, Chapter 11

FORMAT

NUMTOYMINTERVAL ( n , 'char_expr' )

DESCRIPTION NUMTOYMINTERVAL converts numbern to an INTERVAL YEAR TO MONTH

literal.n can be a number or an expression resolving to a number char_expr can be of CHAR, VARCHAR2,

NCHAR, or NVARCHAR2 datatype The value forchar_expr specifies the unit of n, and must resolve

to either 'YEAR' or 'MONTH'

NUMWIDTH (SQL*Plus)

See SET.

Trang 21

DESCRIPTION Ifvalue is NULL, this function returns substitute If value is not NULL, this function

returnsvalue value can be any Oracle datatype substitute can be a literal, another column, or an

expression, but must be the same datatype asvalue

NVL2

SEE ALSO AGGREGATE FUNCTIONS, NULL, OTHER FUNCTIONS, Chapter 9

FORMAT

NVL2 ( expr1 , expr2 , expr3 )

DESCRIPTION NVL2 is an extended form of NVL In NVL2,expr1 can never be returned; either

expr2 or expr3 will be returned If expr1 is not NULL, NVL2 returns expr2 If expr1 is NULL, NVL2

returnsexpr3 The argument expr1 can have any datatype The arguments expr2 and expr3 can have

any datatypes except LONG

OBJECT NAMES

These database objects may be given names: tables, views, synonyms, aliases, columns, indexes, users,

sequences, tablespaces, and so on The following rules govern naming objects:

■ The name of an object can be from 1 to 30 characters long, except for database names, which

are up to eight characters, and host filenames, whose length is operating-system dependent

■ A name may not contain a quotation mark.

■ A name must:

Begin with a letterContain only the characters A–Z, 0–9, $, #, and _Not be an Oracle reserved word (see RESERVED WORDS)Not duplicate the name of another database object owned by the same userObject names are not case sensitive Object names should follow a sensible naming convention

OBJECT REFERENCE FUNCTIONS

Object reference functions manipulate REFs, which are references to objects of specified object types

The object reference functions are described under their individual entries in this reference The functions

are DEREF, MAKE_REF, REF, REFTOHEX, and VALUE.

OBJECT TABLE

An object table is a table in which each of its rows is a row object.See Chapter 36 and CREATE TABLE.

Trang 22

OBJECT VIEW

An object view superimposes abstract datatypes on existing relational tables Object views allow you to

access the relational table’s data either via normal SQL commands or via its abstract datatype structures

Object views provide a technological bridge between relational and object-relational databases.See

Chapters 33 and 36 for examples of object views

OBJECT-RELATIONAL DATABASE

MANAGEMENT SYSTEM

An object-relational database management system (ORDBMS) supports both relational database

features (such as primary keys and foreign keys) and object-oriented features (such as inheritance and

encapsulation).See Part I and Part V of this book for a description of Oracle’s implementation of an

ORDBMS

OFFLINE BACKUP

An offline backup is a physical backup of the database files while the database is shut down

OID

An OID is an object identifier, assigned by Oracle to each object in a database For example, each row

object within an object table has an OID value assigned to it; the OID is used to resolve references to

the row objects Oracle does not reuse OID values after an object is dropped.See Chapter 36

ONLINE BACKUP

Online backup is the ability of Oracle to archive data while the database is still running The DBA does

not need to shut down the database to archive data Even data currently being accessed can be archived

ONLINE REDO LOG

Online redo logs are redo log files that are not yet archived They may be available to the instance for

recording activity, or have previously been written but are awaiting archiving

OPEN

SEE ALSO CLOSE, DECLARE CURSOR, FETCH, LOOP, Chapter 29

FORMAT

OPEN cursor [(parameter[,parameter] ]

DESCRIPTION OPEN works in conjunction with DECLARE CURSOR and FETCH DECLARE

CURSOR sets up a SELECT statement to be executed, and establishes a list of parameters (PL/SQL

variables) that are to be used in its WHERE clause, but it does not execute the query.

OPENcursor, in effect, executes the query in the named cursor and keeps its results in a staging

area, where they can be called in, a row at a time, with FETCH, and their column values put into local

variables with the INTO clause of the FETCH If the cursor SELECT statement used parameters, then

their actual values are passed to the SELECT statement in the parameter list of the OPEN statement.

They must match in number and position and have compatible datatypes

There is also an alternative method of associating the values in the OPEN statement with those in the SELECT list:

DECLARE

cursor mycur(Title, Publisher) is select

Trang 23

open my_cur(new_book => Title, 'PANDORAS' => Publisher);

Here,new_book, a PL/SQL variable, loaded perhaps from a data entry screen, is pointed to Title,and therefore loads it with whatever is currently in the variablenew_book Publisher is loaded with

the value 'PANDORAS', and these then become the parameters of the cursormy_cur (See DECLARE

CURSOR for more details on parameters in cursors.)

You also may combine pointed associations with positional ones, but the positional ones must

appear first in the OPEN statement’s list.

You cannot reopen an open cursor, though you can CLOSE it and reOPEN it, and you cannot use

a cursor for which you have a current OPEN statement in a CURSOR FOR LOOP.

OPEN CURSOR (Embedded SQL)

SEE ALSO CLOSE, DECLARE CURSOR, FETCH, PREPARE,Programmer’s Guide to the Oracle

| :variable[[ INDICATOR ]:indicator_variable

[,:variable[ INDICATOR ]:indicator_variable]] }]

DESCRIPTION cursor is the name of a cursor previously named in a DECLARE CURSOR statement.

The optional USING references either the host variable list of variables that are to be substituted in the

statement in the DECLARE CURSOR, based on position (the number and type of variables must be the

same), or a descriptor name that references the result of a previous DESCRIBE.

OPENcursor allocates a cursor, defines the active set of rows (the host variables are substitutedwhen the cursor is opened), and positions the cursor just before the first row of the set No rows are

retrieved until a FETCH is executed Host variables do not change once they’ve been substituted.

To change them, you must reopen the cursor (you don’t have to CLOSE it first).

NOTE

See the Programmer’s Guide to the Oracle Precompilers for a full list

of all commands This reference does not contain all of the possibleprecompiler commands

OPERATOR

An operator is a character or reserved word used in an expression to perform an operation, such as addition

or comparison, on the elements of the expression Some examples of operators are * (multiplication), >

(greater than comparison), and ANY (compares a value to each value returned by a subquery).

OPS$ LOGINS

OPS$ LOGINS are a type of Oracle username in which OPS$ is prefixed to the user’s operating system

account ID, to simplify logging into Oracle from that ID

OPTIMIZER

An optimizer is the part of an Oracle kernel that chooses the best way to use the tables and indexes to

complete the request made by a SQL statement.See Chapter 43

Trang 24

SEE ALSO AND, CONTAINS, Chapters 5 and 25

DESCRIPTION OR combines logical expressions so that the result is TRUE if either logical expression

is true

EXAMPLE The following will produce data for both KEENE and SAN FRANCISCO:

select * from COMFORT

where City = 'KEENE' OR City = 'SAN FRANCISCO'

Within CONTEXT queries, an OR operator can be used for searches involving multiple search terms.

If either of the search terms is found, and its search score exceeds the specified threshold value, the text

will be returned by the search.See Chapter 25

ORACLE ENTERPRISE MANAGER

Oracle Enterprise Manager (OEM) is a product from Oracle Corporation OEM provides a graphical

interface for common DBA tasks, including features for performance tuning and data management

functions OEM provides a web-based interface to all of the grid components, including the ASM

diskgroups

ORACLE REAL APPLICATION CLUSTERS

In an Oracle Real Application Clusters (RAC) environment, multiple instances (usually on a cluster of

servers) access a single set of datafiles RAC provides server failover capability in a high-availability

environment, since users can be directed to multiple servers to access the same data

ORACLE APPLICATION SERVER 10g

Oracle Application Server 10g allows developers to access Oracle databases from Web-based applications

The developers call procedures from within the database The procedures, in turn, retrieve or manipulate

data and return results to the developers.See Chapter 45

ORA_HASH

FORMAT

ORA_HASH ( expr [, max_bucket [,seed_value] ])

DESCRIPTION ORA_HASH computes a hash value for a given expression This function is useful

for operations such as analyzing a subset of data and generating a random sample.expr is the data for

which Oracle will compute a hash value (usually a column name).max_bucket determines the maximum

bucket value (0 to 4294967295) Theseed_value argument (0 to 4294967295) enables Oracle to produce

different results with the sameexpr

Trang 25

DESCRIPTION The ORDER BY clause causes Oracle to sort the results of a query before they are

displayed This can be done either byexpression, which can be a simple column name or a complex set

of functions, analias (see Note below), or a column position in the SELECT clause (see Note below).

Rows are ordered first by the first expression or position, then by the second, and so on, based on the

collating sequence of the host If ORDER BY is not specified, the order in which rows are selected from

a table is indeterminate, and may change from one query to the next

NOTE

Oracle still supports the use of column positions in ORDER BY

clauses, but this feature is no longer part of the SQL standard and

is not guaranteed to be supported in future releases Use columnaliases instead

ASC or DESC specifies ascending or descending order, and may follow each expression, position,

or alias in the ORDER BY clause NULL values precede ascending and follow descending rows in Oracle.

ORDER BY follows any other clauses except FOR UPDATE OF.

If ORDER BY and DISTINCT are both specified, the ORDER BY clause may refer only to columns

or expressions that are in the SELECT clause.

When the UNION, INTERSECT, or MINUS operator is used, the names of the columns in the first

SELECT may differ from the names in subsequent SELECTs ORDER BY must use the column name from

the first SELECT.

Only CHAR, VARCHAR2, NUMBER, and DATE datatypes—and the special datatype ROWID—can

appear in an ORDER BY clause.

EXAMPLE

select Title, Publisher from BOOKSHELF

order by Title;

OTHER FUNCTIONS

This is an alphabetical list of all current functions in the Oracle version of SQL that do not readily fall

into any other function category Each of these is listed elsewhere in this reference under its own name,

with its proper format and use

BFILENAME, COALESCE, CV, DECODE, DEPTH, DUMP, EMPTY_BLOB, EMPTY_CLOB, EXISTSNODE, EXTRACT, EXTRACTVALUE, GREATEST, LEAST, LNNVL, NLS_CHARSET_DECL_LEN,

NLS_CHARSET_ID, NLS_CHARSET_NAME, NULLIF, NVL, NVL2, ORA_HASH, PATH, PRESENTNNV,

PRESENTV, PREVIOUS, SYS_CONNECT_BY_PATH, SYS_CONTEXT, SYS_DBURIGEN, SYS_EXTRACT_

UTC, SYS_GUID, SYS_TYPEID, SYS_XMLAGG, SYS_XMLGEN, UID, UPDATEXML, USER, USERENV,

VSIZE, XMLAGG, XMLCOLATTVAL, XMLCONCAT, XMLFOREST, XMLSEQUENCE, XMLTRANSFORM

OUTER JOIN

See JOIN for a detailed explanation As of Oracle9i, you can use the ANSI standard outer join syntax

options (LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN).See Chapter 13 for details

and examples

Trang 26

A package is a PL/SQL object that groups PL/SQL types, variables, SQL cursors, exceptions, procedures,

and functions Each package has a specification and a body The specification shows the objects you

can access when you use the package The body fully defines all the objects and can contain additional

objects used only for the internal workings You can change the body (for example, by adding procedures

to the package) without invalidating any object that uses the package

See CREATE PACKAGE, CREATE PACKAGE BODY, CURSOR, EXCEPTION, FUNCTION, TABLE

(PL/SQL), RECORD (PL/SQL), PROCEDURE, and Chapter 31

PAGESIZE (SQL*Plus)

See SET.

PARAMETER

A parameter is a value, a column name, or an expression, usually following a function or module

name, specifying additional functions or controls that should be observed by the function or module

See PARAMETERS for an example

PARAMETERS

SEE ALSO &, &&, ACCEPT, DEFINE

DESCRIPTION Parameters allow the execution of a start file with values passed on the SQL*Plus

command line These are simply spaced apart following the name of the start file Within the file,

parameters are referenced by the order in which they appeared on the command line &1 is the first,

&2 the second, and so on Aside from this rule, the rules for use are the same as for variables loaded

using DEFINE or ACCEPT, and they may be used in SQL statements in the same way.

There is one limitation, however There is no way to pass a multiple-word argument to a singlevariable Each variable can take only one word, date, or number Attempting to solve this by putting

the parameters in quotes on the command line results in the words being concatenated

EXAMPLE Suppose you have a start file named fred.sql that contains this SQL:

select Title, Publisher

from BOOKSHELF

where Title > &1;

Starting it with this command line:

Trang 27

See LOGICAL OPERATORS and RESERVED WORDS

PARSE

Parsing is the mapping of a SQL statement to a cursor At parse time, several validation checks are made,

such as whether all referenced objects exist, whether grants are proper, and whether statement syntax is

correct Also, decisions regarding execution and optimization are made, such as which indexes will be used

PASSWORD (SQL*Plus)

SEE ALSO ALTER USER, Chapter 18

FORMAT

PASSW[ORD] [username]

DESCRIPTION You can use the PASSWORD command in SQL*Plus to change the password on

your account or another account (if you have ALTER ANY USER privilege) If you use the PASSWORD

command, your new password will not be displayed on the screen as you type Users with DBA authority

can change any user’s password via the PASSWORD command; other users can change only their own

Retype new password:

When the password has been successfully changed, you will receive the feedback:

Password changed

PARALLEL QUERY OPTION

The Parallel Query Option (PQO) splits a single database task into multiple coordinated tasks, enabling

the task to use multiple processors For example, a full table scan or a large sort may be parallelized,

enabling multiple processors to take part in the completion of the operation If there are adequate

resources available on the server, then the parallelized operation may complete faster than if it were

to run as a single task

The number of parallel query server processes used to execute an operation is called thedegree

of parallelism, and is set via the DEGREE parameter of hints See Chapter 43.

PARTITION

To partition a table is to systematically divide its rows among multiple tables, each with the same structure

You can direct the database to automatically partition a table and its indexes.See Chapter 17

PARTITIONED TABLE

A partitioned table is a table whose rows have been partitioned across multiple smaller tables

Trang 28

SEE ALSO DEPTH

FORMAT

PATH ( correlation_integer )

DESCRIPTION PATH is an ancillary function used only with the UNDER_PATH and EQUALS_PATH

conditions It returns the relative path that leads to the resource specified in the parent condition The

correlation_integer value can be any NUMBER integer Values less than 1 are treated as 1

PAUSE (Form 1—SQL*Plus)

See SET.

PAUSE (Form 2—SQL*Plus)

SEE ALSO ACCEPT, PROMPT, Chapter 6

FORMAT

PAU[SE] [text];

DESCRIPTION PAUSE is similar to PROMPT, except PAUSE first displays an empty line, then a

line containingtext, then waits for the user to pressRETURN Iftext is not entered, PAUSE displays two

empty lines, then waits for user to pressRETURN

NOTE PAUSE waits for aRETURNfrom the terminal even if the source ofcommand input has been redirected to be from a file, which means astart file with SET TERMOUT OFF could hang, waiting for aRETURN,with no message as to why it was waiting (or that it was waiting) Use

PAUSE with caution.

EXAMPLE

prompt Report Complete

pause Press RETURN to continue

PCTFREE

PCTFREE is a portion of the data block that is not filled by rows as they are inserted into a table, but is

reserved for later updates made to the rows in that block

PCTUSED

PCTUSED is the percentage of space in a data block that Oracle attempts to keep filled If the percent

used falls below PCTUSED, then a block is added to the list of free blocks in the segment PCTUSED

may be set on a table-by-table basis

PERCENT_RANK

SEE ALSO AGGREGATE FUNCTIONS, Chapter 12

Trang 29

FORMAT For aggregates:

PERCENT_RANK ( expr [, expr] ) WITHIN GROUP

( ORDER BY

expr [ DESC | ASC ] [NULLS { FIRST | LAST }]

[, expr [ DESC | ASC ] [NULLS { FIRST | LAST }]] )

For analytics:

PERCENT_RANK ( ) OVER ( [query_partition_clause] order_by_clause )

DESCRIPTION As an aggregate function, PERCENT_RANK calculates, for a hypothetical row R

identified by the arguments of the function and a corresponding sort specification, the rank of row R

minus 1 divided by the number of rows in the aggregate group This calculation is made as if the hypothetical

row R were inserted into the group of rows over which Oracle is to aggregate The arguments of the

function identify a single hypothetical row within each aggregate group Therefore, they must all evaluate

to constant expressions within each aggregate group The constant argument expressions and the

expressions in the ORDER BY clause of the aggregate match by position Therefore, the number of

arguments must be the same and their types must be compatible

The range of values returned by PERCENT_RANK is 0 to 1, inclusive The first row in any set has

a PERCENT_RANK of 0.

As an analytic function, for a row R, PERCENT_RANK calculates the rank of R minus 1, divided

by 1 less than the number of rows being evaluated (the entire query result set or a partition)

See Chapter 12 for an example of the use of PERCENT_RANK.

DESCRIPTION PERCENTILE_CONT is an inverse distribution function that assumes a continuous

distribution model It takes a percentile value and a sort specification, and returns an interpolated value

that would fall into that percentile value with respect to the sort specification Nulls are ignored in the

calculation

The firstexpr must evaluate to a numeric value between 0 and 1, because it is a percentile value This

expr must be constant within each aggregation group The ORDER BY clause takes a single expression that

must be a numeric or datetime value, as these are the types over which Oracle can perform interpolation

DESCRIPTION PERCENTILE_DISC is an inverse distribution function that assumes a discrete

distribution model It takes a percentile value and a sort specification and returns an element from the

set Nulls are ignored in the calculation

Trang 30

The firstexpr must evaluate to a numeric value between 0 and 1, because it is a percentile value.

This expression must be constant within each aggregate group The ORDER BY clause takes a single

expression that can be of any type that can be sorted

For a given percentile value P, PERCENTILE_DISC function sorts the values of the expression in the

ORDER BY clause, and returns the one with the smallest CUME_DIST value (with respect to the same

sort specification) that is greater than or equal to P

PMON PROCESS

The Process Monitor (PMON) is a background process used for recovery when a process accessing a

database fails.See BACKGROUND PROCESS

DESCRIPTION POWERMULTISET takes as input a nested table and returns a nested table of

nested tables containing all nonempty subsets (called submultisets) of the input nested table.expr can

be any expression that evaluates to a nested table; if that nested table is empty, an error is returned

POWERMULTISET_BY_CARDINALITY

SEE ALSO POWERMULTISET

FORMAT

POWERMULTISET ( expr, cardinality )

DESCRIPTION POWERMULTISET_BY_CARDINALITY takes as input a nested table and returns a

nested table of nested tables containing all nonempty subsets (called submultisets) of the input nested

table of the specified cardinality.expr can be any expression that evaluates to a nested table, and

cardinality can be any positive integer; if that nested table is empty, an error is returned

PRAGMA

A pragma statement is a directive to the compiler, rather than a piece of executable code Even though a

pragma statement looks like executable code and appears in a program (such as a PL/SQL block), it is

not actually executable and doesn’t appear as a part of the execution code of that block Rather, it gives

instructions to the compiler.See EXCEPTION_INIT.

PRECEDENCE

SEE ALSO LOGICAL OPERATORS, QUERY OPERATORS, Chapter 13

Trang 31

DESCRIPTION The following operators are listed in descending order of precedence Operators

with equal precedence are on the same line Operators of equal precedence are evaluated in succession

from left to right All ANDs are evaluated before any OR Each of these is listed and described separately

under its own symbol or name in this Alphabetical Reference

Operator Function

- SQL*Plus command continuation Continues a command on the following line.

& Prefix for parameters in a SQL*Plus start file Words are substituted for &1, &2, and so on.

SeeSTART.

& && Prefix for a substitution in a SQL command in SQL*Plus SQL*Plus will prompt for a value if an

undefined & or && variable is found && also defines the variable and saves the value; & does not.See& and &&, DEFINE, and ACCEPT.

: Prefix for a host variable in PL/SQL.

Variable separator, used in SQL*Plus to separate the variable name from a suffix, so that the

suffix is not considered a part of the variable name.

( ) Surrounds subqueries or lists of columns.

' Surrounds a literal, such as a character string or date constant To use a ' in a string constant,

use two ' marks (not a double quotation mark).

" Surrounds a table or column alias that contains special characters or a space.

" Surrounds literal text in a date format clause of TO_CHAR.

@ Precedes a database name in a COPY, or a link name in a FROM clause.

( ) Overrides normal operator precedence.

+ - Prefix sign (positive or negative) for a number or number expression.

* / Multiplication and division.

+ - Addition and subtraction.

|| Char value concatenation.

NOT Reverses result of an expression.

AND Returns TRUE if both conditions are true.

OR Returns TRUE if either condition is true.

UNION Returns all distinct rows from both of two queries.

INTERSECT Returns all matching distinct rows from two queries.

MINUS Returns all distinct rows in the first query that are not in the second.

PRECOMPILER

A precompiler program reads specially structured source code, and writes a modified (precompiled)

source program file that a normal compiler can read

PREDICATE

The predicate is the WHERE clause and, more explicitly, a selection criteria clause based on one

of the operators (=, !=, IS, IS NOT, >, >=) and containing no AND, OR, or NOT.

Trang 32

PREPARE (Embedded SQL)

SEE ALSO CLOSE, CURSOR, DECLARE, FETCH, OPEN,Programmer’s Guide to the Oracle

Precompilers

FORMAT

EXEC SQL [AT { db_name | :host_variable }] PREPARE statement_id

FROM { :host_string | 'text' | select_command }

DESCRIPTION PREPARE parses SQL in the host variable :host_string or the literal text It assigns

astatement_id as a reference to the SQL If the statement_id has been used previously, this reference

replaces it The SQL is a SELECT statement, and may include a FOR UPDATE OF clause.:host_string

is not the actual name of the host variable used, but a placeholder OPEN CURSOR assigns input host

variables in its USING clause, and FETCH assigns output host variables in its INTO clause, based on

position A statement needs to be PREPAREd only once It can then be executed multiple times.

NOTE

See the Programmer’s Guide to the Oracle Precompilers for a full list

of all commands This reference does not contain all of the possibleprecompiler commands

EXAMPLE

query_string : string(1 100)

get(query_string);

EXEC SQL prepare FRED from :query_string;

EXEC SQL execute FRED;

PRESENTNNV

SEE ALSO PRESENTV

FORMAT

PRESENTNNV ( cell_reference, expr1, expr2 )

DESCRIPTION PRESENTNNV is relevant only for interrow calculations It can be used only in the

MODEL clause of the SELECT statement and then only on the right side of a model rule It returnsexpr1

when, prior to the execution of the MODEL clause,cell_reference exists and is not null Otherwise it

returnsexpr2

PRESENTV

SEE ALSO PRESENTNNV

FORMAT

PRESENTV ( cell_reference, expr1, expr2 )

DESCRIPTION PRESENTV is relevant only for interrow calculations It can be used only in the

MODEL clause of the SELECT statement and then only on the right side of a model rule It returnsexpr1

when, prior to the execution of the MODEL clause,cell_reference exists (but may be null) Otherwise it

returnsexpr2

Trang 33

SEE ALSO ITERATION_NUMBER

FORMAT

PREVIOUS ( cell_reference )

DESCRIPTION PREVIOUS is relevant only for interrow calculations It can be used only in the

MODEL clause of the SELECT statement and then only in the ITERATE … [UNTIL] clause of the MODEL

RULES clause It returns the value ofcell_reference at the beginning of each iteration

DESCRIPTION PRINT displays the current value of the specified variable (which is created via

the VARIABLE command) You can print the current values of multiple variables in a single command.

PRIOR

See CONNECT BY

PRIVILEGE

A privilege is a permission granted to an Oracle user to execute some action In Oracle, no user can

execute any action without having the privilege to do so

There are two kinds of privileges: system privileges and object privileges System privileges extend

permission to execute various data definition and data control commands, such as CREATE TABLE and

ALTER USER, or even to log onto the database Object privileges extend permission to operate on a

particular named database object

System privileges in Oracle include CREATE, ALTER, and DROP privileges for the various CREATE,

ALTER, and DROP commands Privileges with the keyword ANY in them mean that the user can exercise

the privilege on any schema for which the privilege has been granted, not just his or her own schema

The standard privileges in the list following just give permission to execute the indicated command, and

don’t require further explanation Some of the privileges aren’t intuitively clear; these are explained here

System privileges include:

TUNING

ADVISOR Access the advisor framework through PL/SQL packages including

DBMS_ADVISOR and DBMS_SQLTUNE.

ADMINISTER SQL TUNING SET Create, drop, select, load, and delete a SQL tuning set owned by the

grantee through the DBMS_SQLTUNE package.

ADMINISTER ANY SQL TUNING SET Create, drop, select, load, and delete a SQL tuning set owned by any

user through the DBMS_SQLTUNE package.

Trang 34

Privilege Permission to

CREATE ANY SQL PROFILE Accept a SQL profile recommended by the tuning advisor.

DROP ANY SQL PROFILE Drop an existing SQL profile.

ALTER ANY SQL PROFILE Alter the attributes of an existing SQL profile.

CLUSTERS

CREATE CLUSTER Create clusters in grantee’s schema.

CREATE ANY CLUSTER Create a cluster in any schema Behaves similarly to CREATE

ANY TABLE.

ALTER ANY CLUSTER Alter clusters in any schema.

DROP ANY CLUSTER Drop clusters in any schema.

CONTEXTS

CREATE ANY CONTEXT Create any context namespace.

DROP ANY CONTEXT Drop any context namespace.

DATABASE

DATABASE LINKS

CREATE DATABASE LINK Create private database links in grantee’s schema.

CREATE PUBLIC DATABASE LINK Create public database links.

DROP PUBLIC DATABASE LINK Drop public database links.

DEBUGGING

DEBUG CONNECT SESSION Connect the current session to a debugger.

DEBUG ANY PROCEDURE Debug all PL/SQL and Java code in any database object Display

information on all SQL statements executed by the application.

DIMENSIONS

CREATE DIMENSION Create dimensions in the grantee’s schema.

CREATE ANY DIMENSION Create dimensions in any schema.

ALTER ANY DIMENSION Alter dimensions in any schema.

DROP ANY DIMENSION Drop dimensions in any schema.

DIRECTORIES

CREATE ANY DIRECTORY Create directory database objects.

DROP ANY DIRECTORY Drop directory database objects.

INDEXTYPES

CREATE INDEXTYPE Create an indextype in the grantee’s schema.

CREATE ANY INDEXTYPE Create an indextype in any schema.

Trang 35

Privilege Permission to

ALTER ANY INDEXTYPE Modify indextypes in any schema.

DROP ANY INDEXTYPE Drop an indextype in any schema.

EXECUTE ANY INDEXTYPE Reference an indextype in any schema.

INDEXES

CREATE ANY INDEX Create in any schema a domain index or an index on any table in

any schema.

ALTER ANY INDEX Alter indexes in any schema.

JOB SCHEDULER OBJECTS

CREATE JOB Create jobs, schedulers, or programs in the grantee’s schema (using

DBMS_SCHEDULER).

CREATE ANY JOB Create, alter, or drop jobs, schedules, or programs in any schema.

EXECUTE ANY PROGRAM Use any program in a job in the grantee’s schema.

EXECUTE ANY CLASS Specify any job class in a job in the grantee’s schema.

MANAGE SCHEDULER Create, alter, or drop any job class, window, or window group.

LIBRARIES

CREATE LIBRARY Create external procedure/function libraries in grantee’s schema.

CREATE ANY LIBRARY Create external procedure/function libraries in any schema.

DROP ANY LIBRARY Drop external procedure/function libraries in any schema.

MATERIALIZED VIEWS

CREATE MATERIALIZED VIEW Create a materialized view in the grantee’s schema.

CREATE ANY MATERIALIZED VIEW Create materialized views in any schema.

ALTER ANY MATERIALIZED VIEW Alter materialized views in any schema.

DROP ANY MATERIALIZED VIEW Drop materialized views in any schema.

QUERY REWRITE This privilege has been deprecated.

GLOBAL QUERY REWRITE Enable rewrite using a materialized view when that materialized

view references tables or views in any schema.

ON COMMIT REFRESH Create a refresh-on-commit materialized view on any table in the

database.

Alter a refresh-on-demand materialized view on any table in the database to refresh-on-commit.

FLASHBACK ANY TABLE Issue a FLASHBACK QUERY on any table, view, or materialized

view in any schema.

OPERATORS

CREATE OPERATOR Create an operator and its bindings in the grantee’s schema.

CREATE ANY OPERATOR Create an operator and its bindings in any schema.

ALTER ANY OPERATOR Modify an operator in any schema.

Trang 36

Privilege Permission to

DROP ANY OPERATOR Drop an operator in any schema.

EXECUTE ANY OPERATOR Reference an operator in any schema.

OUTLINES

CREATE ANY OUTLINE Create public outlines that can be used in any schema that uses

outlines.

PROCEDURES

CREATE PROCEDURE Create stored procedures, functions, and packages in grantee’s

schema.

CREATE ANY PROCEDURE Create stored procedures, functions, and packages in any schema.

ALTER ANY PROCEDURE Alter stored procedures, functions, or packages in any schema.

DROP ANY PROCEDURE Drop stored procedures, functions, or packages in any schema.

EXECUTE ANY PROCEDURE Execute procedures or functions (stand-alone or packaged).

Reference public package variables in any schema.

PROFILES

ROLES

ALTER ANY ROLE Alter any role in the database.

GRANT ANY ROLE Grant any role in the database.

ROLLBACK SEGMENTS

CREATE ROLLBACK SEGMENT Create rollback segments.

ALTER ROLLBACK SEGMENT Alter rollback segments.

DROP ROLLBACK SEGMENT Drop rollback segments.

SEQUENCES

CREATE SEQUENCE Create sequences in grantee’s schema.

CREATE ANY SEQUENCE Create sequences in any schema.

ALTER ANY SEQUENCE Alter any sequence in the database.

DROP ANY SEQUENCE Drop sequences in any schema.

SELECT ANY SEQUENCE Reference sequences in any schema.

SESSIONS

Trang 37

Privilege Permission to

ALTER RESOURCE COST Set costs for session resources.

RESTRICTED SESSION Log on after the instance is started using the SQL*Plus STARTUP

RESTRICT statement.

SYNONYMS

CREATE SYNONYM Create synonyms in grantee’s schema.

CREATE ANY SYNONYM Create private synonyms in any schema.

CREATE PUBLIC SYNONYM Create public synonyms.

DROP ANY SYNONYM Drop private synonyms in any schema.

DROP PUBLIC SYNONYM Drop public synonyms.

TABLES

CREATE TABLE Create tables in grantee’s schema.

CREATE ANY TABLE Create tables in any schema The owner of the schema containing the

table must have space quota on the tablespace to contain the table.

ALTER ANY TABLE Alter any table or view in any schema.

BACKUP ANY TABLE Use the Export utility to incrementally export objects from the schema

of other users.

DELETE ANY TABLE Delete rows from tables, table partitions, or views in any schema.

DROP ANY TABLE Drop or truncate tables or table partitions in any schema.

INSERT ANY TABLE Insert rows into tables and views in any schema.

LOCK ANY TABLE Lock tables and views in any schema.

SELECT ANY TABLE Query tables, views, or materialized views in any schema.

FLASHBACK ANY TABLE Issue a flashback query on any table, view, or materialized view

in any schema.

UPDATE ANY TABLE Update rows in tables and views in any schema.

TABLESPACES

CREATE TABLESPACE Create tablespaces.

MANAGE TABLESPACE Take tablespaces offline and online and begin and end tablespace

backups.

UNLIMITED TABLESPACE Use an unlimited amount of any tablespace This privilege overrides

any specific quotas assigned If you revoke this privilege from a user, the user’s schema objects remain but further tablespace allocation is denied unless authorized by specific tablespace quotas You cannot grant this system privilege to roles.

Trang 38

Privilege Permission to TRIGGERS

CREATE TRIGGER Create a database trigger in grantee’s schema.

CREATE ANY TRIGGER Create database triggers in any schema.

ALTER ANY TRIGGER Enable, disable, or compile database triggers in any schema.

DROP ANY TRIGGER Drop database triggers in any schema.

ADMINISTER DATABASE TRIGGER Create a trigger on DATABASE (You must also have the CREATE

TRIGGER or CREATE ANY TRIGGER privilege.)

TYPES

CREATE TYPE Create object types and object type bodies in grantee’s schema.

CREATE ANY TYPE Create object types and object type bodies in any schema.

ALTER ANY TYPE Alter object types in any schema.

DROP ANY TYPE Drop object types and object type bodies in any schema.

EXECUTE ANY TYPE Use and reference object types and collection types in any schema,

and invoke methods of an object type in any schema if you make the grant to a specific user If you grant EXECUTE ANY TYPE to a role, users holding the enabled role will not be able to invoke methods of

an object type in any schema.

UNDER ANY TYPE Create subtypes under any nonfinal object types.

USERS

CREATE USER Create users This privilege also allows the creator to:

Assign quotas on any tablespace.

Set default and temporary tablespaces.

Assign a profile as part of a CREATE USER statement.

ALTER USER Alter any user This privilege authorizes the grantee to:

Change another user’s password or authentication method.

Assign quotas on any tablespace.

Set default and temporary tablespaces.

Assign a profile and default roles.

VIEWS

CREATE ANY VIEW Create views in any schema.

UNDER ANY VIEW Create subviews under any object views.

MISCELLANEOUS

ANALYZE ANY Analyze any table, cluster, or index in any schema.

AUDIT ANY Audit any object in any schema using AUDITschema_objects

statements.

COMMENT ANY TABLE Comment on any table, view, or column in any schema.

Trang 39

Privilege Permission to

EXEMPT ACCESS POLICY Bypass fine-grained access control This is a very powerful system

privilege, as it lets the grantee bypass application-driven security policies Database administrators should use caution when granting this privilege.

FORCE ANY TRANSACTION Force the commit or rollback of any in-doubt distributed transaction

in the local database Induce the failure of a distributed transaction.

FORCE TRANSACTION Force the commit or rollback of grantee’s in-doubt distributed

transactions in the local database.

GRANT ANY OBJECT PRIVILEGE Grant any object privilege.

GRANT ANY PRIVILEGE Grant any system privilege.

SELECT ANY DICTIONARY Query any data dictionary object in the SYS schema This privilege

lets you selectively override the default FALSE setting of the O7_DICTIONARY_ACCESSIBILITY initialization parameter.

ALTER DATABASE: open, mount, back up, or change character set.

CREATE DATABASE.

ARCHIVELOG and RECOVER.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege

ALTER DATABASE OPEN | MOUNT | BACKUP.

ARCHIVELOG and RECOVER.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege.

CONNECT, RESOURCE, and DBA Provided for compatibility with previous versions of Oracle Database

software.

DELETE_CATALOG_ROLE, EXECUTE_CATALOG_ROLE, SELECT_CATALOG_ROLE

These roles are provided for accessing data dictionary views and packages.

EXP_FULL_DATABASE, IMP_FULL_DATABASE

These roles are provided for convenience in using the Import and Export utilities.

AQ_USER_ROLE, AQ_ADMINISTRATOR_ROLE

These roles are needed for Oracle Advanced Queueing.

SNMPAGENT This role is used by the Enterprise Manager Intelligent Agent.

RECOVERY_CATALOG_OWNER This role is required for the creation of a recovery catalog schema

owner.

HS_ADMIN_ROLE Needed for support of Heterogeneous Services.

SCHEDULER_ADMIN This role allows the grantee to execute the DBMS_SCHEDULER

package’s procedures.

Trang 40

Procedures, Functions, Packagesa

Materialized View Directory Library

defined Type Operator

User- type

X

QUERY REWRITE

PRO*C

PRO*C is an extension to C that lets you develop user exits and other programs that access the Oracle

database A precompiler converts PRO*C code into normal C code, which can then be compiled.See

thePro*C/C++ Precompiler Programmer’s Guide

PROCEDURE

A procedure is a set of instructions (usually combining SQL and PL/SQL commands) saved for calling

and repeated execution.See CREATE PROCEDURE.

Ngày đăng: 08/08/2014, 20:21

TỪ KHÓA LIÊN QUAN