forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
139 lines
5.4 KiB
HTML
139 lines
5.4 KiB
HTML
<a name="dli_08_0378"></a><a name="dli_08_0378"></a>
|
|
|
|
<h1 class="topictitle1">Data Manipulation Language (DML)</h1>
|
|
<div id="body8662426"><div class="section" id="dli_08_0378__en-us_topic_0000001310095777_section198286378373"><h4 class="sectiontitle">DML Statements</h4><p id="dli_08_0378__en-us_topic_0000001310095777_p682774519373"><strong id="dli_08_0378__en-us_topic_0000001310095777_b1798715918373">Syntax</strong></p>
|
|
</div>
|
|
<pre class="screen" id="dli_08_0378__en-us_topic_0000001310095777_screen8417439181914">INSERT INTO table_name [PARTITION part_spec] query
|
|
|
|
part_spec: (part_col_name1=val1 [, part_col_name2=val2, ...])
|
|
|
|
query:
|
|
values
|
|
| {
|
|
select
|
|
| selectWithoutFrom
|
|
| query UNION [ ALL ] query
|
|
| query EXCEPT query
|
|
| query INTERSECT query
|
|
}
|
|
[ ORDER BY orderItem [, orderItem ]* ]
|
|
[ LIMIT { count | ALL } ]
|
|
[ OFFSET start { ROW | ROWS } ]
|
|
[ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY]
|
|
|
|
orderItem:
|
|
expression [ ASC | DESC ]
|
|
|
|
select:
|
|
SELECT [ ALL | DISTINCT ]
|
|
{ * | projectItem [, projectItem ]* }
|
|
FROM tableExpression
|
|
[ WHERE booleanExpression ]
|
|
[ GROUP BY { groupItem [, groupItem ]* } ]
|
|
[ HAVING booleanExpression ]
|
|
[ WINDOW windowName AS windowSpec [, windowName AS windowSpec ]* ]
|
|
|
|
selectWithoutFrom:
|
|
SELECT [ ALL | DISTINCT ]
|
|
{ * | projectItem [, projectItem ]* }
|
|
|
|
projectItem:
|
|
expression [ [ AS ] columnAlias ]
|
|
| tableAlias . *
|
|
|
|
tableExpression:
|
|
tableReference [, tableReference ]*
|
|
| tableExpression [ NATURAL ] [ LEFT | RIGHT | FULL ] JOIN tableExpression [ joinCondition ]
|
|
|
|
joinCondition:
|
|
ON booleanExpression
|
|
| USING '(' column [, column ]* ')'
|
|
|
|
tableReference:
|
|
tablePrimary
|
|
[ matchRecognize ]
|
|
[ [ AS ] alias [ '(' columnAlias [, columnAlias ]* ')' ] ]
|
|
|
|
tablePrimary:
|
|
[ TABLE ] [ [ catalogName . ] schemaName . ] tableName
|
|
| LATERAL TABLE '(' functionName '(' expression [, expression ]* ')' ')'
|
|
| UNNEST '(' expression ')'
|
|
|
|
values:
|
|
VALUES expression [, expression ]*
|
|
|
|
groupItem:
|
|
expression
|
|
| '(' ')'
|
|
| '(' expression [, expression ]* ')'
|
|
| CUBE '(' expression [, expression ]* ')'
|
|
| ROLLUP '(' expression [, expression ]* ')'
|
|
| GROUPING SETS '(' groupItem [, groupItem ]* ')'
|
|
|
|
windowRef:
|
|
windowName
|
|
| windowSpec
|
|
|
|
windowSpec:
|
|
[ windowName ]
|
|
'('
|
|
[ ORDER BY orderItem [, orderItem ]* ]
|
|
[ PARTITION BY expression [, expression ]* ]
|
|
[
|
|
RANGE numericOrIntervalExpression {PRECEDING}
|
|
| ROWS numericExpression {PRECEDING}
|
|
]
|
|
')'
|
|
|
|
matchRecognize:
|
|
MATCH_RECOGNIZE '('
|
|
[ PARTITION BY expression [, expression ]* ]
|
|
[ ORDER BY orderItem [, orderItem ]* ]
|
|
[ MEASURES measureColumn [, measureColumn ]* ]
|
|
[ ONE ROW PER MATCH ]
|
|
[ AFTER MATCH
|
|
( SKIP TO NEXT ROW
|
|
| SKIP PAST LAST ROW
|
|
| SKIP TO FIRST variable
|
|
| SKIP TO LAST variable
|
|
| SKIP TO variable )
|
|
]
|
|
PATTERN '(' pattern ')'
|
|
[ WITHIN intervalLiteral ]
|
|
DEFINE variable AS condition [, variable AS condition ]*
|
|
')'
|
|
|
|
measureColumn:
|
|
expression AS alias
|
|
|
|
pattern:
|
|
patternTerm [ '|' patternTerm ]*
|
|
|
|
patternTerm:
|
|
patternFactor [ patternFactor ]*
|
|
|
|
patternFactor:
|
|
variable [ patternQuantifier ]
|
|
|
|
patternQuantifier:
|
|
'*'
|
|
| '*?'
|
|
| '+'
|
|
| '+?'
|
|
| '?'
|
|
| '??'
|
|
| '{' { [ minRepeat ], [ maxRepeat ] } '}' ['?']
|
|
| '{' repeat '}'</pre>
|
|
<p id="dli_08_0378__en-us_topic_0000001310095777_p17596813133818"><strong id="dli_08_0378__en-us_topic_0000001310095777_b630912513384">Precautions</strong></p>
|
|
<p id="dli_08_0378__en-us_topic_0000001310095777_p1785417476386">Flink SQL uses a lexical policy for identifier (table, attribute, function names) similar to Java:</p>
|
|
<ul id="dli_08_0378__en-us_topic_0000001310095777_ul526635473814"><li id="dli_08_0378__en-us_topic_0000001310095777_li1226635433817">The case of identifiers is preserved whether they are quoted.</li><li id="dli_08_0378__en-us_topic_0000001310095777_li21423582389">Identifiers are matched case-sensitively.</li><li id="dli_08_0378__en-us_topic_0000001310095777_li1382812017396">Unlike Java, back-ticks allow identifiers to contain non-alphanumeric characters (for example, <strong id="dli_08_0378__en-us_topic_0000001310095777_b195468028345014">SELECT a AS `my field` FROM t</strong>).</li></ul>
|
|
<p id="dli_08_0378__en-us_topic_0000001310095777_p185404783816">String literals must be enclosed in single quotes (for example, <strong id="dli_08_0378__en-us_topic_0000001310095777_b66981561745014">SELECT'Hello World'</strong>). Duplicate a single quote for escaping (for example, <strong id="dli_08_0378__en-us_topic_0000001310095777_b51068505845014">SELECT 'It''s me.'</strong>). Unicode characters are supported in string literals. If explicit Unicode points are required, use the following syntax:</p>
|
|
<ul id="dli_08_0378__en-us_topic_0000001310095777_ul163671415193916"><li id="dli_08_0378__en-us_topic_0000001310095777_li336717159398">Use the backslash (\) as an escaping character (default): <strong id="dli_08_0378__en-us_topic_0000001310095777_b132763683245014">SELECT U&'\263A'</strong></li><li id="dli_08_0378__en-us_topic_0000001310095777_li191670189390">Use a custom escaping character: <strong id="dli_08_0378__en-us_topic_0000001310095777_b142504216945014">SELECT U&'#263A' UESCAPE '#'</strong></li></ul>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0373.html">Syntax</a></div>
|
|
</div>
|
|
</div>
|
|
|