Updated on 2024-12-13 GMT+08:00

SELECT

Syntax

[/*+ query_rewrite_hint*/]

[ WITH [ RECURSIVE ] with_query [, ...] ]

SELECT [ ALL | DISTINCT ] select_expression [, ...]

[ FROM from_item [, ...] ]

[ WHERE condition ]

[ GROUP BY [ ALL | DISTINCT ] grouping_element [, ...] ]

[ HAVING condition]

[ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]

[ ORDER BY expression [ ASC | DESC ] [, ...] ]

[ OFFSET count [ ROW | ROWS ] ]

[ LIMIT { count | ALL } ]

[ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } { ONLY | WITH TIES } ]

  • from_item can be used in the following formats:
    • table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
    • from_item join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ]
    • table_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]

      MATCH_RECOGNIZE pattern_recognition_specification

      [ [ AS ] alias [ ( column_alias [, ...] ) ] ]

  • join_type can be used in the following formats:
    • [ INNER ] JOIN
    • LEFT [ OUTER ] JOIN
    • RIGHT [ OUTER ] JOIN
    • FULL [ OUTER ] JOIN
    • LEFT [SEMI] JOIN
    • RIGHT [SEMI] JOIN
    • LEFT [ANTI] JOIN
    • RIGHT [ANTI] JOIN
    • CROSS JOIN
  • grouping_element can be:
    • ()
    • expression
    • GROUPING SETS ( ( column [, ...] ) [, ...] )
    • CUBE ( column [, ...] )
    • ROLLUP ( column [, ...] )

Description

This statement is used to retrieve row data from zero or more tables.

Query the content of the stu table.

SELECT id,name FROM stu;