O'Reilly logo

Oracle SQL: the Essential Reference by David C. Kreines

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SELECT
SELECT [DISTINCT | UNIQUE | ALL]
{[schema.]{table. | view. | snapshot.}* |
expr [[AS] alias][,expr [[AS] alias] ...] |
*
FROM {schema.{table[@dblink] |
            table PARTITION (partition) |
            table SUBPARTITION (subpartition) |
            table SAMPLE [BLOCK] sample_percent |
            view[@dblink] | 
            snapshot[@dblink] |
            (subquery) 
    } [table_alias]
    [,{schema.{table[@dblink] |
            table PARTITION (partition) |
            table SUBPARTITION (subpartition) |
            table SAMPLE [BLOCK] sample_percent |
            view[@dblink] | 
            snapshot[@dblink] |
            (subquery) 
} |
        }[table_alias]
        ...]
[WHERE condition]
[GROUP BY {expr[,expr ...] |
            CUBE (expr[,expr ...]) |
            ROLLUP (expr[,expr ...])
            } 
            [HAVING condition]
[[START WITH condition] CONNECT BY condition]
[{UNION [ALL] | INTERSECT | MINUS} {subquery)
 [,{UNION [ALL] | INTERSECT | MINUS} {subquery) ...]]
[ORDER BY {expr
						| position
						| alias} [ASC | DESC]
 [, {expr | position | alias} [ASC | DESC] ...]
[FOR UPDATE [OF schema.{table | view].column[,schema.{table | view].column ...]
    [NOWAIT]

Retrieves data from tables, views, or snapshots.

Keywords

DISTINCT

Specifies that only one copy of a row should be returned, even if there are duplicate rows. A duplicate row is one that returns the same values for all columns listed in the SELECT list.

ALL

Specifies that all rows should be returned, including duplicates. This option is the default.

schema

The name of the schema containing the table or view. If omitted, the current userid is assumed.

table

Specifies the name of a table.

view

Specifies the name of a view. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required