Supported SQL Syntax

The EBNF and Railroad Diagrams for the supported SQL Syntax. Kindly provided by Gunther Rademacher.

Statement

IF Condition SingleStatement Block ST_SEMICOLON ELSE SingleStatement Block ST_SEMICOLON EOF UnsupportedStatement
         ::= ( 'IF' Condition ( ( SingleStatement | Block ) ST_SEMICOLON? 'ELSE' )? )? ( SingleStatement | Block ) ST_SEMICOLON? EOF
           | UnsupportedStatement

SingleStatement

WithList SelectWithWithItems Insert Update Delete Merge Select TableStatement Upsert Alter RenameTableStatement Create Drop Analyze Truncate Execute Set Reset Show RefreshMaterializedView Use SavepointStatement RollbackStatement COMMIT Comment Describe Explain Declare Grant PurgeStatement
         ::= WithList? ( SelectWithWithItems | Insert | Update | Delete | Merge )
           | Select
           | TableStatement
           | Upsert
           | Alter
           | RenameTableStatement
           | Create
           | Drop
           | Analyze
           | Truncate
           | Execute
           | Set
           | Reset
           | Show
           | RefreshMaterializedView
           | Use
           | SavepointStatement
           | RollbackStatement
           | 'COMMIT'
           | Comment
           | Describe
           | Explain
           | Declare
           | Grant
           | PurgeStatement

Block

BEGIN ST_SEMICOLON SingleStatement Block ST_SEMICOLON END ST_SEMICOLON
Block    ::= 'BEGIN' ST_SEMICOLON* ( ( SingleStatement | Block ) ST_SEMICOLON )+ 'END' ST_SEMICOLON?

Statements

ST_SEMICOLON IF Condition SingleStatement Block ST_SEMICOLON ELSE SingleStatement Block SingleStatement Block ST_SEMICOLON UnsupportedStatement ST_SEMICOLON IF Condition SingleStatement Block ST_SEMICOLON ELSE SingleStatement Block SingleStatement Block ST_SEMICOLON UnsupportedStatement EOF

Declare

DECLARE UserVariable TABLE ( ColumnDefinition , ) AS RelObjectName ColDataType = Expression UserVariable ,
Declare  ::= 'DECLARE' UserVariable ( 'TABLE' '(' ColumnDefinition ( ',' ColumnDefinition )* ')' | 'AS' RelObjectName | ColDataType ( '=' Expression )? ( ',' UserVariable ColDataType ( '=' Expression )? )* )

Set

SET LOCAL SESSION K_DATETIMELITERAL ZONE UserVariable IdentifierChain = Expression ZONE K_DATETIMELITERAL = RelObjectNameExt ,
Set      ::= 'SET' ( 'LOCAL' | 'SESSION' )? ( K_DATETIMELITERAL 'ZONE' | ( UserVariable | IdentifierChain ) '='? ) Expression ( ',' ( K_DATETIMELITERAL 'ZONE' | RelObjectNameExt '='? )? Expression )*

Reset

RESET K_DATETIMELITERAL ZONE RelObjectName ALL
Reset    ::= 'RESET' ( K_DATETIMELITERAL 'ZONE' | RelObjectName | 'ALL' )

RenameTableStatement

RENAME TABLE IF EXISTS Table WAIT S_LONG NOWAIT TO Table Table ,
         ::= 'RENAME' 'TABLE'? ( 'IF' 'EXISTS' )? Table ( 'WAIT' S_LONG | 'NOWAIT' )? 'TO' Table ( ',' Table 'TO' Table )*

PurgeStatement

PURGE TABLE Table INDEX Index RECYCLEBIN DBA_RECYCLEBIN TABLESPACE S_IDENTIFIER USER S_IDENTIFIER
         ::= 'PURGE' ( 'TABLE' Table | 'INDEX' Index | 'RECYCLEBIN' | 'DBA_RECYCLEBIN' | 'TABLESPACE' S_IDENTIFIER ( 'USER' S_IDENTIFIER )? )

Describe

DESCRIBE DESC Table
Describe ::= ( 'DESCRIBE' | 'DESC' ) Table

Explain

EXPLAIN ExplainStatementOptions Select Table

ExplainOptionBoolean

TRUE FALSE ON OFF
         ::= ( 'TRUE' | 'FALSE' | 'ON' | 'OFF' )?

ExplainFormatOption

XML JSON YAML
         ::= ( 'XML' | 'JSON' | 'YAML' )?

ExplainStatementOptions

ANALYZE BUFFERS COSTS VERBOSE ExplainOptionBoolean FORMAT ExplainFormatOption
         ::= ( ( 'ANALYZE' | 'BUFFERS' | 'COSTS' | 'VERBOSE' ) ExplainOptionBoolean | 'FORMAT' ExplainFormatOption )*

Use

USE SCHEMA RelObjectNameExt
Use      ::= 'USE' 'SCHEMA'? RelObjectNameExt

Show

SHOW ShowColumns ShowIndex ShowTables captureRest
Show     ::= 'SHOW' ( ShowColumns | ShowIndex | ShowTables | captureRest )

ShowColumns

COLUMNS FROM RelObjectNameExt
         ::= 'COLUMNS' 'FROM' RelObjectNameExt

ShowIndex

INDEX FROM RelObjectNameExt
         ::= 'INDEX' 'FROM' RelObjectNameExt

RefreshMaterializedView

REFRESH MATERIALIZED VIEW CONCURRENTLY Table WITH NO DATA captureRest
         ::= 'REFRESH' 'MATERIALIZED' 'VIEW' 'CONCURRENTLY'? Table ( 'WITH' 'NO'? 'DATA' )? captureRest

ShowTables

EXTENDED FULL TABLES FROM IN RelObjectNameExt LIKE SimpleExpression WHERE Expression
         ::= 'EXTENDED'? 'FULL'? 'TABLES' ( ( 'FROM' | 'IN' ) RelObjectNameExt )? ( 'LIKE' SimpleExpression | 'WHERE' Expression )?

Values

VALUES VALUE ExpressionList
Values   ::= ( 'VALUES' | 'VALUE' ) ExpressionList

ReturningClause

RETURNING RETURN SelectItemsList INTO Table UserVariable ,
         ::= ( 'RETURNING' | 'RETURN' ) SelectItemsList ( 'INTO' ( Table | UserVariable ) ( ',' ( Table | UserVariable ) )* )?

Update

UPDATE LOW_PRIORITY IGNORE TableWithAliasAndMysqlIndexHint JoinsList SET UpdateSets OutputClause FROM FromItem JoinsList WhereClause OrderByElements PlainLimit ReturningClause

UpdateSets

Column = Expression ParenthesedExpressionList = ParenthesedSelect ParenthesedExpressionList , Column = Expression ParenthesedExpressionList = ParenthesedSelect ParenthesedExpressionList

Insert

INSERT LOW_PRIORITY DELAYED HIGH_PRIORITY IGNORE INTO Table AS RelObjectNameWithoutValue ( ColumnList ) OutputClause SET UpdateSets Select ON DUPLICATE KEY UPDATE UpdateSets ON CONFLICT InsertConflictTarget InsertConflictAction ReturningClause
Insert   ::= 'INSERT' ( 'LOW_PRIORITY' | 'DELAYED' | 'HIGH_PRIORITY' )? 'IGNORE'? 'INTO'? Table ( 'AS'? RelObjectNameWithoutValue )? ( '(' ColumnList ')' )? OutputClause? ( 'SET' UpdateSets | Select ) ( 'ON' 'DUPLICATE' 'KEY' 'UPDATE' UpdateSets )? ( 'ON' 'CONFLICT' InsertConflictTarget? InsertConflictAction )? ReturningClause?

InsertConflictTarget

( RelObjectNameExt2 , ) WhereClause ON CONSTRAINT RelObjectNameExt2
         ::= '(' RelObjectNameExt2 ( ',' RelObjectNameExt2 )* ')' WhereClause?
           | 'ON' 'CONSTRAINT' RelObjectNameExt2

InsertConflictAction

DO NOTHING UPDATE SET UpdateSets WhereClause
         ::= 'DO' ( 'NOTHING' | 'UPDATE' 'SET' UpdateSets WhereClause? )

OutputClause

OUTPUT SelectItemsList INTO UserVariable Table ColumnsNamesList
         ::= 'OUTPUT' SelectItemsList ( 'INTO' ( UserVariable | Table ) ColumnsNamesList? )?

Upsert

UPSERT INSERT OR REPLACE INTO Table ParenthesedColumnList SET UpdateSets Select ON DUPLICATE KEY UPDATE UpdateSets
Upsert   ::= ( 'UPSERT' | ( 'INSERT' 'OR' )? 'REPLACE' ) 'INTO'? Table ParenthesedColumnList? ( 'SET' UpdateSets | Select ) ( 'ON' 'DUPLICATE' 'KEY' 'UPDATE' UpdateSets )?

Delete

DELETE LOW_PRIORITY QUICK IGNORE TableWithAlias , OutputClause FROM TableWithAlias JoinsList USING TableWithAlias , WhereClause OrderByElements PlainLimit ReturningClause
Delete   ::= 'DELETE' 'LOW_PRIORITY'? 'QUICK'? 'IGNORE'? ( ( TableWithAlias ( ',' TableWithAlias )* OutputClause? )? 'FROM' )? ( TableWithAlias JoinsList? )? ( 'USING' TableWithAlias ( ',' TableWithAlias )* )? WhereClause? OrderByElements? PlainLimit? ReturningClause?

Merge

MERGE INTO TableWithAlias USING FromItem ON Expression MergeOperations OutputClause
Merge    ::= 'MERGE' 'INTO' TableWithAlias 'USING' FromItem 'ON' Expression MergeOperations OutputClause?

MergeOperations

MergeWhenMatched MergeWhenNotMatched
         ::= ( MergeWhenMatched | MergeWhenNotMatched )*

MergeWhenMatched

WHEN MATCHED AND Expression THEN DELETE MergeUpdateClause
         ::= 'WHEN' 'MATCHED' ( 'AND' Expression )? 'THEN' ( 'DELETE' | MergeUpdateClause )

MergeUpdateClause

UPDATE SET UpdateSets WHERE Expression DELETE WHERE Expression
         ::= 'UPDATE' 'SET' UpdateSets ( 'WHERE' Expression )? ( 'DELETE' 'WHERE' Expression )?

MergeWhenNotMatched

WHEN NOT MATCHED AND Expression THEN INSERT ( ColumnList ) VALUES ( SimpleExpressionList ) WHERE Expression
         ::= 'WHEN' 'NOT' 'MATCHED' ( 'AND' Expression )? 'THEN' 'INSERT' ( '(' ColumnList ')' )? 'VALUES' '(' SimpleExpressionList ')' ( 'WHERE' Expression )?

RelObjectNameList

RelObjectNameExt . : . RelObjectNameExt2
         ::= RelObjectNameExt ( ( '.' | ':' ) '.'* RelObjectNameExt2 )*

Column

RelObjectNameList COMMENT S_CHAR_LITERAL . K_NEXTVAL ArrayConstructor

RelObjectNameWithoutValue

DATA_TYPE S_IDENTIFIER S_QUOTED_IDENTIFIER K_DATE_LITERAL K_DATETIMELITERAL K_STRING_FUNCTION_NAME K_ISOLATION K_TIME_KEY_EXPR ACTION ACTIVE ADD ADVANCE ADVISE AGAINST ALGORITHM ALTER ANALYZE APPLY ARCHIVE ARRAY ASC AT AUTHORIZATION AUTO BEGIN BERNOULLI BINARY BIT BLOCK BROWSE BUFFERS BY BYTE BYTES CACHE CALL CASCADE CASE CAST CHANGE CHANGES CHAR CHARACTER CHECKPOINT CLOSE COLLATE COLUMN COLUMNS COMMENT COMMIT CONCURRENTLY CONFLICT CONSTRAINTS CONVERT COSTS CS CYCLE DATA DATABASE DATETIME DDL DECLARE DEFAULT DEFERRABLE DELAYED DELETE DESC DESCRIBE DISABLE DISCONNECT DIV DML DO DOMAIN DROP DUMP DUPLICATE ELEMENTS EMIT ENABLE END ESCAPE EXCLUDE EXEC EXECUTE EXPLAIN EXPLICIT EXTENDED EXTRACT FALSE FILTER FIRST FLUSH FN FOLLOWING FORMAT FULLTEXT FUNCTION GRANT GUARD HASH HISTORY HOPPING INCLUDE INCREMENT INDEX INSERT INTERLEAVE INTERPRET INVALIDATE ISNULL JSON KEEP KEY KEYS LAST LEADING LINK LOCAL LOCKED LOG LOOP MATCH MATCHED MATERIALIZED MAX MAXVALUE MEMBER MERGE MIN MINVALUE MODIFY MOVEMENT NEXT NO NOCACHE NOKEEP NOLOCK NOMAXVALUE NOMINVALUE NOORDER NOTHING NOTNULL NOVALIDATE NOWAIT NULLS OF OFF OPEN OVER OVERLAPS PARALLEL PARENT PARTITION PATH PERCENT PLACING PRECEDING PRECISION PRIMARY PRIOR PURGE QUERY QUICK QUIESCE RANGE RAW READ RECURSIVE RECYCLEBIN REFERENCES REFRESH REGEXP REGISTER REMOTE RENAME REPEATABLE REPLACE RESET RESPECT RESTART RESTRICT RESTRICTED RESUMABLE RESUME RETURN RLIKE ROLLBACK ROLLUP ROOT ROW ROWS RR RS SAVEPOINT SCHEMA SECURE SEED SEPARATOR SEQUENCE SESSION SETS SHARE SHOW SHUTDOWN SIBLINGS SIGNED SIMILAR SIZE SKIP STORED STRING STRUCT SUSPEND SWITCH SYNONYM SYSTEM TABLE TABLESPACE TEMP TEMPORARY THEN TIMEOUT TIMESTAMPTZ TIMEZONE TO TRIGGER TRUE TRUNCATE TUMBLING TYPE UNLOGGED UNQIESCE UNSIGNED UPDATE UPSERT UR USER VALIDATE VERBOSE VIEW VOLATILE WAIT WITHIN WITHOUT WORK XML XMLAGG XMLDATA XMLSCHEMA XMLTEXT XSINIL YAML YES ZONE
         ::= DATA_TYPE
           | S_IDENTIFIER
           | S_QUOTED_IDENTIFIER
           | K_DATE_LITERAL
           | K_DATETIMELITERAL
           | K_STRING_FUNCTION_NAME
           | K_ISOLATION
           | K_TIME_KEY_EXPR
           | 'ACTION'
           | 'ACTIVE'
           | 'ADD'
           | 'ADVANCE'
           | 'ADVISE'
           | 'AGAINST'
           | 'ALGORITHM'
           | 'ALTER'
           | 'ANALYZE'
           | 'APPLY'
           | 'ARCHIVE'
           | 'ARRAY'
           | 'ASC'
           | 'AT'
           | 'AUTHORIZATION'
           | 'AUTO'
           | 'BEGIN'
           | 'BERNOULLI'
           | 'BINARY'
           | 'BIT'
           | 'BLOCK'
           | 'BROWSE'
           | 'BUFFERS'
           | 'BY'
           | 'BYTE'
           | 'BYTES'
           | 'CACHE'
           | 'CALL'
           | 'CASCADE'
           | 'CASE'
           | 'CAST'
           | 'CHANGE'
           | 'CHANGES'
           | 'CHAR'
           | 'CHARACTER'
           | 'CHECKPOINT'
           | 'CLOSE'
           | 'COLLATE'
           | 'COLUMN'
           | 'COLUMNS'
           | 'COMMENT'
           | 'COMMIT'
           | 'CONCURRENTLY'
           | 'CONFLICT'
           | 'CONSTRAINTS'
           | 'CONVERT'
           | 'COSTS'
           | 'CS'
           | 'CYCLE'
           | 'DATA'
           | 'DATABASE'
           | 'DATETIME'
           | 'DDL'
           | 'DECLARE'
           | 'DEFAULT'
           | 'DEFERRABLE'
           | 'DELAYED'
           | 'DELETE'
           | 'DESC'
           | 'DESCRIBE'
           | 'DISABLE'
           | 'DISCONNECT'
           | 'DIV'
           | 'DML'
           | 'DO'
           | 'DOMAIN'
           | 'DROP'
           | 'DUMP'
           | 'DUPLICATE'
           | 'ELEMENTS'
           | 'EMIT'
           | 'ENABLE'
           | 'END'
           | 'ESCAPE'
           | 'EXCLUDE'
           | 'EXEC'
           | 'EXECUTE'
           | 'EXPLAIN'
           | 'EXPLICIT'
           | 'EXTENDED'
           | 'EXTRACT'
           | 'FALSE'
           | 'FILTER'
           | 'FIRST'
           | 'FLUSH'
           | 'FN'
           | 'FOLLOWING'
           | 'FORMAT'
           | 'FULLTEXT'
           | 'FUNCTION'
           | 'GRANT'
           | 'GUARD'
           | 'HASH'
           | 'HISTORY'
           | 'HOPPING'
           | 'INCLUDE'
           | 'INCREMENT'
           | 'INDEX'
           | 'INSERT'
           | 'INTERLEAVE'
           | 'INTERPRET'
           | 'INVALIDATE'
           | 'ISNULL'
           | 'JSON'
           | 'KEEP'
           | 'KEY'
           | 'KEYS'
           | 'LAST'
           | 'LEADING'
           | 'LINK'
           | 'LOCAL'
           | 'LOCKED'
           | 'LOG'
           | 'LOOP'
           | 'MATCH'
           | 'MATCHED'
           | 'MATERIALIZED'
           | 'MAX'
           | 'MAXVALUE'
           | 'MEMBER'
           | 'MERGE'
           | 'MIN'
           | 'MINVALUE'
           | 'MODIFY'
           | 'MOVEMENT'
           | 'NEXT'
           | 'NO'
           | 'NOCACHE'
           | 'NOKEEP'
           | 'NOLOCK'
           | 'NOMAXVALUE'
           | 'NOMINVALUE'
           | 'NOORDER'
           | 'NOTHING'
           | 'NOTNULL'
           | 'NOVALIDATE'
           | 'NOWAIT'
           | 'NULLS'
           | 'OF'
           | 'OFF'
           | 'OPEN'
           | 'OVER'
           | 'OVERLAPS'
           | 'PARALLEL'
           | 'PARENT'
           | 'PARTITION'
           | 'PATH'
           | 'PERCENT'
           | 'PLACING'
           | 'PRECEDING'
           | 'PRECISION'
           | 'PRIMARY'
           | 'PRIOR'
           | 'PURGE'
           | 'QUERY'
           | 'QUICK'
           | 'QUIESCE'
           | 'RANGE'
           | 'RAW'
           | 'READ'
           | 'RECURSIVE'
           | 'RECYCLEBIN'
           | 'REFERENCES'
           | 'REFRESH'
           | 'REGEXP'
           | 'REGISTER'
           | 'REMOTE'
           | 'RENAME'
           | 'REPEATABLE'
           | 'REPLACE'
           | 'RESET'
           | 'RESPECT'
           | 'RESTART'
           | 'RESTRICT'
           | 'RESTRICTED'
           | 'RESUMABLE'
           | 'RESUME'
           | 'RETURN'
           | 'RLIKE'
           | 'ROLLBACK'
           | 'ROLLUP'
           | 'ROOT'
           | 'ROW'
           | 'ROWS'
           | 'RR'
           | 'RS'
           | 'SAVEPOINT'
           | 'SCHEMA'
           | 'SECURE'
           | 'SEED'
           | 'SEPARATOR'
           | 'SEQUENCE'
           | 'SESSION'
           | 'SETS'
           | 'SHARE'
           | 'SHOW'
           | 'SHUTDOWN'
           | 'SIBLINGS'
           | 'SIGNED'
           | 'SIMILAR'
           | 'SIZE'
           | 'SKIP'
           | 'STORED'
           | 'STRING'
           | 'STRUCT'
           | 'SUSPEND'
           | 'SWITCH'
           | 'SYNONYM'
           | 'SYSTEM'
           | 'TABLE'
           | 'TABLESPACE'
           | 'TEMP'
           | 'TEMPORARY'
           | 'THEN'
           | 'TIMEOUT'
           | 'TIMESTAMPTZ'
           | 'TIMEZONE'
           | 'TO'
           | 'TRIGGER'
           | 'TRUE'
           | 'TRUNCATE'
           | 'TUMBLING'
           | 'TYPE'
           | 'UNLOGGED'
           | 'UNQIESCE'
           | 'UNSIGNED'
           | 'UPDATE'
           | 'UPSERT'
           | 'UR'
           | 'USER'
           | 'VALIDATE'
           | 'VERBOSE'
           | 'VIEW'
           | 'VOLATILE'
           | 'WAIT'
           | 'WITHIN'
           | 'WITHOUT'
           | 'WORK'
           | 'XML'
           | 'XMLAGG'
           | 'XMLDATA'
           | 'XMLSCHEMA'
           | 'XMLTEXT'
           | 'XSINIL'
           | 'YAML'
           | 'YES'
           | 'ZONE'

RelObjectName

RelObjectNameWithoutValue GROUP INTERVAL ON START TOP VALUE VALUES CREATE TABLES CONNECT IGNORE QUALIFY
         ::= RelObjectNameWithoutValue
           | 'GROUP'
           | 'INTERVAL'
           | 'ON'
           | 'START'
           | 'TOP'
           | 'VALUE'
           | 'VALUES'
           | 'CREATE'
           | 'TABLES'
           | 'CONNECT'
           | 'IGNORE'
           | 'QUALIFY'

RelObjectNameWithoutStart

RelObjectNameWithoutValue TOP VALUE VALUES INTERVAL
         ::= RelObjectNameWithoutValue
           | 'TOP'
           | 'VALUE'
           | 'VALUES'
           | 'INTERVAL'

RelObjectNameExt

RelObjectName ALL ANY SOME LEFT RIGHT SET IF IIF OPTIMIZE LIMIT OFFSET PROCEDURE PUBLIC CASEWHEN IN GROUPING ORDER K_NEXTVAL GLOBAL
         ::= RelObjectName
           | 'ALL'
           | 'ANY'
           | 'SOME'
           | 'LEFT'
           | 'RIGHT'
           | 'SET'
           | 'IF'
           | 'IIF'
           | 'OPTIMIZE'
           | 'LIMIT'
           | 'OFFSET'
           | 'PROCEDURE'
           | 'PUBLIC'
           | 'CASEWHEN'
           | 'IN'
           | 'GROUPING'
           | 'ORDER'
           | K_NEXTVAL
           | 'GLOBAL'

RelObjectNameExt2

RelObjectNameExt FROM K_SELECT CURRENT
         ::= RelObjectNameExt
           | 'FROM'
           | K_SELECT
           | 'CURRENT'

Table

RelObjectNameList

TableWithAlias

Table Alias
         ::= Table Alias?

TableWithAliasAndMysqlIndexHint

Table Alias MySQLIndexHint
         ::= Table Alias? MySQLIndexHint?

Number

S_DOUBLE S_LONG
Number   ::= S_DOUBLE
           | S_LONG

SampleClause

SAMPLE BLOCK TABLESAMPLE SYSTEM BERNOULLI ( Number ) REPEATABLE ( Number ) SEED ( Number )
         ::= ( 'SAMPLE' 'BLOCK'? | 'TABLESAMPLE' ( 'SYSTEM' | 'BERNOULLI' ) ) '(' Number ')' ( 'REPEATABLE' '(' Number ')' )? ( 'SEED' '(' Number ')' )?

SelectWithWithItems

Select
         ::= Select

Select

WithList PlainSelect Values ParenthesedSelect SetOperationList OrderByElements LimitWithOffset Offset Fetch WithIsolation

TableStatement

TABLE Table OrderByElements LimitWithOffset Offset
         ::= 'TABLE' Table OrderByElements? LimitWithOffset? Offset?

ParenthesedSelect

( Select )
         ::= '(' Select ')'

LateralView

LATERAL VIEW OUTER Function RelObjectNameWithoutStart AS RelObjectNameWithoutStart
         ::= 'LATERAL' 'VIEW' 'OUTER'? Function RelObjectNameWithoutStart? 'AS' RelObjectNameWithoutStart

ForClause

FOR BROWSE XML RAW ( S_CHAR_LITERAL ) AUTO , BINARY BASE64 TYPE ROOT XMLSCHEMA ( S_CHAR_LITERAL ) XMLDATA ELEMENTS XSINIL ABSENT EXPLICIT , BINARY BASE64 TYPE ROOT ( S_CHAR_LITERAL ) XMLDATA PATH ( S_CHAR_LITERAL ) , BINARY BASE64 TYPE ROOT ( S_CHAR_LITERAL ) ELEMENTS XSINIL ABSENT JSON AUTO PATH , ROOT ( S_CHAR_LITERAL ) INCLUDE_NULL_VALUES WITHOUT_ARRAY_WRAPPER
         ::= 'FOR' ( 'BROWSE' | 'XML' ( ( 'RAW' ( '(' S_CHAR_LITERAL ')' )? | 'AUTO' ) ( ',' ( 'BINARY' 'BASE64' | 'TYPE' | ( 'ROOT' | 'XMLSCHEMA' ) ( '(' S_CHAR_LITERAL ')' )? | 'XMLDATA' | 'ELEMENTS' ( 'XSINIL' | 'ABSENT' )? ) )* | 'EXPLICIT' ( ',' ( 'BINARY' 'BASE64' | 'TYPE' | 'ROOT' ( '(' S_CHAR_LITERAL ')' )? | 'XMLDATA' ) )* | 'PATH' ( '(' S_CHAR_LITERAL ')' )? ( ',' ( 'BINARY' 'BASE64' | 'TYPE' | 'ROOT' ( '(' S_CHAR_LITERAL ')' )? | 'ELEMENTS' ( 'XSINIL' | 'ABSENT' )? ) )* ) | 'JSON' ( 'AUTO' | 'PATH' ) ( ',' ( 'ROOT' ( '(' S_CHAR_LITERAL ')' )? | 'INCLUDE_NULL_VALUES' | 'WITHOUT_ARRAY_WRAPPER' ) )* )

LateralViews

LateralView
         ::= LateralView+

LateralSubSelect

LATERAL ( Select )
         ::= 'LATERAL' '(' Select ')'

PlainSelect

K_SELECT STRAIGHT_JOIN Skip First ALL DISTINCT ON ( SelectItemsList ) UNIQUE SQL_CALC_FOUND_ROWS SQL_NO_CACHE SQL_CACHE Top SelectItemsList IntoClause FROM FromItem LateralViews JoinsList FROM ONLY FromItem LateralViews JoinsList FINAL KSQLWindowClause WhereClause OracleHierarchicalQueryClause Having GroupByColumnReferences Having Qualify ForClause OrderByElements WINDOW RelObjectName AS windowDefinition , OrderByElements EMIT CHANGES LimitBy LimitWithOffset Offset LimitWithOffset Fetch WithIsolation FOR NO KEY UPDATE KEY SHARE OF Table Wait NOWAIT SKIP LOCKED OptimizeFor INTO TEMP Table WITH NO LOG
         ::= K_SELECT 'STRAIGHT_JOIN'? Skip? First? ( 'ALL' | 'DISTINCT' ( 'ON' '(' SelectItemsList ')' )? | 'UNIQUE' | 'SQL_CALC_FOUND_ROWS' | 'SQL_NO_CACHE' | 'SQL_CACHE' )? Top? SelectItemsList IntoClause? ( 'FROM' FromItem LateralViews? JoinsList? )? ( 'FROM' 'ONLY' FromItem LateralViews? JoinsList? )? 'FINAL'? KSQLWindowClause? WhereClause? OracleHierarchicalQueryClause? Having? GroupByColumnReferences? Having? Qualify? ForClause? OrderByElements? ( 'WINDOW' RelObjectName 'AS' windowDefinition ( ',' RelObjectName 'AS' windowDefinition )* )? OrderByElements? ( 'EMIT' 'CHANGES' )? LimitBy? LimitWithOffset? Offset? LimitWithOffset? Fetch? WithIsolation? ( 'FOR' ( ( 'NO' 'KEY' )? 'UPDATE' | 'KEY'? 'SHARE' ) ( 'OF' Table )? Wait? ( 'NOWAIT' | 'SKIP' 'LOCKED' )? )? OptimizeFor? ( 'INTO' 'TEMP' Table )? ( 'WITH' 'NO' 'LOG' )?

SetOperationList

UNION ALL DISTINCT INTERSECT MINUS EXCEPT PlainSelect Values ParenthesedSelect OrderByElements LimitWithOffset Offset LimitWithOffset Fetch WithIsolation
         ::= ( ( 'UNION' ( 'ALL' | 'DISTINCT' )? | 'INTERSECT' | 'MINUS' | 'EXCEPT' ) ( PlainSelect | Values | ParenthesedSelect ) )+ OrderByElements? LimitWithOffset? Offset? LimitWithOffset? Fetch? WithIsolation?

WithList

WITH WithItem ,
WithList ::= 'WITH' WithItem ( ',' WithItem )*

WithItem

RECURSIVE RelObjectName ( SelectItemsList ) AS ParenthesedSelect
WithItem ::= 'RECURSIVE'? RelObjectName ( '(' SelectItemsList ')' )? 'AS' ParenthesedSelect

SelectItemsList

SelectItem ,
         ::= SelectItem ( ',' SelectItem )*

SelectItem

AllColumns AllTableColumns XorExpression ConcatExpression Expression Alias

AllColumns

* EXCEPT ParenthesedColumnList REPLACE ( SelectItemsList )
         ::= '*' ( 'EXCEPT' ParenthesedColumnList )? ( 'REPLACE' '(' SelectItemsList ')' )?

AllTableColumns

Table . AllColumns
         ::= Table '.' AllColumns

Alias

AS RelObjectNameWithoutStart ( RelObjectName ColDataType , ) AS RelObjectNameWithoutStart S_CHAR_LITERAL
           | 'AS'? ( RelObjectNameWithoutStart | S_CHAR_LITERAL )

SQLServerHint

INDEX ( RelObjectName ) NOLOCK
         ::= 'INDEX' '(' RelObjectName ')'
           | 'NOLOCK'

SQLServerHints

WITH ( SQLServerHint , )
         ::= 'WITH' '(' SQLServerHint ( ',' SQLServerHint )* ')'

MySQLIndexHint

USE SHOW IGNORE FORCE INDEX KEY ( RelObjectNameWithoutValue , )
         ::= ( 'USE' | 'SHOW' | 'IGNORE' | 'FORCE' ) ( 'INDEX' | 'KEY' ) '(' RelObjectNameWithoutValue ( ',' RelObjectNameWithoutValue )* ')'

FunctionItem

Function Alias
         ::= Function Alias?

PivotForColumns

ParenthesedColumnList Column
         ::= ParenthesedColumnList
           | Column

PivotFunctionItems

FunctionItem ,
         ::= FunctionItem ( ',' FunctionItem )*

ExpressionListItem

ParenthesedExpressionList Alias
         ::= ParenthesedExpressionList Alias?

PivotMultiInItems

ExpressionListItem ,
         ::= ExpressionListItem ( ',' ExpressionListItem )*

Pivot

PIVOT ( PivotFunctionItems FOR PivotForColumns IN ( SelectItemsList PivotMultiInItems ) ) Alias
Pivot    ::= 'PIVOT' '(' PivotFunctionItems 'FOR' PivotForColumns 'IN' '(' ( SelectItemsList | PivotMultiInItems ) ')' ')' Alias?

PivotXml

PIVOT XML ( PivotFunctionItems FOR PivotForColumns IN ( ANY Select SelectItemsList PivotMultiInItems ) )
PivotXml ::= 'PIVOT' 'XML' '(' PivotFunctionItems 'FOR' PivotForColumns 'IN' '(' ( 'ANY' | Select | SelectItemsList | PivotMultiInItems ) ')' ')'

UnPivot

UNPIVOT INCLUDE EXCLUDE NULLS ( PivotForColumns FOR PivotForColumns IN ( SelectItemsList ) ) Alias
UnPivot  ::= 'UNPIVOT' ( ( 'INCLUDE' | 'EXCLUDE' ) 'NULLS' )? '(' PivotForColumns 'FOR' PivotForColumns 'IN' '(' SelectItemsList ')' ')' Alias?

IntoClause

INTO Table ,
         ::= 'INTO' Table ( ',' Table )*

ParenthesedFromItem

( FromItem JoinsList )
         ::= '(' FromItem JoinsList? ')'

FromItem

TableFunction Table ParenthesedFromItem ParenthesedSelect Pivot UnPivot LateralSubSelect Alias SampleClause UnPivot PivotXml Pivot MySQLIndexHint SQLServerHints

JoinsList

JoinerExpression
         ::= JoinerExpression+

JoinHint

LOOP HASH MERGE REMOTE
JoinHint ::= 'LOOP'
           | 'HASH'
           | 'MERGE'
           | 'REMOTE'

JoinerExpression

GLOBAL NATURAL RIGHT FULL OUTER LEFT SEMI OUTER INNER CROSS JoinHint JOIN , OUTER STRAIGHT_JOIN APPLY FromItem WITHIN ( JoinWindow ) ON Expression USING ( Column , )
         ::= 'GLOBAL'? 'NATURAL'? ( ( 'RIGHT' | 'FULL' )? 'OUTER'? | 'LEFT' ( 'SEMI' | 'OUTER' )? | 'INNER' | 'CROSS' ) ( JoinHint? 'JOIN' | ',' 'OUTER'? | 'STRAIGHT_JOIN' | 'APPLY' ) FromItem ( ( 'WITHIN' '(' JoinWindow ')' )? ( 'ON' Expression )+ | 'USING' '(' Column ( ',' Column )* ')' )?

JoinWindow

S_LONG S_IDENTIFIER K_DATE_LITERAL , S_LONG S_IDENTIFIER K_DATE_LITERAL
         ::= S_LONG ( S_IDENTIFIER | K_DATE_LITERAL ) ( ',' S_LONG ( S_IDENTIFIER | K_DATE_LITERAL ) )?

KSQLWindowClause

WINDOW HOPPING ( SIZE S_LONG S_IDENTIFIER , ADVANCE BY SESSION ( TUMBLING ( SIZE S_LONG S_IDENTIFIER )
         ::= 'WINDOW' ( 'HOPPING' '(' 'SIZE' S_LONG S_IDENTIFIER ',' 'ADVANCE' 'BY' | 'SESSION' '(' | 'TUMBLING' '(' 'SIZE' ) S_LONG S_IDENTIFIER ')'

WhereClause

WHERE Expression
         ::= 'WHERE' Expression

OracleHierarchicalQueryClause

START WITH AndExpression CONNECT BY NOCYCLE CONNECT BY NOCYCLE AndExpression START WITH AndExpression
         ::= ( 'START' 'WITH' AndExpression 'CONNECT' 'BY' 'NOCYCLE'? | 'CONNECT' 'BY' 'NOCYCLE'? ( AndExpression 'START' 'WITH' )? ) AndExpression

GroupByColumnReferences

GROUP BY GROUPING SETS ( GroupingSet , ) ExpressionList GROUPING SETS ( GroupingSet , ) WITH ROLLUP
         ::= 'GROUP' 'BY' ( 'GROUPING' 'SETS' '(' GroupingSet ( ',' GroupingSet )* ')' | ExpressionList ( 'GROUPING' 'SETS' '(' GroupingSet ( ',' GroupingSet )* ')' )? ( 'WITH' 'ROLLUP' )? )

GroupingSet

ParenthesedExpressionList SimpleExpression
         ::= ParenthesedExpressionList
           | SimpleExpression

Having

HAVING Expression
Having   ::= 'HAVING' Expression

Qualify

QUALIFY Expression
Qualify  ::= 'QUALIFY' Expression

OrderByElements

ORDER SIBLINGS BY OrderByElement ,
         ::= 'ORDER' 'SIBLINGS'? 'BY' OrderByElement ( ',' OrderByElement )*

OrderByElement

Expression ASC DESC NULLS FIRST LAST WITH ROLLUP
         ::= Expression ( 'ASC' | 'DESC' )? ( 'NULLS' ( 'FIRST' | 'LAST' )? )? ( 'WITH' 'ROLLUP' )?

JdbcParameter

? S_PARAMETER S_LONG
         ::= ( '?' | S_PARAMETER ) S_LONG?

LimitWithOffset

LIMIT Expression , Expression PlainLimit
         ::= 'LIMIT' Expression ',' Expression
           | PlainLimit

PlainLimit

LIMIT ParenthesedSelect Expression
         ::= 'LIMIT' ( ParenthesedSelect | Expression )

LimitBy

LimitWithOffset BY ExpressionList

Offset

OFFSET Expression ROWS ROW
Offset   ::= 'OFFSET' Expression ( 'ROWS' | 'ROW' )?

Fetch

FETCH FIRST NEXT Expression PERCENT ROWS ROW ONLY WITH TIES
Fetch    ::= 'FETCH' ( 'FIRST' | 'NEXT' ) ( Expression 'PERCENT'? )? ( 'ROWS' | 'ROW' ) ( 'ONLY' | 'WITH TIES' )

WithIsolation

WITH K_ISOLATION
         ::= 'WITH' K_ISOLATION

OptimizeFor

OPTIMIZE FOR S_LONG ROWS
         ::= 'OPTIMIZE' 'FOR' S_LONG 'ROWS'

Top

TOP S_LONG JdbcParameter : S_IDENTIFIER ( AdditiveExpression ) PERCENT WITH TIES
Top      ::= 'TOP' ( S_LONG | JdbcParameter | ':' S_IDENTIFIER? | '(' AdditiveExpression ')' ) 'PERCENT'? 'WITH TIES'?

Skip

SKIP S_LONG S_IDENTIFIER JdbcParameter
Skip     ::= 'SKIP' ( S_LONG | S_IDENTIFIER | JdbcParameter )

First

FIRST LIMIT S_LONG S_IDENTIFIER JdbcParameter
First    ::= ( 'FIRST' | 'LIMIT' ) ( S_LONG | S_IDENTIFIER | JdbcParameter )

Expression

XorExpression
         ::= XorExpression

XorExpression

OrExpression XOR
         ::= OrExpression ( 'XOR' OrExpression )*

OrExpression

AndExpression OR
         ::= AndExpression ( 'OR' AndExpression )*

AndExpression

Condition NOT ! ( XorExpression ) AND &&
         ::= ( Condition | ( 'NOT' | '!' )? '(' XorExpression ')' ) ( ( 'AND' | '&&' ) ( Condition | ( 'NOT' | '!' )? '(' XorExpression ')' ) )*

Condition

NOT ! RegularCondition SQLCondition
         ::= ( 'NOT' | '!' )? ( RegularCondition | SQLCondition )

OverlapsCondition

ParenthesedExpressionList OVERLAPS ParenthesedExpressionList
         ::= ParenthesedExpressionList 'OVERLAPS' ParenthesedExpressionList

RegularCondition

PRIOR ComparisonItem ( + ) > < = OP_GREATERTHANEQUALS OP_MINORTHANEQUALS OP_NOTEQUALSSTANDARD OP_NOTEQUALSBANG *= =* && &> <& @@ ~ ~* !~ !~* @> <@ ? ?| ?& OP_CONCAT - -# <-> <#> PRIOR ComparisonItem ( + )
         ::= 'PRIOR'? ComparisonItem ( '(' '+' ')' )? ( '>' | '<' | '=' | OP_GREATERTHANEQUALS | OP_MINORTHANEQUALS | OP_NOTEQUALSSTANDARD | OP_NOTEQUALSBANG | '*=' | '=*' | '&&' | '&>' | '<&' | '@@' | '~' | '~*' | '!~' | '!~*' | '@>' | '<@' | '?' | '?|' | '?&' | OP_CONCAT | '-' | '-#' | '<->' | '<#>' ) 'PRIOR'? ComparisonItem ( '(' '+' ')' )?

SQLCondition

ExistsExpression InExpression OverlapsCondition SimpleExpression ExcludesExpression IncludesExpression Between MemberOfExpression IsNullExpression IsBooleanExpression LikeExpression IsDistinctExpression SimilarToExpression
         ::= ExistsExpression
           | InExpression
           | OverlapsCondition

InExpression

SimpleExpression ( + ) GLOBAL NOT IN S_CHAR_LITERAL Function ParenthesedSelect ParenthesedExpressionList SimpleExpression
         ::= SimpleExpression ( '(' '+' ')' )? 'GLOBAL'? 'NOT'? 'IN' ( S_CHAR_LITERAL | Function | ParenthesedSelect | ParenthesedExpressionList | SimpleExpression )

IncludesExpression

INCLUDES ParenthesedExpressionList
         ::= 'INCLUDES' ParenthesedExpressionList

ExcludesExpression

EXCLUDES ParenthesedExpressionList
         ::= 'EXCLUDES' ParenthesedExpressionList

Between

NOT BETWEEN ParenthesedSelect RegularCondition SimpleExpression AND ParenthesedSelect RegularCondition SimpleExpression

LikeExpression

NOT LIKE ILIKE RLIKE REGEXP BINARY SimpleExpression ESCAPE S_CHAR_LITERAL Expression
         ::= 'NOT'? ( 'LIKE' | 'ILIKE' | 'RLIKE' | 'REGEXP' ) 'BINARY'? SimpleExpression ( 'ESCAPE' ( S_CHAR_LITERAL | Expression ) )?

SimilarToExpression

NOT SIMILAR TO SimpleExpression ESCAPE S_CHAR_LITERAL
         ::= 'NOT'? 'SIMILAR' 'TO' SimpleExpression ( 'ESCAPE' S_CHAR_LITERAL )?

IsDistinctExpression

IS NOT DISTINCT FROM SimpleExpression
         ::= 'IS' 'NOT'? 'DISTINCT' 'FROM' SimpleExpression

IsNullExpression

NOT ISNULL NOTNULL IS NOT NULL
         ::= 'NOT'? 'ISNULL'
           | 'NOTNULL'
           | 'IS' 'NOT'? 'NULL'

IsBooleanExpression

IS NOT TRUE FALSE
         ::= 'IS' 'NOT'? ( 'TRUE' | 'FALSE' )

ExistsExpression

EXISTS SimpleExpression
         ::= 'EXISTS' SimpleExpression

MemberOfExpression

MEMBER OF Expression
         ::= 'MEMBER' 'OF' Expression

ExpressionList

ComplexExpressionList SimpleExpressionList ParenthesedExpressionList
         ::= ComplexExpressionList
           | SimpleExpressionList
           | ParenthesedExpressionList

ParenthesedExpressionList

( ComplexExpressionList SimpleExpressionList )
         ::= '(' ( ComplexExpressionList | SimpleExpressionList )? ')'

SimpleExpressionList

SimpleExpression , LambdaExpression SimpleExpression
         ::= SimpleExpression ( ',' ( LambdaExpression | SimpleExpression ) )*

ColumnList

Column ,
         ::= Column ( ',' Column )*

ParenthesedColumnList

( ColumnList )
         ::= '(' ColumnList ')'

ComplexExpressionList

OracleNamedFunctionParameter Expression , OracleNamedFunctionParameter LambdaExpression Expression

NamedExpressionListExprFirst

SimpleExpression FROM IN PLACING SimpleExpression FOR FROM SimpleExpression FOR SimpleExpression
         ::= SimpleExpression ( 'FROM' | 'IN' | 'PLACING' ) SimpleExpression ( ( 'FOR' | 'FROM' ) SimpleExpression ( 'FOR' SimpleExpression )? )?

ComparisonItem

AnyComparisonExpression SimpleExpression ParenthesedExpressionList RowConstructor PrimaryExpression
         ::= AnyComparisonExpression
           | SimpleExpression
           | ParenthesedExpressionList
           | RowConstructor
           | PrimaryExpression

AnyComparisonExpression

ANY SOME ALL Select
         ::= ( 'ANY' | 'SOME' | 'ALL' ) Select

SimpleExpression

UserVariable = := ConcatExpression
         ::= ( UserVariable ( '=' | ':=' ) )? ConcatExpression

ConcatExpression

BitwiseAndOr OP_CONCAT
         ::= BitwiseAndOr ( OP_CONCAT BitwiseAndOr )*

BitwiseAndOr

AdditiveExpression | & << >>
         ::= AdditiveExpression ( ( '|' | '&' | '<<' | '>>' ) AdditiveExpression )*

AdditiveExpression

MultiplicativeExpression + -
         ::= MultiplicativeExpression ( ( '+' | '-' ) MultiplicativeExpression )*

MultiplicativeExpression

BitwiseXor * / DIV %
         ::= BitwiseXor ( ( '*' | '/' | 'DIV' | '%' ) BitwiseXor )*

BitwiseXor

PrimaryExpression ^
         ::= PrimaryExpression ( '^' PrimaryExpression )*

ArrayExpression

[ SimpleExpression : SimpleExpression ]
         ::= ( '[' SimpleExpression? ( ':' SimpleExpression? )? ']' )+

PrimaryExpression

NOT ! + - ~ NULL CaseWhenExpression CharacterPrimary ImplicitCast JdbcParameter JdbcNamedParameter UserVariable NumericBind ExtractExpression MySQLGroupConcat XMLSerializeExpr JsonFunction JsonAggregateFunction FullTextSearch Function AnalyticExpression IntervalExpression S_DOUBLE S_LONG S_HEX CastExpression K_TIME_KEY_EXPR CURRENT DateTimeLiteralExpression StructType ARRAY ArrayConstructor NextValExpression ConnectByRootOperator ALL Column S_CHAR_LITERAL {d {t {ts S_CHAR_LITERAL } ParenthesedSelect ParenthesedExpressionList . RelObjectNameExt COLLATE S_IDENTIFIER IntervalExpressionWithoutInterval ArrayExpression :: ColDataType -> ->> S_CHAR_LITERAL S_LONG #> #>> S_CHAR_LITERAL JsonExpression AT K_DATETIMELITERAL ZONE PrimaryExpression
         ::= ( 'NOT' | '!' )? ( '+' | '-' | '~' )? ( 'NULL' | CaseWhenExpression | CharacterPrimary | ImplicitCast | JdbcParameter | JdbcNamedParameter | UserVariable | NumericBind | ExtractExpression | MySQLGroupConcat | XMLSerializeExpr | JsonFunction | JsonAggregateFunction | FullTextSearch | Function AnalyticExpression? | IntervalExpression | S_DOUBLE | S_LONG | S_HEX | CastExpression | K_TIME_KEY_EXPR | 'CURRENT' | DateTimeLiteralExpression | StructType | 'ARRAY'? ArrayConstructor | NextValExpression | ConnectByRootOperator | 'ALL' | Column | S_CHAR_LITERAL | ( '{d' | '{t' | '{ts' ) S_CHAR_LITERAL '}' | ParenthesedSelect | ParenthesedExpressionList ( '.' RelObjectNameExt )? ) ( 'COLLATE' S_IDENTIFIER )? IntervalExpressionWithoutInterval? ArrayExpression? ( '::' ColDataType )* ( ( ( '->' | '->>' ) ( S_CHAR_LITERAL | S_LONG ) | ( '#>' | '#>>' ) S_CHAR_LITERAL )+ JsonExpression )? ( 'AT' K_DATETIMELITERAL 'ZONE' PrimaryExpression )*

ConnectByRootOperator

CONNECT_BY_ROOT Column
         ::= 'CONNECT_BY_ROOT' Column

NextValExpression

K_NEXTVAL RelObjectNameList
         ::= K_NEXTVAL RelObjectNameList

JdbcNamedParameter

: & IdentifierChain
         ::= ( ':' | '&' ) IdentifierChain

OracleNamedFunctionParameter

RelObjectNameExt2 => Expression
         ::= RelObjectNameExt2 '=>' Expression

UserVariable

@ @@ IdentifierChain
         ::= ( '@' | '@@' ) IdentifierChain

NumericBind

: S_LONG
         ::= ':' S_LONG

DateTimeLiteralExpression

K_DATETIMELITERAL S_CHAR_LITERAL S_QUOTED_IDENTIFIER

RangeExpression

: Expression
         ::= ':' Expression

ArrayConstructor

[ Expression RangeExpression ArrayConstructor , ]
         ::= '[' ( ( Expression RangeExpression? | ArrayConstructor ) ( ',' ( Expression RangeExpression? | ArrayConstructor ) )* )? ']'

StructParameters

RelObjectName ColDataType ,
         ::= RelObjectName? ColDataType ( ',' RelObjectName? ColDataType )*

StructType

STRUCT < StructParameters > ( SelectItemsList ) { RelObjectName : Expression , } :: STRUCT ( StructParameters )
         ::= 'STRUCT' ( '<' StructParameters '>' )? '(' SelectItemsList ')'
           | '{' RelObjectName ':' Expression ( ',' RelObjectName ':' Expression )* '}' ( '::' 'STRUCT' '(' StructParameters ')' )*

ParenthesedExpression

( PrimaryExpression )
         ::= '(' PrimaryExpression ')'

JsonExpression

:: ColDataType -> ->> S_CHAR_LITERAL S_LONG #> #>> S_CHAR_LITERAL
         ::= ( ( '::' ColDataType )+ ( ( '->' | '->>' ) ( S_CHAR_LITERAL | S_LONG ) | ( '#>' | '#>>' ) S_CHAR_LITERAL )* )*

JsonFunction

JSON_OBJECT ( KEY S_CHAR_LITERAL : , VALUE Expression FORMAT JSON , KEY S_CHAR_LITERAL : , VALUE Expression FORMAT JSON NULL ABSENT ON NULL WITH WITHOUT UNIQUE KEYS JSON_ARRAY ( NULL ON NULL Expression FORMAT JSON , ABSENT ON NULL )
         ::= ( 'JSON_OBJECT' '(' ( 'KEY'? S_CHAR_LITERAL ( ( ':' | ',' | 'VALUE' ) Expression ( 'FORMAT' 'JSON' )? )? ( ',' 'KEY'? S_CHAR_LITERAL ( ':' | ',' | 'VALUE' ) Expression ( 'FORMAT' 'JSON' )? )* )? ( ( 'NULL' | 'ABSENT' ) 'ON' 'NULL' )? ( ( 'WITH' | 'WITHOUT' ) 'UNIQUE' 'KEYS' )? | 'JSON_ARRAY' '(' ( 'NULL' 'ON' 'NULL' | Expression ( 'FORMAT' 'JSON' )? ( ',' Expression ( 'FORMAT' 'JSON' )? )* )* ( 'ABSENT' 'ON' 'NULL' )? ) ')'

JsonAggregateFunction

JSON_OBJECTAGG ( KEY DT_ZONE S_DOUBLE S_LONG S_HEX S_CHAR_LITERAL S_IDENTIFIER S_QUOTED_IDENTIFIER : VALUE S_IDENTIFIER S_QUOTED_IDENTIFIER FORMAT JSON NULL ABSENT ON NULL WITH WITHOUT UNIQUE KEYS JSON_ARRAYAGG ( Expression FORMAT JSON OrderByElements NULL ABSENT ON NULL ) FILTER ( WHERE Expression ) OVER ( PARTITION BY ComplexExpressionList ( ComplexExpressionList ) OrderByElements WindowElement )
         ::= ( 'JSON_OBJECTAGG' '(' 'KEY'? ( DT_ZONE | S_DOUBLE | S_LONG | S_HEX | S_CHAR_LITERAL | S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ( ':' | 'VALUE' ) ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ( 'FORMAT' 'JSON' )? ( ( 'NULL' | 'ABSENT' ) 'ON' 'NULL' )? ( ( 'WITH' | 'WITHOUT' ) 'UNIQUE' 'KEYS' )? | 'JSON_ARRAYAGG' '(' Expression ( 'FORMAT' 'JSON' )? OrderByElements? ( ( 'NULL' | 'ABSENT' ) 'ON' 'NULL' )? ) ')' ( 'FILTER' '(' 'WHERE' Expression ')' )? ( 'OVER' '(' ( 'PARTITION' 'BY' ( ComplexExpressionList | '(' ComplexExpressionList ')' ) )? OrderByElements? WindowElement? ')' )?

IntervalExpression

INTERVAL - S_LONG S_DOUBLE S_CHAR_LITERAL JdbcParameter JdbcNamedParameter Function Column S_IDENTIFIER K_DATE_LITERAL
         ::= 'INTERVAL' '-'? ( S_LONG | S_DOUBLE | S_CHAR_LITERAL | JdbcParameter | JdbcNamedParameter | Function | Column ) ( S_IDENTIFIER | K_DATE_LITERAL )?

IntervalExpressionWithoutInterval

K_DATE_LITERAL
         ::= K_DATE_LITERAL

KeepExpression

KEEP ( S_IDENTIFIER FIRST LAST OrderByElements )
         ::= 'KEEP' '(' S_IDENTIFIER ( 'FIRST' | 'LAST' ) OrderByElements ')'

windowFun

IGNORE NULLS OVER WITHIN GROUP RelObjectName windowDefinition OVER ( PARTITION BY ComplexExpressionList ( ComplexExpressionList ) )
         ::= ( ( 'IGNORE' 'NULLS' )? 'OVER' | 'WITHIN' 'GROUP' ) ( RelObjectName | windowDefinition ( 'OVER' '(' ( 'PARTITION' 'BY' ( ComplexExpressionList | '(' ComplexExpressionList ')' ) )? ')' )? )

windowDefinition

( PARTITION BY ComplexExpressionList ( ComplexExpressionList ) OrderByElements WindowElement )
         ::= '(' ( 'PARTITION' 'BY' ( ComplexExpressionList | '(' ComplexExpressionList ')' ) )? OrderByElements? WindowElement? ')'

AnalyticExpression

FILTER ( WHERE Expression ) windowFun windowFun
         ::= 'FILTER' '(' 'WHERE' Expression ')' windowFun?
           | windowFun

WindowElement

ROWS RANGE BETWEEN WindowOffset AND WindowOffset
         ::= ( 'ROWS' | 'RANGE' ) ( 'BETWEEN' WindowOffset 'AND' )? WindowOffset

WindowOffset

UNBOUNDED SimpleExpression PRECEDING FOLLOWING CURRENT ROW
         ::= ( 'UNBOUNDED' | SimpleExpression ) ( 'PRECEDING' | 'FOLLOWING' )
           | 'CURRENT' 'ROW'

ExtractExpression

EXTRACT ( RelObjectName S_CHAR_LITERAL FROM SimpleExpression )
         ::= 'EXTRACT' '(' ( RelObjectName | S_CHAR_LITERAL ) 'FROM' SimpleExpression ')'

ImplicitCast

DataType S_CHAR_LITERAL S_LONG S_DOUBLE
         ::= DataType ( S_CHAR_LITERAL | S_LONG | S_DOUBLE )

CastExpression

CAST SAFE_CAST TRY_CAST INTERPRET ( SimpleExpression AS ROW ( ColumnDefinition , ) ColDataType FORMAT S_CHAR_LITERAL )
         ::= ( 'CAST' | 'SAFE_CAST' | 'TRY_CAST' | 'INTERPRET' ) '(' SimpleExpression 'AS' ( 'ROW' '(' ColumnDefinition ( ',' ColumnDefinition )* ')' | ColDataType ) ( 'FORMAT' S_CHAR_LITERAL )? ')'

CaseWhenExpression

CASE Expression WhenThenSearchCondition ELSE Expression SimpleExpression END
         ::= 'CASE' Expression? WhenThenSearchCondition+ ( 'ELSE' ( Expression | SimpleExpression ) )? 'END'

WhenThenSearchCondition

WHEN Expression THEN Expression SimpleExpression
         ::= 'WHEN' Expression 'THEN' ( Expression | SimpleExpression )

RowConstructor

ROW ParenthesedExpressionList
         ::= 'ROW' ParenthesedExpressionList

VariableExpression

UserVariable = SimpleExpression
         ::= UserVariable '=' SimpleExpression

Execute

EXEC EXECUTE CALL RelObjectNameList ExpressionList
Execute  ::= ( 'EXEC' | 'EXECUTE' | 'CALL' ) RelObjectNameList ExpressionList?

FullTextSearch

MATCH ( ColumnList ) AGAINST ( S_CHAR_LITERAL JdbcParameter JdbcNamedParameter IN NATURAL LANGUAGE MODE IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION IN BOOLEAN MODE WITH QUERY EXPANSION )
         ::= 'MATCH' '(' ColumnList ')' 'AGAINST' '(' ( S_CHAR_LITERAL | JdbcParameter | JdbcNamedParameter ) ( 'IN NATURAL LANGUAGE MODE' | 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION' | 'IN BOOLEAN MODE' | 'WITH QUERY EXPANSION' )? ')'

LambdaExpression

RelObjectName -> Expression
         ::= RelObjectName '->' Expression

Function

{ FN InternalFunction } SimpleFunction SpecialStringFunctionWithNamedParameters InternalFunction
Function ::= '{' 'FN' InternalFunction '}'
           | SimpleFunction
           | InternalFunction

SpecialStringFunctionWithNamedParameters

K_STRING_FUNCTION_NAME ( NamedExpressionListExprFirst ExpressionList )

SimpleFunction

RelObjectNameList ( * AllTableColumns ParenthesedSelect SimpleFunction RegularCondition SimpleExpressionList ) . Function Column

InternalFunction

RelObjectNameList ( DISTINCT ALL UNIQUE ExpressionList OrderByElements Select HAVING MIN MAX Expression IGNORE RESPECT NULLS PlainLimit ) . Function Column KeepExpression
         ::= RelObjectNameList '(' ( ( 'DISTINCT' | 'ALL' | 'UNIQUE' )? ( ExpressionList OrderByElements? | Select ) )? ( 'HAVING' ( 'MIN' | 'MAX' ) Expression )? ( ( 'IGNORE' | 'RESPECT' ) 'NULLS' )? PlainLimit? ')' ( '.' ( Function | Column ) )? KeepExpression?

XMLSerializeExpr

XMLSERIALIZE ( XMLAGG ( XMLTEXT ( SimpleExpression ) OrderByElements ) AS ColDataType )
         ::= 'XMLSERIALIZE' '(' 'XMLAGG' '(' 'XMLTEXT' '(' SimpleExpression ')' OrderByElements? ')' 'AS' ColDataType ')'

MySQLGroupConcat

GROUP_CONCAT ( DISTINCT ExpressionList OrderByElements SEPARATOR S_CHAR_LITERAL )
         ::= 'GROUP_CONCAT' '(' 'DISTINCT'? ExpressionList OrderByElements? ( 'SEPARATOR' S_CHAR_LITERAL )? ')'

TableFunction

LATERAL Function
         ::= 'LATERAL'? Function

ColumnNamesWithParamsList

( RelObjectName CreateParameter , )
         ::= '(' RelObjectName CreateParameter? ( ',' RelObjectName CreateParameter? )* ')'

Index

RelObjectNameList

CreateIndex

CreateParameter INDEX IF NOT EXISTS Index ON Table USING S_IDENTIFIER USING S_IDENTIFIER ON Table ColumnNamesWithParamsList CreateParameter
         ::= CreateParameter? 'INDEX' ( 'IF' 'NOT' 'EXISTS' )? Index ( 'ON' Table ( 'USING' S_IDENTIFIER )? | ( 'USING' S_IDENTIFIER )? 'ON' Table ) ColumnNamesWithParamsList CreateParameter*

ColumnDefinition

RelObjectName ColDataType CreateParameter

CreateSchema

SCHEMA S_IDENTIFIER S_QUOTED_IDENTIFIER AUTHORIZATION S_IDENTIFIER S_QUOTED_IDENTIFIER PathSpecification CREATE CreateTable CreateView
         ::= 'SCHEMA' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER )? ( 'AUTHORIZATION' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) )? PathSpecification? ( 'CREATE' CreateTable | CreateView )*

PathSpecification

PATH S_IDENTIFIER S_QUOTED_IDENTIFIER ,
         ::= 'PATH' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ( ',' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) )*

CreateTable

UNLOGGED GLOBAL CreateParameter TABLE IF NOT EXISTS Table ( ColumnDefinition , INDEX UNIQUE FULLTEXT KEY RelObjectName ColumnNamesWithParamsList CreateParameter CONSTRAINT RelObjectName PRIMARY KEY UNIQUE KEY ColumnNamesWithParamsList CreateParameter FOREIGN KEY ColumnNamesWithParamsList REFERENCES Table ColumnsNamesList ON DELETE UPDATE Action ON DELETE UPDATE Action CHECK ( Expression ) EXCLUDE WHERE ( Expression ) ColumnDefinition RelObjectName , ) CreateParameter RowMovement AS Select LIKE ( Table ) Table , SpannerInterleaveIn
         ::= 'UNLOGGED'? 'GLOBAL'? CreateParameter* 'TABLE' ( 'IF' 'NOT' 'EXISTS' )? Table ( '(' ( RelObjectName ( ',' RelObjectName )* | ColumnDefinition ( ',' ( ( 'INDEX' | 'UNIQUE'? 'FULLTEXT'? 'KEY' ) RelObjectName ColumnNamesWithParamsList CreateParameter* | ( 'CONSTRAINT' RelObjectName )? ( ( 'PRIMARY' 'KEY' | 'UNIQUE' 'KEY'? ) ColumnNamesWithParamsList CreateParameter* | 'FOREIGN' 'KEY' ColumnNamesWithParamsList 'REFERENCES' Table ColumnsNamesList ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? | 'CHECK' ( '(' Expression ')' )* ) | 'EXCLUDE' 'WHERE' ( '(' Expression ')' )* | ColumnDefinition ) )* ) ')' )? CreateParameter* RowMovement? ( 'AS' Select )? ( 'LIKE' ( '(' Table ')' | Table ) )? ( ',' SpannerInterleaveIn )?

SpannerInterleaveIn

INTERLEAVE IN PARENT Table ON DELETE NO ACTION CASCADE
         ::= 'INTERLEAVE' 'IN' 'PARENT' Table ( 'ON' 'DELETE' ( 'NO' 'ACTION' | 'CASCADE' ) )?

DataType

K_DATETIMELITERAL DT_ZONE DATA_TYPE SIGNED UNSIGNED CHARACTER BIT BYTES BINARY CHAR JSON STRING DATA_TYPE SIGNED UNSIGNED CHARACTER BIT BYTES BINARY CHAR JSON STRING ( S_LONG MAX , S_LONG ) ARRAY < ColDataType >
DataType ::= 'ARRAY' '<' ColDataType '>'
           | ( K_DATETIMELITERAL | DT_ZONE | DATA_TYPE | 'SIGNED' | 'UNSIGNED' | 'CHARACTER' | 'BIT' | 'BYTES' | 'BINARY' | 'CHAR' | 'JSON' | 'STRING' ) ( DATA_TYPE | 'SIGNED' | 'UNSIGNED' | 'CHARACTER' | 'BIT' | 'BYTES' | 'BINARY' | 'CHAR' | 'JSON' | 'STRING' )* ( '(' ( S_LONG | 'MAX' ) ( ',' S_LONG )? ')' )?

ColDataType

DataType S_IDENTIFIER S_QUOTED_IDENTIFIER K_DATETIMELITERAL K_DATE_LITERAL XML INTERVAL DT_ZONE CHAR SET BINARY JSON STRING PUBLIC DATA . ColDataType ( S_LONG MAX BYTE CHAR S_CHAR_LITERAL S_IDENTIFIER CHAR , ) [ S_LONG ] CHARACTER SET S_IDENTIFIER BINARY
         ::= ( DataType | ( S_IDENTIFIER | S_QUOTED_IDENTIFIER | K_DATETIMELITERAL | K_DATE_LITERAL | 'XML' | 'INTERVAL' | DT_ZONE | 'CHAR' | 'SET' | 'BINARY' | 'JSON' | 'STRING' | 'PUBLIC' | 'DATA' ) ( '.' ColDataType )? ) ( '(' ( ( ( S_LONG | 'MAX' ) ( 'BYTE' | 'CHAR' )? | S_CHAR_LITERAL | S_IDENTIFIER | 'CHAR' ) ','? )* ')' )? ( '[' S_LONG? ']' )* ( 'CHARACTER' 'SET' ( S_IDENTIFIER | 'BINARY' ) )?

Analyze

ANALYZE Table
Analyze  ::= 'ANALYZE' Table

ColumnWithCommentList

( Column , )
         ::= '(' Column ( ',' Column )* ')'

CreateView

NO FORCE SECURE TEMP TEMPORARY VOLATILE MATERIALIZED VIEW Table AUTO REFRESH YES NO IF NOT EXISTS ColumnWithCommentList CreateViewTailComment AS Select WITH READ ONLY
         ::= ( 'NO'? 'FORCE' )? 'SECURE'? ( 'TEMP' | 'TEMPORARY' | 'VOLATILE' )? 'MATERIALIZED'? 'VIEW' Table ( 'AUTO' 'REFRESH' ( 'YES' | 'NO' ) )? ( 'IF' 'NOT' 'EXISTS' )? ColumnWithCommentList? CreateViewTailComment? 'AS' Select ( 'WITH' 'READ' 'ONLY' )?

CreateViewTailComment

COMMENT = S_CHAR_LITERAL
         ::= 'COMMENT' '='? S_CHAR_LITERAL

Action

CASCADE RESTRICT NO ACTION SET NULL DEFAULT
Action   ::= 'CASCADE'
           | 'RESTRICT'
           | 'NO' 'ACTION'
           | 'SET' ( 'NULL' | 'DEFAULT' )

AlterView

VIEW Table ColumnsNamesList AS Select
         ::= 'VIEW' Table ColumnsNamesList? 'AS' Select

CreateParameter

K_NEXTVAL ( S_CHAR_LITERAL :: ColDataType ) S_IDENTIFIER S_QUOTED_IDENTIFIER . S_IDENTIFIER S_QUOTED_IDENTIFIER USING INDEX TABLESPACE RelObjectName S_CHAR_LITERAL NULL NOT PRIMARY FOREIGN REFERENCES KEY STORED ON COMMIT DROP ROWS UNIQUE CASCADE DELETE UPDATE CONSTRAINT WITH EXCLUDE WHERE TEMP TEMPORARY PARTITION BY IN TYPE COMMENT USING COLLATE ASC DESC TRUE FALSE PARALLEL BINARY START K_TIME_KEY_EXPR RAW HASH FIRST LAST SIGNED UNSIGNED = DEFAULT AS CHECK ( Expression ) + - S_LONG S_DOUBLE AList CHARACTER SET ARRAY ArrayConstructor :: ColDataType
         ::= K_NEXTVAL '(' S_CHAR_LITERAL '::' ColDataType ')'
           | ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ( '.' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) )?
           | ( 'USING' 'INDEX' )? 'TABLESPACE' RelObjectName
           | S_CHAR_LITERAL
           | 'NULL'
           | 'NOT'
           | 'PRIMARY'
           | 'FOREIGN'
           | 'REFERENCES'
           | 'KEY'
           | 'STORED'
           | 'ON'
           | 'COMMIT'
           | 'DROP'
           | 'ROWS'
           | 'UNIQUE'
           | 'CASCADE'
           | 'DELETE'
           | 'UPDATE'
           | 'CONSTRAINT'
           | 'WITH'
           | 'EXCLUDE'
           | 'WHERE'
           | 'TEMP'
           | 'TEMPORARY'
           | 'PARTITION'
           | 'BY'
           | 'IN'
           | 'TYPE'
           | 'COMMENT'
           | 'USING'
           | 'COLLATE'
           | 'ASC'
           | 'DESC'
           | 'TRUE'
           | 'FALSE'
           | 'PARALLEL'
           | 'BINARY'
           | 'START'
           | K_TIME_KEY_EXPR
           | 'RAW'
           | 'HASH'
           | 'FIRST'
           | 'LAST'
           | 'SIGNED'
           | 'UNSIGNED'
           | '='
           | ( 'DEFAULT' | 'AS' | 'CHECK' ) ( '(' Expression ')' )?
           | ( '+' | '-' )? S_LONG
           | S_DOUBLE
           | AList
           | 'CHARACTER' 'SET'
           | 'ARRAY' ArrayConstructor
           | '::' ColDataType

RowMovement

ENABLE DISABLE ROW MOVEMENT
         ::= ( 'ENABLE' | 'DISABLE' ) 'ROW' 'MOVEMENT'

AList

( S_LONG S_DOUBLE S_CHAR_LITERAL RelObjectNameWithoutValue , = )
AList    ::= '(' ( ( S_LONG | S_DOUBLE | S_CHAR_LITERAL | RelObjectNameWithoutValue ) ( ',' | '=' )? )* ')'

ColumnsNamesListItem

RelObjectName ( S_LONG )
         ::= RelObjectName ( '(' S_LONG ')' )?

ColumnsNamesList

( ColumnsNamesListItem , )
         ::= '(' ColumnsNamesListItem ( ',' ColumnsNamesListItem )* ')'

FuncArgsListItem

RelObjectName RelObjectName ( S_LONG )
         ::= RelObjectName RelObjectName? ( '(' S_LONG ')' )?

FuncArgsList

( FuncArgsListItem , )
         ::= '(' ( FuncArgsListItem ( ',' FuncArgsListItem )* )? ')'

Drop

DROP MATERIALIZED S_IDENTIFIER TEMPORARY TABLE INDEX VIEW SCHEMA SEQUENCE FUNCTION IF EXISTS Table FuncArgsList S_IDENTIFIER CASCADE RESTRICT ON
Drop     ::= 'DROP' 'MATERIALIZED'? ( S_IDENTIFIER | 'TEMPORARY'? 'TABLE' | 'INDEX' | 'VIEW' | 'SCHEMA' | 'SEQUENCE' | 'FUNCTION' ) ( 'IF' 'EXISTS' )? Table FuncArgsList? ( S_IDENTIFIER | 'CASCADE' | 'RESTRICT' | 'ON' )*

Truncate

TRUNCATE TABLE ONLY Table CASCADE
Truncate ::= 'TRUNCATE' 'TABLE'? 'ONLY'? Table 'CASCADE'?

AlterExpressionColumnDataType

RelObjectName TYPE ColDataType CreateParameter
         ::= RelObjectName 'TYPE'? ColDataType? CreateParameter*

AlterExpressionColumnDropNotNull

RelObjectName DROP NOT NULL
         ::= RelObjectName 'DROP' 'NOT'? 'NULL'

AlterExpressionColumnDropDefault

RelObjectName DROP DEFAULT
         ::= RelObjectName 'DROP' 'DEFAULT'

AlterExpressionConstraintState

NOT DEFERRABLE VALIDATE NOVALIDATE ENABLE DISABLE
         ::= ( 'NOT'? 'DEFERRABLE' | 'VALIDATE' | 'NOVALIDATE' | 'ENABLE' | 'DISABLE' )*

IndexWithComment

COMMENT S_CHAR_LITERAL
         ::= 'COMMENT' S_CHAR_LITERAL

AlterExpression

ADD ALTER MODIFY PRIMARY KEY ColumnsNamesList AlterExpressionConstraintState USING RelObjectName KEY INDEX RelObjectName ColumnsNamesList AlterExpressionConstraintState UNIQUE KEY INDEX S_IDENTIFIER S_QUOTED_IDENTIFIER ColumnsNamesList USING RelObjectName IndexWithComment RelObjectName COMMENT S_CHAR_LITERAL COLUMN IF NOT EXISTS ( AlterExpressionColumnDataType , ) AlterExpressionColumnDataType AlterExpressionColumnDropNotNull AlterExpressionColumnDropDefault ( AlterExpressionColumnDataType , ) FOREIGN KEY ColumnsNamesList REFERENCES Table ColumnsNamesList ON DELETE UPDATE Action ON DELETE UPDATE Action CONSTRAINT RelObjectName FOREIGN KEY ColumnsNamesList REFERENCES Table ColumnsNamesList ON DELETE UPDATE Action ON DELETE UPDATE Action KEY ColumnsNamesList AlterExpressionConstraintState PRIMARY KEY UNIQUE KEY INDEX ColumnsNamesList AlterExpressionConstraintState USING RelObjectName IndexWithComment CHECK ( Expression ) CHANGE COLUMN S_IDENTIFIER S_QUOTED_IDENTIFIER AlterExpressionColumnDataType DROP ColumnsNamesList COLUMN IF EXISTS S_IDENTIFIER S_QUOTED_IDENTIFIER INVALIDATE CASCADE CONSTRAINTS INDEX KEY S_IDENTIFIER S_QUOTED_IDENTIFIER UNIQUE FOREIGN KEY ColumnsNamesList PRIMARY KEY CONSTRAINT IF EXISTS S_IDENTIFIER S_QUOTED_IDENTIFIER CASCADE RESTRICT ALGORITHM = TRUNCATE PARTITION RelObjectName RENAME COLUMN INDEX KEY CONSTRAINT S_IDENTIFIER S_QUOTED_IDENTIFIER TO S_IDENTIFIER S_QUOTED_IDENTIFIER COMMENT = S_CHAR_LITERAL captureRest
         ::= ( 'ADD' | 'ALTER' | 'MODIFY' ) ( 'PRIMARY' 'KEY' ColumnsNamesList AlterExpressionConstraintState ( 'USING' RelObjectName )? | ( ( 'KEY' | 'INDEX' ) RelObjectName ColumnsNamesList AlterExpressionConstraintState | 'UNIQUE' ( ( 'KEY' | 'INDEX' ) ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) )? ColumnsNamesList ) ( 'USING' RelObjectName )? IndexWithComment? | RelObjectName 'COMMENT' S_CHAR_LITERAL | 'COLUMN'? ( 'IF' 'NOT' 'EXISTS' )? ( '(' AlterExpressionColumnDataType ( ',' AlterExpressionColumnDataType )* ')' | AlterExpressionColumnDataType | AlterExpressionColumnDropNotNull | AlterExpressionColumnDropDefault ) | '(' AlterExpressionColumnDataType ( ',' AlterExpressionColumnDataType )* ')' | 'FOREIGN' 'KEY' ColumnsNamesList 'REFERENCES' Table ColumnsNamesList? ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? | 'CONSTRAINT' RelObjectName ( ( 'FOREIGN' 'KEY' ColumnsNamesList 'REFERENCES' Table ColumnsNamesList? ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? ( 'ON' ( 'DELETE' | 'UPDATE' ) Action )? | 'KEY' ColumnsNamesList ) AlterExpressionConstraintState | ( 'PRIMARY' 'KEY' | 'UNIQUE' ( 'KEY' | 'INDEX' )? ) ColumnsNamesList AlterExpressionConstraintState ( 'USING' RelObjectName )? IndexWithComment? | 'CHECK' ( '(' Expression ')' )* ) )
           | 'CHANGE' 'COLUMN'? ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) AlterExpressionColumnDataType
           | 'DROP' ( ( ColumnsNamesList | 'COLUMN'? ( 'IF' 'EXISTS' )? ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ) 'INVALIDATE'? ( 'CASCADE' 'CONSTRAINTS'? )? | ( 'INDEX' | 'KEY' ) ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) | ( ( 'UNIQUE' | 'FOREIGN' 'KEY' ) ColumnsNamesList | 'PRIMARY' 'KEY' | 'CONSTRAINT' ( 'IF' 'EXISTS' )? ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) ) ( 'CASCADE' | 'RESTRICT' )? )
           | ( 'ALGORITHM' '='? | 'TRUNCATE' 'PARTITION' ) RelObjectName
           | 'RENAME' ( ( 'COLUMN' | 'INDEX' | 'KEY' | 'CONSTRAINT' )? ( S_IDENTIFIER | S_QUOTED_IDENTIFIER ) )? 'TO' ( S_IDENTIFIER | S_QUOTED_IDENTIFIER )
           | 'COMMENT' '='? S_CHAR_LITERAL
           | captureRest

Alter

ALTER AlterTable AlterSession AlterView AlterSystemStatement AlterSequence captureRest REPLACE AlterView captureRest
           | 'REPLACE' ( AlterView | captureRest )

AlterTable

TABLE ONLY IF EXISTS Table AlterExpression ,
         ::= 'TABLE' 'ONLY'? ( 'IF' 'EXISTS' )? Table AlterExpression ( ',' AlterExpression )*

AlterSession

SESSION ADVISE COMMIT ROLLBACK NOTHING CLOSE DATABASE LINK ENABLE DISABLE COMMIT IN PROCEDURE GUARD PARALLEL DML DDL QUERY RESUMABLE FORCE PARALLEL DML DDL QUERY SET S_CHAR_LITERAL S_IDENTIFIER = S_LONG PARALLEL
         ::= 'SESSION' ( 'ADVISE' ( 'COMMIT' | 'ROLLBACK' | 'NOTHING' ) | 'CLOSE' 'DATABASE' 'LINK' | ( 'ENABLE' | 'DISABLE' ) ( 'COMMIT' 'IN' 'PROCEDURE' | 'GUARD' | 'PARALLEL' ( 'DML' | 'DDL' | 'QUERY' ) | 'RESUMABLE' ) | 'FORCE' 'PARALLEL' ( 'DML' | 'DDL' | 'QUERY' ) | 'SET' ) ( S_CHAR_LITERAL | S_IDENTIFIER | '=' | S_LONG | 'PARALLEL' )*

AlterSystemStatement

SYSTEM ARCHIVE LOG CHECKPOINT DUMP ACTIVE SESSION HISTORY ENABLE DISABLE DISTRIBUTED RECOVERY RESTRICTED SESSION FLUSH DISCONNECT SESSION KILL SESSION SWITCH SUSPEND RESUME QUIESCE RESTRICTED UNQIESCE SHUTDOWN REGISTER SET RESET captureRest
         ::= 'SYSTEM' ( 'ARCHIVE' 'LOG' | 'CHECKPOINT' | 'DUMP' 'ACTIVE' 'SESSION' 'HISTORY' | ( 'ENABLE' | 'DISABLE' ) ( 'DISTRIBUTED RECOVERY' | 'RESTRICTED SESSION' ) | 'FLUSH' | 'DISCONNECT' 'SESSION' | 'KILL SESSION' | 'SWITCH' | 'SUSPEND' | 'RESUME' | 'QUIESCE' 'RESTRICTED' | 'UNQIESCE' | 'SHUTDOWN' | 'REGISTER' | 'SET' | 'RESET' ) captureRest

Wait

WAIT S_LONG
Wait     ::= 'WAIT' S_LONG

SavepointStatement

SAVEPOINT S_IDENTIFIER
         ::= 'SAVEPOINT' S_IDENTIFIER

RollbackStatement

ROLLBACK WORK TO SAVEPOINT S_IDENTIFIER FORCE S_CHAR_LITERAL
         ::= 'ROLLBACK' 'WORK'? ( 'TO' 'SAVEPOINT'? S_IDENTIFIER | 'FORCE' S_CHAR_LITERAL )?

Comment

COMMENT ON TABLE VIEW Table COLUMN Column IS S_CHAR_LITERAL
Comment  ::= 'COMMENT' 'ON' ( ( 'TABLE' | 'VIEW' ) Table | 'COLUMN' Column ) 'IS' S_CHAR_LITERAL

Grant

GRANT readGrantTypes , ON RelObjectNameList S_IDENTIFIER TO UsersList
Grant    ::= 'GRANT' ( ( readGrantTypes ( ',' readGrantTypes )* )? 'ON' RelObjectNameList | S_IDENTIFIER ) 'TO' UsersList

UsersList

RelObjectName , ColumnsNamesListItem
         ::= RelObjectName ( ',' ColumnsNamesListItem )*

readGrantTypes

K_SELECT INSERT UPDATE DELETE EXECUTE ALTER DROP
         ::= K_SELECT
           | 'INSERT'
           | 'UPDATE'
           | 'DELETE'
           | 'EXECUTE'
           | 'ALTER'
           | 'DROP'

Sequence

RelObjectNameList

SequenceParameters

INCREMENT BY START WITH MAXVALUE MINVALUE CACHE S_LONG RESTART WITH S_LONG NOMAXVALUE NOMINVALUE NOCYCLE CYCLE NOCACHE ORDER NOORDER KEEP NOKEEP SESSION GLOBAL
         ::= ( ( 'INCREMENT' 'BY' | 'START' 'WITH' | 'MAXVALUE' | 'MINVALUE' | 'CACHE' ) S_LONG | 'RESTART' ( 'WITH' S_LONG )? | 'NOMAXVALUE' | 'NOMINVALUE' | 'NOCYCLE' | 'CYCLE' | 'NOCACHE' | 'ORDER' | 'NOORDER' | 'KEEP' | 'NOKEEP' | 'SESSION' | 'GLOBAL' )*

CreateSequence

SEQUENCE Sequence SequenceParameters
         ::= 'SEQUENCE' Sequence SequenceParameters

AlterSequence

SEQUENCE Sequence SequenceParameters
         ::= 'SEQUENCE' Sequence SequenceParameters

Create

CREATE OR REPLACE CreateFunctionStatement CreateSchema CreateSequence CreateSynonym CreateTable CreateView TRIGGER DOMAIN captureRest CreateIndex
Create   ::= 'CREATE' ( 'OR' 'REPLACE' )? ( CreateFunctionStatement | CreateSchema | CreateSequence | CreateSynonym | CreateTable | CreateView | ( 'TRIGGER' | 'DOMAIN' )? captureRest | CreateIndex )

CreateFunctionStatement

FUNCTION PROCEDURE captureFunctionBody
         ::= ( 'FUNCTION' | 'PROCEDURE' ) captureFunctionBody

CreateSynonym

PUBLIC SYNONYM Synonym FOR RelObjectNameList
         ::= 'PUBLIC'? 'SYNONYM' Synonym 'FOR' RelObjectNameList

Synonym

RelObjectNameList

UnsupportedStatement

captureUnsupportedStatementDeclaration

IdentifierChain

RelObjectNameExt2 .
         ::= RelObjectNameExt2 ( '.' RelObjectNameExt2 )*

CharacterPrimary

TranscodingFunction TrimFunction
         ::= TranscodingFunction
           | TrimFunction

TranscodingFunction

CONVERT ( ColDataType , Expression , S_LONG Expression USING IdentifierChain )
         ::= 'CONVERT' '(' ( ColDataType ',' Expression ( ',' S_LONG )? | Expression 'USING' IdentifierChain ) ')'

TrimFunction

TRIM ( LEADING TRAILING BOTH Expression , FROM Expression )
         ::= 'TRIM' '(' ( 'LEADING' | 'TRAILING' | 'BOTH' )? Expression? ( ( ',' | 'FROM' ) Expression )? ')'

WHITESPACE

[#x9] [#xD] [#xA]
         ::= [ #x9#xD#xA]

K_DATETIMELITERAL

DATE DATETIME TIME TIMESTAMP TIMESTAMPTZ
         ::= 'DATE'
           | 'DATETIME'
           | 'TIME'
           | 'TIMESTAMP'
           | 'TIMESTAMPTZ'

K_DATE_LITERAL

YEAR MONTH DAY HOUR MINUTE SECOND
         ::= 'YEAR'
           | 'MONTH'
           | 'DAY'
           | 'HOUR'
           | 'MINUTE'
           | 'SECOND'

K_ISOLATION

UR RS RR CS
         ::= 'UR'
           | 'RS'
           | 'RR'
           | 'CS'

K_NEXTVAL

NEXTVAL FOR NEXT VALUE FOR
         ::= 'NEXTVAL' ( ' '+ 'FOR' )?
           | 'NEXT' ' '+ 'VALUE' ' '+ 'FOR'

K_SELECT

SELECT SEL
K_SELECT ::= 'SELECT'
           | 'SEL'

K_TIME_KEY_EXPR

CURRENT _ TIMESTAMP TIME DATE TIMEZONE ()
         ::= 'CURRENT' ( '_' | ' '+ ) ( 'TIMESTAMP' | 'TIME' | 'DATE' | 'TIMEZONE' ) '()'?

K_STRING_FUNCTION_NAME

SUBSTR SUBSTRING TRIM POSITION OVERLAY
         ::= 'SUBSTR'
           | 'SUBSTRING'
           | 'TRIM'
           | 'POSITION'
           | 'OVERLAY'

ST_SEMICOLON

; [#xA] / [#xA] go [#xA]
         ::= ';'
           | #xA ( [/#xA] | 'go' ) #xA

OP_GREATERTHANEQUALS

> WHITESPACE =
         ::= '>' WHITESPACE* '='

OP_MINORTHANEQUALS

< WHITESPACE =
         ::= '<' WHITESPACE* '='

OP_NOTEQUALSSTANDARD

< WHITESPACE >
         ::= '<' WHITESPACE* '>'

OP_NOTEQUALSBANG

! WHITESPACE =
         ::= '!' WHITESPACE* '='

OP_CONCAT

| WHITESPACE |
         ::= '|' WHITESPACE* '|'

DT_ZONE

K_DATETIMELITERAL WHITESPACE ( S_LONG ) WHITESPACE WITH WITHOUT WHITESPACE LOCAL WHITESPACE TIME WHITESPACE ZONE
DT_ZONE  ::= K_DATETIMELITERAL WHITESPACE* ( '(' S_LONG ')' )? WHITESPACE* ( 'WITH' | 'WITHOUT' ) WHITESPACE+ ( 'LOCAL' WHITESPACE+ )? 'TIME' WHITESPACE+ 'ZONE'

DATA_TYPE

BISTRING TYPE_BLOB TYPE_BOOLEAN ENUM TYPE_REAL TYPE_DOUBLE UUID MAP TYPE_TINYINT TYPE_SMALLINT TYPE_INTEGER TYPE_BIGINT HUGEINT UTINYINT USMALLINT UINTEGER UBIGINT UHUGEINT TYPE_DECIMAL TYPE_VARCHAR TIMETZ TYPE_TIMESTAMP
         ::= 'BISTRING'
           | TYPE_BLOB
           | TYPE_BOOLEAN
           | 'ENUM'
           | TYPE_REAL
           | TYPE_DOUBLE
           | 'UUID'
           | 'MAP'
           | TYPE_TINYINT
           | TYPE_SMALLINT
           | TYPE_INTEGER
           | TYPE_BIGINT
           | 'HUGEINT'
           | 'UTINYINT'
           | 'USMALLINT'
           | 'UINTEGER'
           | 'UBIGINT'
           | 'UHUGEINT'
           | TYPE_DECIMAL
           | TYPE_VARCHAR
           | 'TIMETZ'
           | TYPE_TIMESTAMP

TYPE_BLOB

BLOB BYTEA BINARY VARBINARY BYTES
         ::= 'BLOB'
           | 'BYTEA'
           | 'BINARY'
           | 'VARBINARY'
           | 'BYTES'

TYPE_BOOLEAN

BOOLEAN BOOL
         ::= 'BOOLEAN'
           | 'BOOL'

TYPE_DECIMAL

DECIMAL NUMBER NUMERIC
         ::= 'DECIMAL'
           | 'NUMBER'
           | 'NUMERIC'

TYPE_TINYINT

TINYINT INT1
         ::= 'TINYINT'
           | 'INT1'

TYPE_SMALLINT

SMALLINT INT2 SHORT
         ::= 'SMALLINT'
           | 'INT2'
           | 'SHORT'

TYPE_INTEGER

INTEGER INT INT4 SIGNED UNSIGNED
         ::= 'INTEGER'
           | 'INT'
           | 'INT4'
           | 'SIGNED'
           | 'UNSIGNED'

TYPE_BIGINT

BIGINT INT8 LONG
         ::= 'BIGINT'
           | 'INT8'
           | 'LONG'

TYPE_REAL

REAL FLOAT4 FLOAT
         ::= 'REAL'
           | 'FLOAT4'
           | 'FLOAT'

TYPE_DOUBLE

DOUBLE PRECISION FLOAT8 FLOAT64
         ::= 'DOUBLE'
           | 'PRECISION'
           | 'FLOAT8'
           | 'FLOAT64'

TYPE_VARCHAR

NVARCHAR VARCHAR NCHAR CHAR BPCHAR STRING TEXT CHARACTER VARYING
         ::= 'NVARCHAR'
           | 'VARCHAR'
           | 'NCHAR'
           | 'CHAR'
           | 'BPCHAR'
           | 'STRING'
           | 'TEXT'
           | 'CHARACTER'
           | 'VARYING'

TYPE_TIMESTAMP

TIMESTAMP_NS TIMESTAMP_MS TIMESTAMP_S
         ::= 'TIMESTAMP_NS'
           | 'TIMESTAMP_MS'
           | 'TIMESTAMP_S'

S_DOUBLE

S_LONG . S_LONG e E + [#x2D] S_LONG S_LONG . e E + [#x2D] S_LONG e E + [#x2D] S_LONG
S_DOUBLE ::= S_LONG? '.' S_LONG ( [eE] [+#x2D]? S_LONG )?
           | S_LONG ( '.' ( [eE] [+#x2D]? S_LONG )? | [eE] [+#x2D]? S_LONG )

S_LONG

DIGIT
S_LONG   ::= DIGIT+

DIGIT

[0-9]
DIGIT    ::= [0-9]

S_HEX

X ' HEX_VALUE ' 0x HEX_VALUE
S_HEX    ::= 'X' ( "'" HEX_VALUE* "'" ' '* )+
           | '0x' HEX_VALUE+

HEX_VALUE

[0-9] [A-F]
         ::= [0-9A-F ]

LINE_COMMENT

-- // [^#xD#xA]
         ::= ( '--' | '//' ) [^#xD#xA]*

MULTI_LINE_COMMENT

/* [^*] * [^*] [^*/] /
         ::= '/*' [^*]* '*' ( ( [^*/] [^*]* )? '*' )* '/'

S_PARAMETER

$ [0-9]
         ::= '$' [0-9]+

S_IDENTIFIER

LETTER PART_LETTER
         ::= LETTER PART_LETTER*

LETTER

UnicodeIdentifierStart Nd $ _ [#x23]
           | Nd
           | [$_#x23]

PART_LETTER

UnicodeIdentifierStart UnicodeIdentifierExtend $ _ @ [#x23]
         ::= UnicodeIdentifierStart
           | UnicodeIdentifierExtend
           | [$_@#x23]

UnicodeIdentifierStart

[#xB7] Ll Lm Lo Lt Lu Nl CJK
         ::= #xB7
           | Ll
           | Lm
           | Lo
           | Lt
           | Lu
           | Nl
           | CJK

Ll

[a-z] [#xB5] [#xDF-#xF6] [#xF8-#xFF] [#x101] [#x103] [#x105] [#x107] [#x109] [#x10B] [#x10D] [#x10F] [#x111] [#x113] [#x115] [#x117] [#x119] [#x11B] [#x11D] [#x11F] [#x121] [#x123] [#x125] [#x127] [#x129] [#x12B] [#x12D] [#x12F] [#x131] [#x133] [#x135] [#x137-#x138] [#x13A] [#x13C] [#x13E] [#x140] [#x142] [#x144] [#x146] [#x148-#x149] [#x14B] [#x14D] [#x14F] [#x151] [#x153] [#x155] [#x157] [#x159] [#x15B] [#x15D] [#x15F] [#x161] [#x163] [#x165] [#x167] [#x169] [#x16B] [#x16D] [#x16F] [#x171] [#x173] [#x175] [#x177] [#x17A] [#x17C] [#x17E-#x180] [#x183] [#x185] [#x188] [#x18C-#x18D] [#x192] [#x195] [#x199-#x19B] [#x19E] [#x1A1] [#x1A3] [#x1A5] [#x1A8] [#x1AA-#x1AB] [#x1AD] [#x1B0] [#x1B4] [#x1B6] [#x1B9-#x1BA] [#x1BD-#x1BF] [#x1C6] [#x1C9] [#x1CC] [#x1CE] [#x1D0] [#x1D2] [#x1D4] [#x1D6] [#x1D8] [#x1DA] [#x1DC-#x1DD] [#x1DF] [#x1E1] [#x1E3] [#x1E5] [#x1E7] [#x1E9] [#x1EB] [#x1ED] [#x1EF-#x1F0] [#x1F3] [#x1F5] [#x1F9] [#x1FB] [#x1FD] [#x1FF] [#x201] [#x203] [#x205] [#x207] [#x209] [#x20B] [#x20D] [#x20F] [#x211] [#x213] [#x215] [#x217] [#x219] [#x21B] [#x21D] [#x21F] [#x221] [#x223] [#x225] [#x227] [#x229] [#x22B] [#x22D] [#x22F] [#x231] [#x233-#x239] [#x23C] [#x23F-#x240] [#x242] [#x247] [#x249] [#x24B] [#x24D] [#x24F-#x293] [#x295-#x2AF] [#x371] [#x373] [#x377] [#x37B-#x37D] [#x390] [#x3AC-#x3CE] [#x3D0-#x3D1] [#x3D5-#x3D7] [#x3D9] [#x3DB] [#x3DD] [#x3DF] [#x3E1] [#x3E3] [#x3E5] [#x3E7] [#x3E9] [#x3EB] [#x3ED] [#x3EF-#x3F3] [#x3F5] [#x3F8] [#x3FB-#x3FC]