iSelfSchooling.com - Copyright © 1999-2007 iSelfSchooling.com  References  Job Openings  |  Secure Login
    Home  | Search more...  |  FREE Online VIDEO Oracle Training  |  Gift Store  |  Bookstore

   Unlimited access!   

    Oracle  Syntax  | Suggestions Your Contribution  |  FREE Legal Forms

 

Email2aFriend Homepage us! |  Bookmark   -  Copyright & User Agreement

Products/Services

 Vision/Mission

 Community Sharing

 Services

  Products

 Biography

 Contact Us

 FAQ

 Current News

 Website Traffic

 Bookstore

 FREE Training

 SQL

 PL/SQL

 Forms 

 Reports

 Other TOOLS

 Fundamentals

 Performance

 OEM

 Application Server

 Grid Control

 Articles

 Prepare for OCP

Oracle SYNTAX

 Oracle Functions

 Oracle Syntax

 Oracle 10g Syntax

  PL/SQL Syntax

UNIX and more...

 UNIX for DBAs

 LINUX for DBAs

 DB using PHP

  A+ Certification

 Basics of JAVA  

 Tips of  SEO

Finance/Jobs

 Financial Aid

 Skilled

 Oracle

 Jobs

  Magazine

More Training

 Q & Answers

 SQL-PL/SQL

 DBA

 Developer

 Important Notes

 Case Studies

 9i New Features

 10g New Features

 10g Qs/As

 Grid Control

 OracleAS # I

 OracleAS # II

  LDAP and OID

  HTTP Server

 Instructor-Led

  Virtual Hosts

 Community Sharing

More to know...

Acknowledgement**

 FREE Legal Forms

 Who is who

 Market Place

 University Directory

 Advisory Articles

 Links...

 

 

Complete Syntax  |  Oracle Functions  |  PL/SQL Syntax  |  SQL Syntax  |  Tables

 

SELECT Syntax statement

SELECT [hint][DISTINCT] select_list

   FROM table_list

   [WHERE conditions]

   [GROUP BY group_by_list]

   [HAVING search_conditions]

   [ORDER BY order_list [ASC | DESC] ]

   [FOR UPDATE for_update_options]

 

select_list
column1, column2, column3

table.column1, table.column2

table.column1 C_1_Alias, table.column2 C_2_Alias

schema.table.column1 Col_1_Alias, schema.table.column2 c_2_Alias

schema.table.*

*

expr1, expr2

 

(subquery [WITH READ ONLY | WITH CHECK OPTION [CONSTRAINT constraint]])

 

In the select_lists above, 'table' may be replaced with view or snapshot.
Using the * expression will return all columns. If a Column_Alias is specified this will appear at the top of any column headings in the query output.

 

FROM table_list
Contains a list of the tables from which the result set data is retrieved.

[schema.]{table | view | snapshot}[@dblink] [t_alias]

When selecting from a table you can also specify Partition and/or Sample clauses e.g. [schema.]table [PARTITION (partition)] [SAMPLE (sample_percent)]

 

WHERE search_conditions
A filter that defines the conditions each row in the source table(s) must meet to qualify for the SELECT. Only rows that meet the conditions will be included in the result set. The WHERE clause can also contain inner and outer join specifications (SQL1989 standard). e.g.

WHERE tableA.column = tableB.column

WHERE tableA.column = tableB.column(+)

WHERE tableA.column(+) = tableB.column

 

GROUP BY group_by_list
The GROUP BY clause partitions the result set into groups.
The group_by_list may be one or more columns or expressions and may optionally include the CUBE / ROLLUP keywords for creating crosstab results.

 

Heirarchical Queries
Any query that does *not* include a GROUP BY clause may include a CONNECT BY heirarchy clause:

[START WITH condition] CONNECT BY condition

HAVING search_conditions
An additional filter - the HAVING clause acts as an additional filter to the grouped result rows - as opposed to the WHERE clause that applies to individual rows. The HAVING clause is most commonly used in conjunction with a GROUP BY clause.

ORDER BY order_list [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
The ORDER BY clause defines the order in which the rows in the result set are sorted. order_list specifies the result set columns that make up the sort list. The ASC and DESC keywords are used to specify if the rows are sorted ascending (1...9 a...z) or descending (9...1 z...a).

You can sort by any column even if that column is not actually in the main SELECT clause. If you do not include an ORDER BY clause then the order of the result set rows will be unpredictable (random or quasi random).

FOR UPDATE options - this locks the selected rows (Oracle will normally wait for a lock unless you spacify NOWAIT)

FOR UPDATE [OF [ [schema.]{table|view}.] column] [NOWAIT]

 

Writing a SELECT statement

The clauses (SELECT ... FROM ... WHERE ... HAVING ... ORDER BY ... ) must be in this order.

 

SELECT command { UNION | UNION ALL | INTERSECT | MINUS } SELECT command ]  

 

 

 

INSERT Syntax Statement

INSERT [hint] INTO [schema.] table [@dblink] [t_alias] (column, column,...)

      VALUES (expression)

 

INSERT [hint] INTO [schema.] table

      [[SUB]PARTITION (ptn_name)] [t_alias] (column, column,...)

         VALUES (expression)

 

INSERT [hint] INTO subquery

      WITH [READ ONLY | CHECK OPTION [CONSTRAINT constraint] ]

         [t_alias] (column, column,...)

            VALUES (expression)

 

VALUES(expression) can be expanded to

 

   VALUES ([expr, expr...] [subquery])

     [RETURNING expr, expr... INTO host_variable|plsql_variable]

 

 

UPDATE Syntax Statement

UPDATE [hint] [schema.]table [@dblink] [alias]

     [ WITH {READ ONLY | CHECK OPTION [CONSTRAINT constraint]} ]

         SET col_expr(s)

           [WHERE condition]

              [ RETURNING (expr,...) INTO (data_item,...) ]

 

UPDATE [hint] [schema.]table [[SUB]PARTITION partition] [alias]

     [ WITH {READ ONLY | CHECK OPTION [CONSTRAINT constraint]} ]

         SET col_expr(s)

           [WHERE condition]

              [ RETURNING (expr,...) INTO (data_item,...) ]

 

UPDATE [hint] [schema.]view [@dblink] [alias]

     [ WITH {READ ONLY | CHECK OPTION [CONSTRAINT constraint]} ]

         SET col_expr(s) [WHERE condition]

 

UPDATE [hint] [schema.]snapshot [@dblink] [alias]

     [ WITH {READ ONLY | CHECK OPTION [CONSTRAINT constraint]} ]

         SET col_expr(s) [WHERE condition]

 

col_expr:

   column = expression

   column = (subquery)

   (column, column,...) = (subquery)

   VALUE  (table_alias) = expression

   VALUE  (table_alias) = (subquery)

 

To update multiple columns, separate col_expr with commas. The terms "snapshot" and "materialized view" are synonymous.

 

DELETE Syntax Statement

DELETE [FROM] [schema.] table [@dblink] [alias]

      WHERE (condition)

         [RETURNING expr INTO DATA_ITEM]

 

DELETE [FROM] [schema.] table [SUB]PARTITION partition [alias]

      WHERE (condition)

         [RETURNING expr INTO DATA_ITEM]

 

DELETE [FROM] [schema.] view [@dblink] [alias]

      WHERE (condition)

         [RETURNING expr INTO DATA_ITEM]

 

DELETE [FROM] subquery [WITH READ ONLY] [alias]

      WHERE (condition)

         [RETURNING expr INTO DATA_ITEM]

 

DELETE [FROM] subquery [WITH CHECK OPTION] [CONSTRAINT constraint] [alias]

      WHERE (condition)

         [RETURNING expr INTO DATA_ITEM]

 

Example:

The following example returns column es_salary from the deleted rows and stores the result in bind array :1

 

DELETE FROM employee

WHERE emp_no = 1075 AND commission = 50

RETURNING salary INTO :1;

 


ALTER DATABASE Syntax Statement

ALTER DATABASE

Open an existing database, and /or modify associated files.

ALTER DATABASE database_name options

options can be any combination of the following:

open / mount options:

   MOUNT

   MOUNT STANDBY DATABASE

   MOUNT CLONE DATABASE

   MOUNT PARALLEL

   MOUNT STANDBY DATABASE

   CONVERT

   OPEN [READ ONLY]

   OPEN [READ WRITE] RESETLOGS|NORESETLOGS

   ACTIVATE STANDBY DATABASE

   [NATIONAL] CHARACTER SET char_set

 

archivelog options:

   ARCHIVELOG

   NOARCHIVELOG

 

backup and recovery options:

   BACKUP CONTROLFILE TO 'filename' [REUSE]

   BACKUP CONTROLFILE TO TRACE

   BACKUP CONTROLFILE TO TRACE RESETLOGS

   CREATE STANDBY CONTROLFILE AS 'filename' [REUSE]

   RENAME FILE 'data_file_name' TO 'data_file_name'

   RENAME FILE 'redolog_file_name' TO 'redolog_file_name'

   RECOVER recover_clause

   DATAFILE 'filename' END BACKUP

 

Datafile options:

   CREATE DATAFILE 'filename' AS filespec

   DATAFILE 'filename' ONLINE

   DATAFILE 'filename' OFFLINE [DROP]

   DATAFILE 'filename' RESIZE int K | M

   DATAFILE 'filename' AUTOEXTEND OFF

   DATAFILE 'filename' AUTOEXTEND ON [NEXT int K | M] [MAXSIZE int K | M]

   DATAFILE 'filename' END BACKUP

   TEMPFILE 'filename' ONLINE

   TEMPFILE 'filename' OFFLINE

   TEMPFILE 'filename' DROP

   TEMPFILE 'filename' RESIZE int K | M

   TEMPFILE 'filename' AUTOEXTEND OFF

   TEMPFILE 'filename' AUTOEXTEND ON [NEXT int K | M] [MAXSIZE int K | M]

 

redo log options:

   ADD LOGFILE [THREAD int] [GROUP int] filespec

   ADD LOGFILE MEMBER 'filename' [REUSE] TO GROUP int

   ADD LOGFILE MEMBER 'filename' [REUSE] TO 'filename'

   DROP LOGFILE GROUP int

   DROP LOGFILE ('filename')

   DROP LOGFILE MEMBER 'filename'

   CLEAR [UNARCHIVED] LOGFILE GROUP int [UNRECOVERABLE DATAFILE]

   CLEAR [UNARCHIVED] LOGFILE ('filename') [UNRECOVERABLE DATAFILE]

 

Parallel server options:

   CREATE STANDBY CONTROLFILE AS 'filename' [REUSE]

   SET DBLOW = 'text'

   SET DBHIGH = 'text'

   SET DBMAC = ON | OFF

   ENABLE [PUBLIC] THREAD int

   DISABLE THREAD int

 

Backwards compatibility options:

   RENAME GLOBAL_NAME TO database [domain]

   RESET COMPATIBILITY

 

database_name is defined when the database is created - it is normally set to the same as the database SID.

Some of the commands above can only be used when the database is in a particular state:

MOUNT, CONVERT
 - Require that the db is Not Mounted.

ARCHIVELOG, NOARCHIVLOG, RECOVER - Require that the db is Mounted but not open (must be mount exclusive - not mount parallel).

ENABLE, DISABLE, RENAME GLOBAL_NAME, RESET, SET - Require that the db is Open.

All other options will work with the db mounted, open or closed as long as none of the files involved are 'in use'

 

 

ALTER RESOURCE COST Syntax Statement

ALTER RESOURCE COST option(s)

 

options are any combination of

 

   CPU_PER_SESSION int

   CONNECT_TIME int

   LOGICAL_READS_PER_SESSION int

   PRIVATE_SGA int

int is the integer weight applied to each option

The units being costed are
CPU = 1/100 sec
connect_time = 1/100 sec
SGA = bytes

 

ALTER SESSION Syntax Statement

ALTER SESSION ADVISE {COMMIT | ROLLBACK | NOTHING}

ALTER SESSION CLOSE DATABASE LINK link_name

ALTER SESSION {ENABLE | DISABLE} COMMIT IN PROCEDURE

ALTER SESSION {ENABLE | DISABLE | FORCE} PARALLEL {DML|DDL|QUERY} [PARALLEL int]

ALTER SESSION SET option(s)

 

options:

   CONSTRAINT[S] {IMMEDIATE|DEFERRED|DEFAULT}

   CREATE_STORED_OUTLINES = {TRUE | FALSE| 'category_name' }

   CURRENT_SCHEMA = schema

   CURSOR_SHARING = {FORCE | EXACT}

 

   DB_BLOCK_CHECKING = {TRUE | FALSE}

   DB_FILE_MULTIBLOCK_READ_COUNT = int

 

   FAST_START_IO_TARGET = int

   FLAGGER = {ENTRY | INTERMEDIATE | FULL | OFF}

 

   GLOBAL_NAMES = {TRUE | FALSE}

 

   HASH_AREA_SIZE = int

   HASH_JOIN_ENABLED = {TRUE | FALSE}

   HASH_MULTIBLOCK_IO_COUNT = int

 

   INSTANCE = int

   ISOLATION_LEVEL = {SERIALIZABLE | READ_COMMITTED}

 

   LABEL = {'text' | DBLOW | DBHIGH | OSLABEL}

   LOG_ARCHIVE_DEST_n (read the Oracle8i Reference for more on this)

   LOG_ARCHIVE_DEST_STATE_n = {ENABLE | DEFER}

   LOG_ARCHIVE_MIN_SUCCEED_DEST = int

 

   MAX_DUMP_FILE_SIZE = { size | UNLIMITED }

 

   NLS_CALENDAR = 'text'

   NLS_COMP = 'text'

   NLS_CURRENCY = 'text'

   NLS_DATE_FORMAT = 'fmt'

   NLS_DATE_LANGUAGE = language

   NLS_DUAL_CURRENCY = 'text'

   NLS_ISO_CURRENCY = territory

   NLS_LANGUAGE = language

   NLS_NUMERIC_CHARACTERS = 'text'

   NLS_SORT = {sort | BINARY}

   NLS_TERRITORY = territory

 

   OBJECT_CACHE_MAX_SIZE_PERCENT = int

   OBJECT_CACHE_OPTIMAL_SIZE = int

   OPTIMIZER_INDEX_CACHING = int

   OPTIMIZER_INDEX_COST_ADJ = int

   OPTIMIZER_MAX_PERMUTATIONS = int

   OPTIMIZER_MODE = {ALL_ROWS | FIRST_ROWS | RULE | CHOOSE}

   OPTIMIZER_PERCENT_PARALLEL = int

 

   PARALLEL_BROADCAST_ENABLED = {TRUE | FALSE}

   PARALLEL_INSTANCE_GROUP = ' text '

   PARALLEL_MIN_PERCENT = int

   PARTITION_VIEW_ENABLED = {TRUE | FALSE}

   PLSQL_V2_COMPATIBILITY = {TRUE | FALSE}

 

   QUERY_REWRITE_ENABLED = {TRUE | FALSE}

   QUERY_REWRITE_INTEGRITY = {enforced | trusted | stale_tolerated}

 

   REMOTE_DEPENDENCIES_MODE = {TIMESTAMP | SIGNATURE}

 

   SESSION_CACHED_CURSORS = int

   SKIP_UNUSABLE_INDEXES = {TRUE | FALSE}

   SORT_AREA_RETAINED_SIZE = int

   SORT_AREA_SIZE = integer

   SORT_MULTIBLOCK_READ_COUNT = int

   SQL_TRACE = {TRUE | FALSE}

   STAR_TRANSFORMATION_ENABLED = {TRUE | FALSE}

 

   TIMED_STATISTICS = {TRUE | FALSE}

 

   USE_STORED_OUTLINES = {TRUE | FALSE| 'category_name' }

 

 

Version 7 Options - now obsolete in v8

   CLOSE_CACHED_OPEN_CURSORS = {TRUE | FALSE}

   NLS_ISO_CURRENCY = territory

   MLS_LABEL_FORMAT = 'fmt'

   OPTIMISER_GOAL - is now OPTIMISER_MODE

   SCHEMA=schema_name

 

 

ALTER SYSTEM Syntax Statement

ALTER SYSTEM ARCHIVE LOG archive_log_clause

ALTER SYSTEM CHECKPOINT [GLOBAL | LOCAL]

ALTER SYSTEM CHECK DATAFILES [GLOBAL | LOCAL]

ALTER SYSTEM FLUSH SHARED POOL

ALTER SYSTEM SWITCH LOGFILE

ALTER SYSTEM {ENABLE | DISABLE} DISTRIBUTED RECOVERY

ALTER SYSTEM {ENABLE | DISABLE} RESTRICTED SESSION

ALTER SYSTEM {SUSPEND | RESUME}

ALTER SYSTEM SHUTDOWN [IMMEDIATE] dispatcher_name

ALTER SYSTEM KILL SESSION 'int1, int2' [POST TRANSACTION] [IMMEDIATE]

ALTER SYSTEM DISCONNECT SESSION 'int1, int2' [IMMEDIATE]

ALTER SYSTEM SET option(s)

 

options:

   AQ_TM_PROCESSES = int

 

   BACKGROUND_DUMP_DEST = 'text'

   BACKUP_TAPE_IO_SLAVES = {TRUE | FALSE} DEFERRED

 

   CONTROL_FILE_RECORD_KEEP_TIME = int

   CORE_DUMP_DEST = 'text'

   CREATE_STORED_OUTLINES = {TRUE | FALSE | 'category_name' } [NOOVERRIDE]

   CURSOR_SHARING = {force|exact}

 

   DB_BLOCK_CHECKING = {TRUE | FALSE} DEFERRED

   DB_BLOCK_CHECKSUM = {TRUE | FALSE}

   DB_BLOCK_MAX_DIRTY_TARGET = int

   DB_FILE_DIRECT_IO_COUNT = int DEFERRED

   DB_FILE_MULTIBLOCK_READ_COUNT = int

 

   FAST_START_IO_TARGET = int

   FAST_START_PARALLEL_ROLLBACK = {FALSE | LOW | HIGH}

   FIXED_DATE = { 'DD_MM_YY' | 'YYYY_MI_DD_HH24_MI-SS' }

 

   GC_DEFER_TIME = int

   GLOBAL_NAMES = {TRUE | FALSE}

 

   HASH_MULTIBLOCK_IO_COUNT = int

   HS_AUTOREGISTER = {TRUE | FALSE}

 

   JOB_QUEUE_PROCESSES = int

 

   LICENSE_MAX_SESSIONS = int

   LICENSE_MAX_USERS = int

   LICENSE_SESSIONS_WARNING = int

   LOG_ARCHIVE_DEST = string

   LOG_ARCHIVE_DEST_n = {null_string |

      {LOCATION=local_pathname | SERVICE=tnsnames_service}

          [MANDATORY | OPTIONAL] [REOPEN[=integer]]}

   LOG_ARCHIVE_DEST_STATE_n = {ENABLE | DEFER}

   LOG_ARCHIVE_DUPLEX_DEST = string

   LOG_ARCHIVE_MAX_PROCESSES = int

   LOG_ARCHIVE_MIN_SUCCEED_DEST = int

   LOG_ARCHIVE_TRACE = int

   LOG_CHECKPOINT_INTERVAL = int

   LOG_CHECKPOINT_TIMEOUT = int

 

   MAX_DUMP_FILE_SIZE = { size | 'unlimited'} [DEFERRED]

   MTS_DISPATCHERS = dispatcher_clause

   MTS_SERVERS = int

 

   OBJECT_CACHE_MAX_SIZE_PERCENT = int DEFERRED

   OBJECT_CACHE_OPTIMAL_SIZE = int DEFERRED

   OPTIMIZER_MAX_PERMUTATIONS = int NOOVERRIDE

 

   PARALLEL_ADAPTIVE_MULTI_USER  = {TRUE | FALSE}

   PARALLEL_INSTANCE_GROUP = 'text'

   PARALLEL_THREADS_PER_CPU = int

   PLSQL_V2_COMPATIBILITY = {TRUE | FALSE} [DEFERRED]

 

   QUERY_REWRITE_ENABLED = {TRUE | FALSE} [DEFERRED | NOOVERRIDE]

   QUERY_REWRITE_INTEGRITY = {ENFORCED | TRUSTED | STALE_TOLERATED}

 

   REMOTE_DEPENDENCIES_MODE = {TIMESTAMP | SIGNATURE}

   RESOURCE_LIMIT = {TRUE | FALSE}

   RESOURCE_MANAGER_PLAN = plan_name

 

   SORT_AREA_RETAINED_SIZE = int DEFERRED

   SORT_AREA_SIZE = int DEFERRED

   SORT_MULTIBLOCK_READ_COUNT = int DEFERRED

   STANDBY_ARCHIVE_DEST = string

 

   TIMED_STATISTICS = {TRUE | FALSE}

   TIMED_OS_STATISTICS = int

   TRANSACTION_AUDITING = {TRUE | FALSE} DEFERRED

 

   USE_STORED_OUTLINES = {TRUE | FALSE| 'category_name' } [NOOVERRIDE]

   USER _DUMP_DEST = 'directory_name'

 

Oracle 7 options now obsolete in v8

   CACHE_INSTANCES = int

   SCAN_INSTANCES = int

 

 

ALTER TABLE Syntax Statement

Change the properties of an existing table.

ALTER TABLE [schema.]table RENAME TO new_table_name

 

ALTER TABLE [schema.]table

      [ [NO]MINIMISE RECORDS PER BLOCK ]

          [PARALLEL parallel_clause]

             [ENABLE enable_clause | DISABLE disable_clause]

                 [{ENABLE|DISABLE} TABLE LOCK]

                    [{ENABLE|DISABLE} ALL TRIGGERS]

 

   ALTER TABLE [schema.]table

      iot_overflow_clause

          [PARALLEL parallel_clause]

             [ENABLE enable_clause | DISABLE disable_clause]

                 [{ENABLE|DISABLE} TABLE LOCK]

                    [{ENABLE|DISABLE} ALL TRIGGERS]

 

   ALTER TABLE [schema.]table

      partitioning_clause

          [PARALLEL parallel_clause]

             [ENABLE enable_clause | DISABLE disable_clause]

                 [{ENABLE|DISABLE} TABLE LOCK]

                    [{ENABLE|DISABLE} ALL TRIGGERS]

 

   ALTER TABLE [schema.]table

      tbl_defs,...

          [PARALLEL parallel_clause]

             [ENABLE enable_clause | DISABLE disable_clause]

                 [{ENABLE|DISABLE} TABLE LOCK]

                    [{ENABLE|DISABLE} ALL TRIGGERS]

 

tbl_defs:

   ADD [column datatype] [DEFAULT expr] [column_constraint(s)]

     [table_constraint] [table_ref_constraint]

 

   MODIFY [column datatype] [DEFAULT expr] [column_constraint(s)]

 

   MODIFY [table_constraint]

 

   drop_column_clause

 

   DROP drop_constraint_clause

 

   [PCTFREE int][PCTUSED int][INITTRANS int]

      [MAXTRANS int][STORAGE storage_clause]

 

   extent_options

 

   MOVE [ONLINE] storage_options INDEX index_organized_tbl_clause

      [LOB_storage_clause][varray_clause]