ZZiming Zhangfetch enhance
3f731b70创建于 2024年10月26日历史提交
<refentry id="SQL-SELECT">
<refmeta>
<refentrytitle>SELECT</refentrytitle>
<manvolnum>7</manvolnum>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>SELECT</refname>
<refpurpose>retrieve rows from a table or view</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
[ WITH [ RECURSIVE ] with_query [, ...] ]
SELECT [/*+ plan_hint */] [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
    { * | {expression [ [ AS ] output_name ]} [, ...] }
    [into_option]
    [ FROM from_item [, ...] ]
    [ index_hints ]
    [ WHERE condition ]
    [ [ START WITH condition ] CONNECT BY condition [ ORDER SIBLINGS BY expression ] ]
    [ GROUP BY grouping_element [, ...] ]
    [ HAVING condition [, ...] ]
    [ WINDOW {window_name AS ( window_definition )} [, ...] ]
    [ { UNION | INTERSECT | EXCEPT | MINUS } [ ALL | DISTINCT ] select ]
    [ ORDER BY {expression [ [ ASC | DESC | USING operator ] | nlssort_expression_clause ] [ NULLS { FIRST | LAST } ]} [, ...] ]
    [ LIMIT { [offset,] count | ALL } ]
    [ OFFSET start [ ROW | ROWS ] ]
    [ FETCH { FIRST | NEXT } [ count ] [ PERCENT ] { ROW | ROWS } { ONLY | WITH TIES } ]
    [into_option]
    [ {FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | WAIT N | SKIP LOCKED]} [...] ]
    [into_option]
TABLE { ONLY { (table_name) | table_name } | table_name [ * ]};

where into_option can be:
INTO var_name [, var_name] ...
| INTO OUTFILE 'file_name'
   [CHARACTER SET charset_name]
   export_options
| INTO DUMPFILE 'file_name'
where export_options can be:
[FIELDS
	[TERMINATED BY 'string']
	[[OPTIONALLY] ENCLOSED BY 'char']
	[ESCAPED BY 'char' ]
]
[LINES
	[STARTING BY 'string']
	[TERMINATED BY 'string']
]
where from_item can be:
[ ONLY ] table_name [ * ] [ partition_clause ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
[ TABLESAMPLE sampling_method ( argument [, ...] ) [ REPEATABLE ( seed ) ] ]
[ TIMECAPSULE {TIMESTAMP | CSN} expression ]
|( select ) [ AS ] alias [ ( column_alias [, ...] ) ]
|with_query_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
|function_name ( [ argument [, ...] ] ) [ AS ] alias [ ( column_alias [, ...] | column_definition [, ...] ) ]
|function_name ( [ argument [, ...] ] ) AS ( column_definition [, ...] )
|from_item [ NATURAL ] join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ]
where grouping_element can be:
()
|expression
|( expression [, ...] )
|ROLLUP ( { expression | ( expression [, ...] ) } [, ...] )
|CUBE ( { expression | ( expression [, ...] ) } [, ...] )
|GROUPING SETS ( grouping_element [, ...] )
where with_query can be:
with_query_name [ ( column_name [, ...] ) ] AS [ [ NOT ] MATERIALIZED ] ( {select | values | insert | update | delete} )
where partition_clause can be:
PARTITION { ( partition_name ) | FOR (  partition_value [, ...] ) }
SUBPARTITION { ( subpartition_name ) | FOR (  subpartition_value [, ...] )}
where nlssort_expression_clause can be:
NLSSORT ( column_name, ' NLS_SORT = { SCHINESE_PINYIN_M | generic_m_ci } ' )
where index_hints can be:
{ FORCE | IGNORE } { INDEX | KEY } ( index_name [, ...] )
| USE { INDEX | KEY } ( [ index_name [, ...] ] )
NOTICE: [into_option] is only available in CENTRALIZED mode and B-format database.
NOTICE: [index_hints] is only available in CENTRALIZED mode and B-format database.
NOTICE: '[ [ START WITH condition ] CONNECT BY condition [ ORDER SIBLINGS BY expression ] ]' is only avaliable in CENTRALIZED mode!
NOTICE: 'SUBPARTITION { ( subpartition_name ) | FOR (  subpartition_value [, ...] )}' is only avaliable in CENTRALIZED mode!
NOTICE: expression can be @uservar := expression in CENTRALIZED mode and B-format database.
</synopsis>
</refsynopsisdiv>
</refentry>