SELECT v11
Name
SELECT
-- retrieve rows from a table or view.
Synopsis
where from_item
can be one of:
Description
SELECT
retrieves rows from one or more tables. The general processing of SELECT
is as follows:
- All elements in the
FROM
list are computed. (Each element in theFROM
list is a real or virtual table.) If more than one element is specified in theFROM
list, they are cross-joined together. (SeeFROM
clause, below.) - If the
WHERE
clause is specified, all rows that do not satisfy the condition are eliminated from the output. (SeeWHERE
clause, below.) - If the
GROUP BY
clause is specified, the output is divided into groups of rows that match on one or more values. If theHAVING
clause is present, it eliminates groups that do not satisfy the given condition. (SeeGROUP BY
clause andHAVING
clause below.) - Using the operators
UNION
,INTERSECT
, andMINUS
, the output of more than oneSELECT
statement can be combined to form a single result set. TheUNION
operator returns all rows that are in one or both of the result sets. TheINTERSECT
operator returns all rows that are strictly in both result sets. TheMINUS
operator returns the rows that are in the first result set but not in the second. In all three cases, duplicate rows are eliminated. In the case of theUNION
operator, ifALL
is specified then duplicates are not eliminated. (SeeUNION
clause,INTERSECT
clause, andMINUS
clause below.) - The actual output rows are computed using the
SELECT
output expressions for each selected row. (SeeSELECT
list below.) - The
CONNECT BY
clause is used to select data that has a hierarchical relationship. Such data has a parent-child relationship between rows. (SeeCONNECT BY
clause.) - If the
ORDER BY
clause is specified, the returned rows are sorted in the specified order. IfORDER BY
is not given, the rows are returned in whatever order the system finds fastest to produce. (SeeORDER BY clause
below.) DISTINCT
eliminates duplicate rows from the result.ALL
(the default) will return all candidate rows, including duplicates. (SeeDISTINCT
clause below.)- The
FOR UPDATE
clause causes theSELECT
statement to lock the selected rows against concurrent updates. (SeeFOR UPDATE
clause below.)
You must have SELECT
privilege on a table to read its values. The use of FOR UPDATE
requires UPDATE
privilege as well.
Parameters
optimizer_hint
Comment-embedded hints to the optimizer for selection of an execution plan. See Database Compatibility for Oracle Developers Guide for information about optimizer hints.
FROM Clause
The FROM
clause specifies one or more source tables for a SELECT
statement. The syntax is: