Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
85 views

Oracle SQL Quick Reference 6.0 - Quick Hand Guide

SQL Language Quick Reference is intended for all users of Oracle SQL

Uploaded by

pedal.miguelo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Oracle SQL Quick Reference 6.0 - Quick Hand Guide

SQL Language Quick Reference is intended for all users of Oracle SQL

Uploaded by

pedal.miguelo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Quick Reference

SQL Language Quick Reference


Version 6.0
Version 6.0

Part No. 5421-V6.0


January 1990

Copyright © Oracle Corporation 1990


" All rights reserved. Printed in the U.s.A.

Restricted Rights Legend


. Use, duplication, or disclosure of the Programs is subject to restrictions stated in
your_contract with Oracle Corporation.
Use, duplication, or disclosure of the Programs by the Government is subject to
restrictions for commercial computer software and the Programs shall be
deemed to be licensed with Restricted Rights under Federallaw.
The info'rmation in this document is subject to change without notice. lf you
find any problems in the documentation, please report them to us in writing ..
Oracle Corporation does not warrant that this document is error-free.
\1 "G {Ié' {/
lie 12 b .A-~/i-
DRACLE® II/~\?r (')/'.~
SQL Language Quick Reference
This Reference briefly describes elements of SQL used with ORACLE Version 6.0.
For details on SQL, refer to the SQL Language Reference Manual, Part No. 778-V6.0.

Syntaxand Notation Used in this Reference

UPPERCASE CREATE Enter text exactly as shown.


italic col umn Para meter. Substitute an appropriate value.
parameters cha r Character constant in single quotes 01'
with specific expression of datatype CHAR.
meanings column element Column definition. For the format of
columnJlement refer to the CREATE TABLE
statement.
d or e Date constant 01' expression of datatype DATE.
expr Anyexpression.
f il espec File specification. For the format of filespec,
refer to the CREATE DAT ABASE statement.
integer Number constant 01' expression of datatype
NUMBER. Must evaluate to an integer.
m or n Any number constant 01' expression of
datatype NUMBER.
condi tion Expression that logically evaluates to TRUE
or FALSE, such as JOS='SALESMAN'.
raw Expression of datatype RAW.
rowid Expression of datatype ROWID.
storage Storage clause. For the format of storage,
refer to the CREATE TABLE statement.
Query express ion in another statement, such
as CREATE TABLE .., AS query.
brackets [] [NOWAIT] Optional item. Do not enter the brackets.
braces and {exprl expr} Choice between expressions. Enter one of
vertical bar the items separated by l. Do not enter the
{ I } braces 01' the vertical bar.
ellipses ... expr[, expr] ... Preceding item may be repeated multiple times.
( ) (expr) Enter parentheses, commas, periods, single
p, s quotes, and @ exactly as shown.
user.
, filename'
@ @
underlining [ASCI DESC] Indicates the default value. If you enter
nothing, ORACLE uses this value.
SQL Language Quick Reference
Data Manipulation Language (DML) Statements and Queries Data Definition Language (DDL) Statements

COMMIT [WORK] ALTER CLUSTER [user.]cluster


[PCTUSED integer] [PCTFREE integer]
Saves the ehanges in the current transaction to the database. Also erases
[SIZE integer]
the transaetion's savepoints and releases the transaetion's loeks.
[INITRANS integer] [MAXTRANS integer]
DELETE [FROM] [user.] {table I view) [alias] [STORAGE storage]
[WHERE condition]
Redefines storage al1ocations for an existing cluster.
Removes rows that meet the WHERE condition from a table or víew.
Removes all rows if no WHERE condition is specified. ALTER DATABASE [database]
{ADD LOGFlLE filespec [REUSE]
INSERT INTO [user.] {tablelview} [(column [,column] ... )] [, filespec [REUSE]]
{VALOES(value [,value] ... )lquery) I DROP LOGFlLE 'filename' [,' filename' ]
Adds new rows to a table or view. IRENAME FlLE 'filename' [,' filename']
ROLLBACK [WORK] [TO [SAVEPOINTj savepoint] TO 'filename' [, f filename' ]
IDATAFlLE filespec [ONLlNEIOFFLlNE]
Undoes al1 changes made sinee the savepoint. Undoes a11changes in
IBACKUP CONTROLFlLE TO filespec
the current transaetion if no savepoint is specified.
IARCHlVELOG
SAVEPOINT sa vepoin t 1NOARCHlVELOG
Identifies a savepoint in the eurrent transaction to whieh changes ean be IMOUNT [EXCLUSlVEISHARED]
rol1ed baek. IDISMOUNT
IOPEN [RESETLOGSINORESETLOGS]
SELECT [ALLI DISTINCT]
1CLOSE [NORMAL I IMMEDIATE] }
{*I[user.]{tablelvievl}.*lexpr [c_alias])
[, {[user.]{tablelview).*lexpr [c_alias])] ... Redefines an existing database by:
FROM [user.]{tablelview}[@link] [t_alias] . adding or dropping a redo log file
[, [user.] {table I view} [@link] [t_alias]] . renammg a database file or a redo 10g file
[WHERE condition] Changes the state of a database by:
[CONNECT BY condition [START WITH condition]]
enabling or disabling arehiving of redo log files
[GROUP BY expr [, expr] ... ] mounting or dismounting the i:latabase
[HAVING condi tion] opening or c10sing the database
[{UNIONIINTERSECTIMINUS) query]
ALTER INDEX [user.]index
[ORDER BY (exprlposn) [ASC 1DESC]
[INITRANS integer] [MAXTRANS integer]
[, {exprlposn} [ASCIDESC]] ... ].
[STORAGE storage]
[FOR UPDATE OF column [,column] [NOWAIT]]
Redefines storage al1oeations for an existing index.
Queries one or more tables or víews. Returns rows and columns of
data. May be used as a statement or as a subquery in another ALTER [PUBLIC] ROLLBACK SEGMENT rollback_segment
statement. STORAGE storage

UPDATE [user.] {tablelview) [alias] Redefines storage al1oeations for an existing rollback_segment, or makes
SET column = expr [, column = expr]
a prívate rollback_segment PUBLICo
[WHERE condition] ALTER SEQUENCE [user.]sequence
or [INCREMENT BY integer]
[MAXVALOE in t ege r I NOMAXVALOE]
UPDATE [user.]{tablelview} [alias]
[MINVALOE integerlNOMINVALOE]
SET (column [,column] ... ) = (subquery)
[CYCLE 1NOCYCLE]
[WHERE condition]
[CACHE integerlNOCACHE]
Changes the values of columns in rows that meet the WHERE condition [ORDER I NOORDER]
in a table or víew. Changes alJ rows if no WHERE condition is specified.
Redefines an existing sequence.
ALTER SESSION SET SQL_TRACE {TRUEIFALSE} AUDIT {optíon [,optíon] ... IALL}
Enables and di sables the SQL trace facility for the current user session. ON {[user.] {tablelvíewlsequencelsynonym} IDEFAULT}
[BY {SESSIONIACCESS}]
For information on the SQL trace facility, refer to the ORACLE RDBM5
[WHENEVER [NOT] SUCCESSFUL]
Performance Tuning Cuide, Part No. 531?-V6.0.
Enables auditing of access to a lable, view, sequence, or synonym based
ALTER TABLE [user.]table on the oplions. Enables default auditing of al! subsequently created
[ADD ({column_elementltable_constraint) tables if the DEFAULT option is specified.
[, {column_element I table_constraint}] )]
The oplions may include ALTER, AUDIT, COMMENT, DELETE,
[MODIFY (column_element [, column_element] )]
GRANT, INDEX, INSERT, LOCK, RENAME, SELECT, or UPDATE,
[DROP CONSTRAINT constraintj
depending on the types of objects.
[PCTFREE integer] [PCTUSED integer]
[INITRANS integer] [MAXTRANS ínteger] COMMENT ON {TABLE [user.] {tablelvíew}
[STORAGE storage] ICOLUMN [user.] {tablel view} .column}
[BACKUP] IS char
Redefines the columns, constraints, or storage alIocations of an existing Adds a comment about a table, view, or column to the Data Dictionary.
lable. Also records in the Data Dictionary that a table has been backed up. CREATE CLUSTER cluster
ALTER TABLESPACE tablespace (column datatype [,column datatype] ... )
(ADD DATAFILE filespec [REUSE] [PCTUSED 401 ínteger] [PCTFREE 101 ínteger]
[, fílespec [REUSE]] [SIZE ínteger]
IRENAME DATAFlLE 'fílename' [,' filename'] [INITRANS 1.1 ínteger] [MAXTRANS 2551 ínteger]
TO ' fílename' [,' fílename' ] [TABLESPACE tablespace]
I DEFAULT STORAGE storage [STORAGE storage]
IONLINE Creates a new cluster and specifies its cluster key columns.
IOFFLINE [NORMAL I IMMEDIATE]
CREATE DATABASE database
I {BEGIN IEND} BACKUP}
[CONTROLFILE REUSE]
Redefines an existing tablespace by: [LOGFlLE fílespec [, fílespec] ... J
· adding or renaming a database file [MAXLOGFILES ínteger]
· redefining default storage al1ocations [DATAFILE fílespec [, fílespec] ... ]
AIso changes the state of a lablespace by: [MAXDATAFILES ínteger]
[MAXINSTANCES ínteger]
moving the tablespace ONLINE or OFFLINE
· signifying that a backup of the database files has begun or completed [ARCHlVELOGINOARCHIVELOG]
[EXCLUSIVE]
ALTER USER user [IDENTIFIED BY password]
[DEFAULT TABLESPACE tablespace]
Creates a new database and:
[TEMPORARY TABLESPACE tablespace] sets maximum numbers of instances, database mes, and redo log files
specifies database files and redo log files
Changes the password, default tablespace, or temporarylablespace of an chooses mode for the redo log
existing user.
filespec is a file specification in this form:
AUDIT {system_opticn [,system optíon] I ALL}
[WHENEVER [NOT] SUCCESSFUL] , fílename' ¡SIZE ínteger [KIM]] [REUSE)

Enables auditing of database access based on the syslem_oplions. CREATE [PUBLIC] DATABASE LINK link
The system_options include CONNECT, DBA, NOT EXISTS, and [CONNECT TO user IDENTIFIED BY password]
RESOURCE. USING ' connect_stríng'
Creates a link from the local database to a user on a remote database
specified by a connecl_string. For information on specifying a remote
database, refer to the manual for your specific SQL*Net protocol.
CREATE [UNIQUE] INDEX index CREATE TABLE (continued)
ON {tab1e (co1umn (~IDESC)
column_element defines a column and has the form:
[, co1umn (MQIDESC)] ... )
ICLUSTER cluster} co1umn datatype [DEFAULT expr] [column_constraint]
[INITRANS integer] [MAXTRANS integer] where:
[TABLESPACE tab1espace]
[STORAGE storage] col umn is the column name.
[PCTFREE {lO I integer}] datatype is one ofthese datatypes:
[NOSORT] CHAR(size) or Variable length character string of up to size
Creates a new index on the specified columns in a table 01' cluster. CHARACTER (si characters. size defaults to 1. Maximum size
ze)

CREATE [PUBLIC] ROLLBACK SEGMENT ro1lback_segment is 255.


[TABLESPACE {SYSTEMltab1espace}] Dates ranging from January 1, 4712 BC to
[STORAGE storage] December 31, 4712 AD.
Creates a new rollback_segment. DECIMAL ( [ (p I * ) Same as NUMBER(p,s) except that s al ways
[, s] ]) defaults to O.
CREATE SEQUENCE [user.]sequence
[INCREMENT BY al
integer}] DOUBLE Same as NUMBER.
[START WITH integer] PRECISION
[MAXVALUE integerl NOMAXVALUE] FLOAT ( [p I *] ) Same as NUMBER(p) 01'NUMBER(*).
[MINVALUE in t ege r I NOMINVALUE] Same as NUMBER(38,O).
INTEGER
[ CYCLE I NOCYCLE]
[CACHE {201 integerl INOCACHE] LONG or Variable length character string of up to
[ ORDER INOORDER] LONG VARCHAR 65,535 characters.
Creates a new sequence. LONG RAW Binary data of up to 65,535 bytes.
CREATE [PUBLIC] SYNONYM synonym NUMBER( [{pl *} Numbers up to p digits long and up to s
FOR [user. J (tab1el viewlsequencelsynonym) [@link] [, s]]) digits to the right of the decimal point.
Creates a new synonym for a table, view, sequence, 01'another synonym. p ranges fram 1 to 38 and defaults to 38.
s ranges fram -84 to 127. lf you specify p, s
PUBLlC synonyms are available to all users. Creating PUBLIC
defaults to O. lf you do not specify p, s
synonyms requires DBA privilege.
defaults to null, 01'floating point number.
CREATE TABLE (user.] tab1e * al10ws you to specify s without specifying p.
( {co1umn elementltab1e constraint} Binary data of up to size bytes. Maximum
[, {co1umn=e1ement I tab1e=constraint}] ... ) size is 255.
[PCTFREE {lO I integerl ] [PCTUSED {.iQ.1 integer} ]
Same as NUMBER.
[INITRANS (l.linteger)] [MAXTRANS {255Iinteger}]
[TABLESPACE {SYSTEKltablespace}] ROWID Values fram the pseudo-column RüWID.
[STORAGE storage] SMALLINT Same as NUMBER(38,O).
[CLUSTER cluster (co1umn [, co1umn] ... )]
VARCHAR (si ze) . Same as CHAR(size).
[AS query]
Creates a new table and defines its columns, constraints, and storage DEFAULT expr specifies the default value fol' the column.
allocations. column constraint restricts the range of valid values for the
(CREATE TABLE continued on the next page.) column.
For more information on default values and column constraints, refer
to the SQL Language Reference Manual, Part No. 778-V6.0.
(CREATE TABLE continued on the next page.)
CREATE TABLE (eontinued) DROP TABLESPACE tablespaee (INCLODING CONTENTS]

tableJonstraintrestricts the range of valid values for one or more Removes a tablespace from the database. Also removes all database
columns in the table. For more information on table constraints, refer objeets, sueh as tables and views, in the tablespace if you specify the
to the SQL Language Reference Manual, Part No. 778-V6.O. INCLUDING CONTENT5 option.
storage specifies storage allocation for a table, cluster, index, rollback DROP VIEW [user.]view
segment, or tablespace. storage has this form: Removes a view from the database.
( [INITIAL 10240 I integer] [NEXT 10240 I integer]
GRANT database_priv [, database_priv]
[MINEXTENTS 1.1 integer] [MAXEXTENTS 991 inceger] TO user [, user]
[PCTINCREASE 50 I integer] ) [IDENTIFIED BY password [, password] ... ]
Por more inforrnation on the storage clause and parameters, refer to Gives database privileges to a user.
the SQL Language Reference Manual, Part No. 778-V6.O. Oatabase privileges include OBA, CONNECT, and RESOURCE.
CREATE TABLESPACE tablespace GRANT RESO'ORCE [(quota [KIM])]
DATAFILE filespee [,fi1espee] ON tablespaee
[DEFAULT STORAGE storage] TO {PUBLIC I user [, user] ... }
[ONLINEIOFFLINE]
Gives a user access to a tablespace. Gives all users access to a tablespace
Creates a new tablespace and specifies: if PUBLlC is specified. Can also impose a quota on the space the user
the database files can use .
• the default storage allocations
. whether the tablespace is initial!y ONLlNE or OFFLINE GRANT {objeet_pri v [, objeet pri v] ... IALL [PRIVILEGES]}
ON (user.) {tablelviewlsequeneelsynonym}
CREATE VIEW [user.] view [(e_alias [, e~alias] ... )]
TO {userIPUBLIC} [, user]
AS query
[WITH GRANT OPTION]
[WITH CHECK OPTION [CONSTRAINT eonstraint]]
Gives a user object privileges on a table, view, sequence, or synonym.
Creates a new view. Gives al! users objeet privileges if PUBLICis specified. Allows a user
DROP CLUSTER [user.]eluster [INCLUDING TABLES] to subsequently give another user object privileges if the WITH
Removes a cluster from the database. Also removes tables in the cluster GRANT OPTION is specified.
if you specify the INCLUDING TABLE5option. Object privileges may include ALTER, OELETE,INOEX, IN5ERT,
REFERENCES,SELECT,or UPDATE, depending on the type of object.
DROP [PUBLIC] DATABASE LINK link
Removes a link to a remote databa se. LOCK TABLE [user.]table [, [user.]table]
IN (ROW SHARE
Removing a PUELlC database link requires OBA privilege.
IROW EXCLUSIVE
DROP INDEX [user.]index 1 SHARE UPDATE
Removes an index from the database. ISHARE
I SHARE ROW EXCLUSlVE
DROP [PUBLIC) ROLLBACK SEGMENT rollbaek_segment
IEXCLUSlVE) MODE
Removes a rollback_segment from the database. [NOWAIT]
DROP SEQUENCE [user.]sequenee Overrides default lock mode and reserves access to a table for the
Removes a sequence from the databa se. eurrent transaction. Perrnits or restricts aceess by other users,
depending upon the specified lock mode.
DROP [PUBLIC] SYNONYM [user.]synonym
For information on lock modes, refer to the ORACLE RDBMS Database
Removes a synonym from the databa se.
Administrator'sCuide, Part No. 3601-V6.O.
Removing a PUELlC synonym requires DBA privilege.
NOAUDIT {system_option [, system_option] ... IALL}
DROP TABLE [user.]cable [WHENEVER [NOT] SUCCESSFUL]
Removes a table from the database. Oisables auditing of database aceess based on the system_options.
NOAUDIT {option [,option] ... IALL} Operators
ON {tablelviewlsequencelsynonymIDEFAULT)
[WHENEVER (NOT) SUCCESSFUL] These tables list operators in descending order of precedence. In these tables,
Disables auditing of a table, view, sequence, or synonym based on the dotted lines separate operators of different precedence. When evaluating an
options. Disables default auditing of subsequently created tables if the expression, ORACLE evaluates operators with greater precedence first.
DEFAULT option is specified. Note: Parentheses O override normal precedence. ORACLE evaluates
RENAME old TO new operators inside parentheses before those outside.
Renames a table, view, or synonym fram old to new.
REVOKE database_pri v [,database_pri v] Arithmetic Operators
FROM user [,user] Operator
Revokes database privileges fram a user.
Database privileges include CONNECf, RESOURCE, and DBA. + .~..<()f\~op~r~.f\~) I?~n()t~s.~. p()s.it.i~~.()~11~~ati\,~ .~~p~~ssi()f\: ..

REVOKE RESOURCE
ON tablespace
FROM user [,user]
Revokes access to a tablespace fram a user.
REVOKE {object_pri v [,object_pri v] ... IALL [PRIVlLEGES]} Character Operators
ON [user.] {tablelviewlsequencelsynonym)
FROM {userIPUBLIC} [, user] Operator
Revokes object privileges on a table, view, sequence, or synonym from a user.
SET TRANSACTION READ ONLY
Enforces read consistency at the transaction leve!. Must be the first Comparison Operators
statement in the transaetion.
VALIDATE INDEX index
Operator
Checks the integrity of an index. Tests for equality.
!= 1\= <> Tests for inequality.
> >= < <= Greater than, greater than or equal to, less
than, less than or equal to.
You can use the ORACLE Precompilers to embed SQL statements into
Equal to any member of a set or subquery.
an application programo For the syntax of embedded SQL statements,
refer to the 5QL Language Reference Manual, Part No. 778-V6.0. AIso equivalent to '= ANY'.
Not equal to any member of a set or subquery.
Also equivalent to '!= ALL'.
Compares a value to each value returned by a
/* ... */ (Comment) list or subquery.
Comments may appear anywhere within a SQL statement. Compares a value to every value returned by a
EXPLAIN PLAN (SET
STATEMENT_ID = charJ list or subquery.
[INTO [user.] {PLAN_TABLEltable)] [Notl greater than or equal to x and Iess than
FOR sql_statement or equal to y.
Determines the plan ORACLE follows to execute a sqCstatement. TRUE if a subquery returns [does not returnl
Inserts a row into a table for each step of the execution plan. For at least one raw.
information on how to interpret an execution plan, refer to the
ORACLE RDBM5 Performance Tuning Cuide, Part No. 5317-V6.0.
Matches [does not match] a specified pattern.
'%' matches any sequence of characters; '_'
matches any single character.
ls [notl null.

ABS(n) Absolute value of n.


CEIL(n) Smallest integer greater than or equal to n.
Reverses a logical expression's resulto FLOOR(n) Largest integer equal to or less than n.
NOT
MOD(m,n) Remainder of m divided by n.
ANO Combines two or more logical expressions;
returns TRUE if all are TRUE, otherwise POWER(m,n) m raised to the nth power. n must be an integer.
returns FALSE. ROUNO(n[,m]) n rounded to m decimal places; m defaults to O.
Combines two or more logical expressions; SIGN(n) lf n<O, -1; if n=O, O; jf n>O, lo
retums TRUE if either is TRUE, otherwise SQRT(n) Square root of n; if n<O, NULL.
returns FALSE. TRUNC(n[,m]) n truncated to m decimal places; m defaults to O.

Single row character functions that return character values:


Combines two queries; returns all distinct Function Value Returned
rows returned by either individual query.
CHR(n) Character with ASCII value n.
Combines two queries; returns all distinct
rows returned by both individual queries. INITCAP(char) Cha"~with first lctter of each word capitalized.
Combines two queries; returns all distinct LOWER(char) char, with allletters lowercase.
rows returned by the first query but not by the LPAO(charl,n[,char2]) charl, left-padded to length n with the sequence
second. of characters in char2; char2 defaults to' '.
char, with initial characters removed up to the
first character not in seto set defauIts to ' '.
REPLACE(char,search _string char, with every occurrence of search_string
[,replacement_string]) replaced by replacement_string. If you do not
specify replacement_string, ORACLE removes
lndicates that the preceding column is an outer
all occurrences of search_string.
join column.
charl, right-padded to length n with the sequence
Wildcard operator used instead of column of characters in char2; char2 defaults to ' '.
names to select all columns from a table or
view. char, with final characters removed after the
las1character not in seto set defaults to ' '.
Used in WHERE clause to define a
parent-child relationship between nodes in a A char value representing the sound of the
word(s) in cha,.
tree-structured query.
Retains duplicate values in a query (ALL is the A substring of char, beginning at character m, n
default, as compared to DISTINCT). cnaracters long (if n is omitted, to end of char).
Eliminates duplicate values from the result of char, translated from the character set from to
a query. the character set to.
char, with allletters uppercase.
Single row character functions that return numeric values:
Function Value Returned
ASClI(char) ASCII value of the first character of char.
char, converted from a CHAR value to a
INSTR(char1,char2(,n Cm 11) Position of the mth occurrence of char2 in ROWID value.
char1, beginning search at position n. m and n
CONVERT(char[,dest_char _sel char, converted from source_char_set
defauIt to lo
[,source_char_set])) implementation to dest_char_set implementation.
Position is relative to the first character of
HEXTORA W(char) char, con verted from a hexadecimal number to
char1, even if n> 1.
a binary RAW value.
LENGTH(char) Length of char in characters.
raw, converted fram a binary value of datatype
NLSSORT(char) National Language value of char. RA W to a hexadecimal number of datatype
For information on National Language CHAR.
Support, refer to the ORACLE RDBMS Database rowid, con verted from a ROWID value to a
Administrator's Cuide, Part No. 3601-V6.0. CHAR value.
expr, con verted fram a NUMBER or DATE
value to a CHAR value in the format specified
by fmt. If you omit fmt, ORACLE converts
DATE values to default date format and
AVG ([DISTINCTI ALLl n) Average value of n, ignoring null values. NUMBER values to CHAR values exactly wide
COUNT([DISTINCTI ALLl Number of rows where expr is not null. enough to hold all significant digits.
(* Iexpr ) ) * returns all rows, including nuIl values. char, converted fram a CHAR value in the
MAX([DISTINCTI ALLl expr) Maximum value of expr. format fmt to a DATE value. If you omit fmt,
char must be in defauIt date formaL
MIN([DISTINCTI ALLl expr) Minimum value of expr.
char, which is a character value containing a
STDDEV([DISTINCT IALL) n) Standard deviation of n, ignoring null values.
number, converted to a NUMBER value.
SUM([DISTINCTI ALLl n) Sum of values of n.
VARIANCE([DISTINCT IALLl n) Variance of n, ignoring null values.

o ECO O E(expr,search1,return 1, If expr equals any search, returns the foIlowing


[search2,return2, l... [defauIt]) return; if not, returns default.
ADD _MONTHS(d,n) Date d plus n months. DUMP(expr[,display Jormat expr in ORACLE internal formaL
LAST_DA Y(d) Date of last day of month containing d. [,start -posit ion(,length 11 J)
MONTHS_BETWEEN(d,e) Nwnber of months by which e precedes d. GREA TEST(expr[,exprl ...) expr with the greatest value.
NEW _TIME(d,a,b) Date and time in time zone b when date and LEAST(expr(,exprl ...) expr with the least value.
time in time zone a are d. a and b are CHAR NVL(expr1,expr2) expr2, if expr1 is null; otherwise returns expr1.
values identifying time zones. UID Number that uniquely identifies the current user.
Date of the first day of the week named by USER Name of the current user.
char that is equal to or later than the date d. USERENV(option) Information useful for an application-specific
ROUND(dLfmt]) d rounded as specified by rounding unit fmt. audit trail table. For information on options,
SYSDATE Current date and time. refer to the SQL Language Reference Manual,
TRUNC(dLfmtD d truncated as specified by fmt. Part No. 778-V6.0.
For ROUND and TRUNC, fmt defaults to 'DD'. The number of bytes in ORACLE's internal
representation of expr.
SQL Language Quick Reference 15
This table lists the date format elements. You can use any combination of these This table lists the number format elements. You can use a combination of
elements as the fmt argument of the TO_CHAR or TO_DATE functions. these elements as the fmt argument of the TO_CHAR function.
fmt defaults to the default DATE format, 'DD-MON-YY'. Format
Format Element Value Returned Element Example Functíon

SCC or CC Century; '5' prefixes "Be" date with '-'o Number of "9"s determines length of returned
character.
YYYYor SYYYY Year; '5' prefixes "BC"date with '-'o
'0999' Prefixes value with leading zeroes.
YYVor YY or Y Last 3, 2, or 1 digit(s) of year.
Y,YYV Year with comma in this position. '$9999' Prefixes value with a dollar signo
SYEAR or YEAR Year, spelled out; '5' prefixes "Be" date with '-'. 'B9999' Returns zero value as blank, instead of "O".
BC or AD BC/ AD indicator. '9999MI' Returns "_"after negative values.
B.e. or A.D. BC/ AD indicator with periods. '9999PR' Returns negative values in <angle brackets>.
Q Quarter of year (1, 2,3, 4; JAN-MAR = 1).. '9,999' Returns value with a comma in this position.
MM Month of year (01-12; JAN=Ol).
'99.99' Returns value with a decimal point in this position.
MüNTH Month name, padded with blanks to 9 characters.
'999V99' Multiplies value by IOn, where n is the number
MüN Name of month, 3-letter abbreviation.
of "9"s after the "V".
WW or W Week of year (1-52) or month (1-5).
Returns value in scientific notation.
DDD or DD or D Day of year (1-366)or month 0-31) or week (1-7).
fmt must contain exactly four "E"s.
DAY Name of day, padded with blanks to 9 characters.
Returns value converted from Julian date to
DY Name of day, 3-letter abbreviation.
'MM/DD/YY' date formato
J Julian day (days since December 31,4713 BC).
AM or PM Meridian indicator.
A.M. or P.M. Meridian indicator with periods.
HH and HH12 Hour of day (1-12). Pseudo-eolumns are similar to table columns. You can query any of these
pseudo-columns, but you cannot change their values with DML statements:
HH24 Hour of day (0-23).
MI Minute (O-59). Column Name Value
SS or SSSSS Second (O-59)or seconds past midnight (0-86399). sequence.CURRV AL Current value of sequence for the current session.
l. , Punctuation is returned exactly as specified. sequence.NEXTV AL Next value of sequence for the current session.
" " Quoted string is returned exactly as specified. table.LEVEL 1 for a root node, 2 for a child of a root, etc.
You can add this prefix to date format elements: Used in the CONNECT BYclause of the
SELECTstatement.
FM "Fill mode." Suppresses blank padding when
Value that uniquely identifies a single row
prefixed to MONTH or DAY.
among other rows in the table.
FM is a toggle. Use FM twice to reenable
ROWID values are of datatype ROWID,not
blank padding.
NUMBERor CHAR.
You can add these suffixes to date format elements:
Position of a single row among other rows
TH Ordinal number ("DDTH" for "4TH"). selected by a query.
sr 5pelled-out number ("DDSP"for "FOUR"). ORACLE selects rows in an arbitrary order
SPTH and THSP Spelled-out ordinal number ("DDSPTH" for and evaluates ROWNUM before sorting rows
"FOURTH"). for an ORDER BYclause.
Data Dictionary Views
The Data Dictionary contains information about database objects, users, and events.
You can access this inforrnation through these views of the Data Dictionary:
Names of database objects, such as tables or columns, must: View Description
be between 1 and 30 characters long, except for database names, which Columns of all tables, views, and clusters
can be no longer than 8 characters accessible to the user.
begin with a letter A-Z
contain only the characters A-Z, 0-9, $, #, and _ ACCESSIBLE_TABLES Tables and views accessible to the user.
not contain quotation marks ALL_CATALOG Tables, views, synonyms, and sequences
not duplicate a SQL reserved word accessible to the user.
not duplicate the name of another object
Comrnents on colurnns of tables and views
Unless a name is always enclosed in quotation marks when used in statements,
accessible to the user.
the name is not case-sensitive.
ALL_COL_GRANTS Synonyrn for COLUMN]RIVILEGES.
ALL_COL_GRANTS_MADE Grants on colurnns for which the user is the
owner or the grantor.
SQL reserved words have special meanings in SQL statements. You may not Grants on columns for which the user or
use these words as names for database objects: PUELlC is the grantee.
ALL_ CONSTRAINTS Constraints on tables accessible to the user.
ACCESS DEFAULT" INITIAL ON* SMALLINT"
DELETE* INSERT" ALL_CONS_COLUMNS Primary, unique, and foreign key columns in
ADD ONLINE START
ALL* DESe' INTEGER* OPTION* SUCCESSFUL constraints owned by the user or on tables
ALTER* DISTINCT" INTERSECT OR* SYNONYM owned by the user.
ANO' DROP INTO* ORDER* SYSDATE ALL_DB_LINKS Database links accessible to the user.
ANY* ELSE IS* PCTFREE TABLE* ALL_DEF_AUDIT_OPTS Default auditing options for newly created objects.
AS* EXCLUSIVE LEVEL PRIOR THEN ALL_INDEXES Indexes on tables and clusters accessible to the
ASC* EXISTS* LIKE* PRIVILEGES* TO*
user.
AUDIT FILE LOCK PUBLlC* TRIGGER
BETWEEN* FLOAT" LONG RAW UID Columns cornprising indexes on tables and
BY* FOR* MAXEXTENTS RENAME UNION* cluster s accessible to the user.
CHAR* FROM* MINUS RESOURCE UNIQUE* ALL_OBJECTS Objects accessible to the user.
CHECK* GRANT* MODE REVOKE* UPDATE* ALL_SEQUENCES Sequences accessible to the user.
CLUSTER GRAPHIC MODIFY* ROW USER*
ALL_SYNONYMS Synonyms accessible to the user.
COLUMN GROUP* NOAUDIT ROWID VALIDATE
COMMENT HAVING* NOCOMPRESS ROWNUM VALUES* ALL_TABLES Tables accessible to the user.
COMPRESS IDENTIFIED NOT ROWS VARCHAR* ALL_TAB_COLUMNS Synonym for ACCESSIBLE_COLUMNS.
CONNECf IF NOWAIT SELECT* VARGRAPHIC ALL_TAB_COMMENTS Comments on al! tables and views accessible
CREATE* IMMEDIATE* NULL* SESSION* VIEW* to the user.
CURRENT* IN* NUMBER SET" WHENEVER*
DATE INCREMENT OF* WHERE* ALL_TAB_GRANTS Synonyrn for T ABLE]RIVILEGES.
SHARE
DBA INDEX OFFLINE SIZE WITH* ALL_TAB_GRANTS_MADE Grants on objects for which the user is the
DECIMAL* owner or the grantor.
Grants on tables for which the user or PUBLlC
* These words are also ANSI reserved words.
is the grantee.
ALL_USERS Al! database users.
ALL_VIEWS Views accessible to the user.
AUDIT_ACnONS Names and codes of audit trail action types.
CAT Synonym for USER_CATALOC. DBA_SYNONYMS All synonyms in the database.
CLU Synonym for USER_CLUSTERS. DBA_SYS_AUDIT_OPTS Current system auditing options.
COLS Synonym for USER_TAB_COLUMNS. DBA_TABLES All tables in the database.
COLUMN]RIVILEGES Grants on columns for which the user is the DBA_TABLESPACES Al! tablespaces.
grantor, grantee, or owner, or PUBLlC is the DBA_TAB_AUDIT_OPTS Auditing options for all database tables and views.
grantee. DBA_TAB_COLUMNS Columns of all database tables, views, and
Foreign key columns in constraints owned by clusters.
the user or on tables accessible to the user. DBA_TAB_COMMENTS Comments on all database tables and views.
CONSTRAINT_DEFS Constraints on tables accessible to the user. DBA_TAB_GRANTS AII grants on database objects.
DBA_AUDIT _CONNECT Synonym for USER~AUDIT_CONNECT. DBA_TS_QUOTAS Tablespace quotas for all users.
DBA_AUDIT_DBA Audit trail entries for actions requiring DBA DBA_USERS AII database users.
privilege. DBA_VIEWS Al! views in the database.
Audit trail entries for any action resulting in Synonym for DICTIONARY.
DICT
an error because a specified database object
DI CTIONARY Data Dictionary tables and views.
does not exist.
DICT_COLUMNS Columns in Data Dictionary tables and views.
DBA_AUDIT_RESOURCE Synonym for USER_AUDIT_RESOURCE.
DUAL Dummy table with one row and one column.
DBA_AUDIT_ TRAIL Synonym for USER_AUDIT _TRAIL.
IND Synonym for USER_INDEXES.
DBA_CATALOG AII tables, views, synonyrns, and sequences in
the database. MYPRIVS Synonym for USER_USERS.
DBA_ CLUSTERS Al! clusters in the database. OB] Synonym for USER_OB]ECTS.
DBA_CLU_COLUMNS Mapping of table columns to al! cluster columns. SEQ Synonym for USER_SEQUENCES.
DBA_ COL_ COMMENTS Comments on columns of all tables and views SYN Synonym for USER_SYNONYMS.
in the database. TABLE_PRIVILEGES Grants on objects for which the user is the
DBA_COL_GRANTS Al! grants on columns in the database. grantor, grantee, or owner, or PUBLlC is the
Constraints on all database tables. grantee.
DBA_CONSTRAINTS
AII database columns used in constraints. TABS Synonyms for USER_TABLES.
DBA_CONS_COLUMNS
Cross reference of all views, synonyms, and USER_AUDIT_ CONNECT Audit trail entries for user logons/logoffs.
DBA_CROSS_REFS
constraints in the databa se. USER_AUDIT_RESOURCE Audit trail entries for user actions that create
Database files. or drop database objects.
DBA_DA TA_FILES
Al! database links in the database. USER_AUDIT _TRAIL Audit trail entries relevant to the user.
DBA_DB_LINKS
USER_CATALOG Tables, views, synonyms, and sequences
DBA_EXP _FILES Export files.
owned by the user.
DBA_EXP _OB]ECTS Objects that have been incrementally exported.
USER_CLUSTERS Clusters owned by the user.
DBA_EXP _VERSION Version number of last export session.
USER_CLU_COLUMNS Mapping of table columns to the user's cluster
DBA_EXTENTS Extents comprising all segments in the database.
columns.
DBA_FREE_SPACE Free extents in al! tablespaces in the database.
Comments on columns of the tables and views
DBA_INDEXES Al! indexes in the databa se. owned by the user.
DBA_IND _COLUMNS Columns comprising indexes on al! tables and Grants on columns for which the user is the
clusters in the database. owner, grantor, or grantee.
DBA_OB]ECTS All objects in the database. USER_ COL_ GRANTS_MADE Grants on columns of objects owned by the user.
DBA_ROLLBACK_SEGS Rollback segments. USER_ COL_ GRANTS_RECD Grants on columns for which the user is the
DBA_SEGMENTS Storage allocated for all database segments. grantee.
DBA_SEQUENCES Al! sequences in the databa se.
USER_ CONSTRAINTS Constraints owned by the user.
USER_ CONS_ COLUMNS Columns in eonstraints owned by the user.
USER_CROSS_REFS Cross references for views, synonyms, and
eonstraints owned by the user.
USER_DB_LINKS Database links owned by the user.
USER_EXTENTS Extents eomprising segments owned by the user.
USER_FREE_SP ACE Free extents in tablespaees available to the user.
USER_INDEXES Indexes owned by the user.
USER_IND_COLUMNS Columns eomprising the user's indexes or
indexes on the user's tables or C!usters.
USER_OBJECTS Objeets owned by the liser.
USER_SEGMENTS Storage alloeated for segments owned by the
user.
USER_SEQUENCES Sequenees owned by the user.
USER_SYNONYMS The user's private synonyms.
USER_TABLES Tables owned by the user.
USER_ TABLESPACES Tablespaees available to the user.
USER_TAB_AUDIT_OPTS Auditing options for the user's tables and views.
USER_TAB_COLUMNS Columns of the user's tables, views, and C!usters.
USER_TAB_COMMENTS Comments on the user's tables and views.
USER_TAB_GRANTS Grants on objeets for which the user is the
owner, grantor, or grantee.
USER_ TAB_GRANTS_MADE Grants on objects owned by the user.
USER_ TAB_ GRANTS_RECD Grants on objeets for which the user is the
grantee.
USER_TS_QUOTAS Tablespaee quotas for the user.
USER_USERS Privileges of the eurrent user.
USER_VIEWS Views owned by the user.

You might also like