BNF for SQL Grammar

Page edited by Steven Hawkins


Changes (53)

...
|{anchor:token_FULL}_FULL_|[qualified table|#qualifiedJoin]||
|{anchor:token_FUNCTION}_FUNCTION_|[create procedure|#createDDLProcedure]||
|{anchor:token_GLOBAL}_GLOBAL_|[create table|#createTable]||
|{anchor:token_GROUP}_GROUP_|[group by clause|#groupBy]||
|{anchor:token_HAVING}_HAVING_|[having clause|#having]||
...
|{anchor:token_INTO}_INTO_|[dynamic data statement|#dynamicCommand], [insert statement|#insert], [into clause|#into]||
|{anchor:token_IS}_IS_|[is null predicate|#isNullCrit]||
|{anchor:token_JOIN}_JOIN_|[cross join|#crossJoin], [make dep options|#makedepOptions], [qualified table|#qualifiedJoin]||
|{anchor:token_LANGUAGE}_LANGUAGE_|[object table|#objectTable]||
|{anchor:token_LATERAL}_LATERAL_|[table subquery|#subqueryFromClause]||
...
|{anchor:token_LIKE_REGEX}_LIKE_REGEX_|[like regex predicate|#regexMatchCrit]||
|{anchor:token_LIMIT}_LIMIT_|[limit clause|#limit]||
|{anchor:token_LOCAL}_LOCAL_|[create foreign temp table|#createForeignTempTable], [create temporary table|#createTempTable]||
|{anchor:token_LONG}_LONG_|[data type|#parseDataType]||
|{anchor:token_LOOP}_LOOP_|[loop statement|#loopStatement]||
...
|{anchor:token_TABLE}_TABLE_|[alter options|#alterStatement], [create procedure|#createDDLProcedure], [create foreign temp table|#createForeignTempTable], [create table|#createTable]
[create temporary table|#createTempTable], [drop table|#dropTable], [query primary|#queryPrimary], [table subquery|#subqueryFromClause]||
|{anchor:token_TEMPORARY}_TEMPORARY_|[create foreign temp table|#createForeignTempTable], [create table|#createTable], [create temporary table|#createTempTable]||
|{anchor:token_THEN}_THEN_|[case expression|#caseExpression], [searched case expression|#searchedCaseExpression]||
|{anchor:token_TIME}_TIME_|[data type|#parseDataType]||
...
[primary key|#primaryKey]||
|{anchor:token_LAST}_LAST_|[non-reserved identifier|#nonReserved], [sort specification|#sortSpecification]||
|{anchor:token_MAX}_MAX_|[standard aggregate function|#aggregateSymbol], [make dep options|#makedepOptions], [non-reserved identifier|#nonReserved]||
|{anchor:token_MIN}_MIN_|[standard aggregate function|#aggregateSymbol], [non-reserved identifier|#nonReserved]||
|{anchor:token_NAME}_NAME_|[function|#function], [non-reserved identifier|#nonReserved], [xml element|#xmlElement]||
...
|{anchor:token_ROW_NUMBER}_ROW_NUMBER_|[analytic aggregate function|#analyticAggregateSymbol], [non-reserved identifier|#nonReserved]||
|{anchor:token_SELECTOR}_SELECTOR_|[non-reserved identifier|#nonReserved], [text table column|#textColumn], [text table|#textTable]||
|{anchor:token_SERIAL}_SERIAL_|[non-reserved |{anchor:token_SERIAL}_SERIAL_|[table element|#createColumn], [non-reserved identifier|#nonReserved], [temporary table element|#tableElement]||
|{anchor:token_SKIP_KEYWORD}_SKIP_|[non-reserved identifier|#nonReserved], [text table|#textTable]||
|{anchor:token_SQL_TSI_DAY}_SQL_TSI_DAY_|[time interval|#intervalType], [non-reserved identifier|#nonReserved]||
...
|DEALLOCATE|DEC|DEREF|DESCRIBE|DETERMINISTIC|DISCONNECT|DLNEWCOPY|DLPREVIOUSCOPY||
|DLURLCOMPLETE|DLURLCOMPLETEONLY|DLURLCOMPLETEWRITE|DLURLPATH|DLURLPATHONLY|DLURLPATHWRITE|DLURLSCHEME|DLURLSERVER||
|DLVALUE|DYNAMIC|ELEMENT|EXTERNAL|FREE|GET|GLOBAL|GRANT|| |DLVALUE|DYNAMIC|ELEMENT|EXTERNAL|FREE|GET|GRANT|HAS||
|HAS|HOLD|IDENTITY|IMPORT|INDICATOR|INPUT|INSENSITIVE|INT|| |HOLD|IDENTITY|IMPORT|INDICATOR|INPUT|INSENSITIVE|INT|INTERVAL||
|INTERVAL|ISOLATION|LARGE|LOCALTIME|LOCALTIMESTAMP|MATCH|MEMBER|METHOD|| |ISOLATION|LARGE|LOCALTIME|LOCALTIMESTAMP|MATCH|MEMBER|METHOD|MODIFIES||
|MODIFIES|MODULE|MULTISET|NATIONAL|NATURAL|NCHAR|NCLOB|NEW|| |MODULE|MULTISET|NATIONAL|NATURAL|NCHAR|NCLOB|NEW|NONE||
|NONE|NUMERIC|OLD|OPEN|OUTPUT|OVERLAPS|PRECISION|PREPARE|| |NUMERIC|OLD|OPEN|OUTPUT|OVERLAPS|PRECISION|PREPARE|RANGE||
|RANGE|READS|RECURSIVE|REFERENCING|RELEASE|REVOKE|ROLLBACK|ROLLUP|| |READS|RECURSIVE|REFERENCING|RELEASE|REVOKE|ROLLBACK|ROLLUP|SAVEPOINT||
|SAVEPOINT|SCROLL|SEARCH|SENSITIVE|SESSION_USER|SPECIFIC|SPECIFICTYPE|SQL|| |SCROLL|SEARCH|SENSITIVE|SESSION_USER|SPECIFIC|SPECIFICTYPE|SQL|START||
|START|STATIC|SUBMULTILIST|SYMETRIC|SYSTEM|SYSTEM_USER|TIMEZONE_HOUR|TIMEZONE_MINUTE|| |STATIC|SUBMULTILIST|SYMETRIC|SYSTEM|SYSTEM_USER|TIMEZONE_HOUR|TIMEZONE_MINUTE|TRANSLATION||
|TRANSLATION|TREAT|VALUE|VARYING|WHENEVER|WINDOW|WITHIN|XMLBINARY|| |TREAT|VALUE|VARYING|WHENEVER|WINDOW|WITHIN|XMLBINARY|XMLCAST||
|XMLCAST|XMLDOCUMENT|XMLEXISTS|XMLITERATE|XMLTEXT|XMLVALIDATE||

h2. {anchor:header_t}Tokens
...
|{anchor:token_ALL_IN_GROUP}_all in group identifier_|<[identifier|#token_ID]> <[period|#token_PERIOD]> <[star|#token_STAR]>|[all in group |#allInGroupSymbol]||
|{anchor:token_BINARYSTRINGVAL}_binary string literal_|"X" \| "x" "\'" (<[hexit|#token_HEXIT]> <[hexit|#token_HEXIT]>)+ "\'"|[non numeric literal|#nonNumericLiteral]||
|{anchor:token_COLON}_colon_|":"|[statement|#statement]|| |{anchor:token_COLON}_colon_|":"|[make dep options|#makedepOptions], [statement|#statement]||
|{anchor:token_COMMA}_comma_|","|[alter options list|#alterOptionsList], [column list|#columnList], [create procedure|#createDDLProcedure], [typed element list|#createElementsWithTypes]
[create table body|#createTableBody], [create temporary table|#createTempTable], [derived column list|#derivedColumnList], [sql exception|#exception]
...
[create table body|#createTableBody], [create temporary table|#createTempTable], [filter clause|#filterClause], [function|#function]
[if statement|#ifStatement], [insert statement|#insert], [json object|#jsonObject], [loop statement|#loopStatement]
[make dep options|#makedepOptions], [object table|#objectTable], [options clause|#optionsClause], [ordered aggreate function|#orderedAgg], [data type|#parseDataType]
[data type|#parseDataType], [query primary|#queryPrimary], [querystring function|#queryString], [in predicate|#setCrit], [call statement|#storedProcedure]
[subquery|#subquery], [table subquery|#subqueryFromClause], [table primary|#tablePrimary], [text aggreate function|#textAgg]
[call statement|#storedProcedure], [subquery|#subquery], [table subquery|#subqueryFromClause], [table primary|#tablePrimary]
[text aggreate function|#textAgg], [text table|#textTable], [unsigned value expression primary|#unsignedValueExpressionPrimary], [while statement|#whileStatement], [window specification|#windowSpecification]
[window specification|#windowSpecification], [with list element|#withListElement], [xml attributes|#xmlAttributes], [xml element|#xmlElement], [xml forest|#xmlForest]
[xml forest|#xmlForest], [xml namespaces|#xmlNamespaces], [xml parse|#xmlParse], [xml query|#xmlQuery], [xml serialize|#xmlSerialize]
[xml serialize|#xmlSerialize], [xml table|#xmlTable]||
|{anchor:token_LSBRACE}_lsbrace_|"\["|[unsigned value expression primary|#unsignedValueExpressionPrimary]||
|{anchor:token_LT}_lt_|"<"|[comparison operator|#operator]||
...
|{anchor:token_PERIOD}_period_|"."|||
|{anchor:token_PLUS}_plus_|"\+"|[plus or minus|#plusMinus]||
|{anchor:token_QMARK}_qmark_|"?"|[callable statement|#callableStatement], [integer parameter|#intParam], [unsigned value expression primary|#unsignedValueExpressionPrimary]||
|{anchor:token_QUOTED_ID}_quoted_id_|<[id_part|#token_ID_PART]> \| "\"" ("\"\"" \| ~\["\""\])+ "\""|||
|{anchor:token_RBRACE}_rbrace_|"\}"|[callable statement|#callableStatement], [match predicate|#matchCrit], [non numeric literal|#nonNumericLiteral], [table reference|#tableReference]
...
[create table body|#createTableBody], [create temporary table|#createTempTable], [filter clause|#filterClause], [function|#function]
[if statement|#ifStatement], [insert statement|#insert], [json object|#jsonObject], [loop statement|#loopStatement]
[make dep options|#makedepOptions], [object table|#objectTable], [options clause|#optionsClause], [ordered aggreate function|#orderedAgg], [data type|#parseDataType]
[data type|#parseDataType], [query primary|#queryPrimary], [querystring function|#queryString], [in predicate|#setCrit], [call statement|#storedProcedure]
[subquery|#subquery], [table subquery|#subqueryFromClause], [table primary|#tablePrimary], [text aggreate function|#textAgg]
[call statement|#storedProcedure], [subquery|#subquery], [table subquery|#subqueryFromClause], [table primary|#tablePrimary]
[text aggreate function|#textAgg], [text table|#textTable], [unsigned value expression primary|#unsignedValueExpressionPrimary], [while statement|#whileStatement], [window specification|#windowSpecification]
[window specification|#windowSpecification], [with list element|#withListElement], [xml attributes|#xmlAttributes], [xml element|#xmlElement], [xml forest|#xmlForest]
[xml forest|#xmlForest], [xml namespaces|#xmlNamespaces], [xml parse|#xmlParse], [xml query|#xmlQuery], [xml serialize|#xmlSerialize]
[xml serialize|#xmlSerialize], [xml table|#xmlTable]||
|{anchor:token_RSBRACE}_rsbrace_|"\]"|[unsigned value expression primary|#unsignedValueExpressionPrimary]||
|{anchor:token_SEMICOLON}_semicolon_|";"|[ddl statement|#ddlStmt], [delimited statement|#delimitedStatement]||
...
|{anchor:usage_insert}_[insert statement|#insert]_|[assignment statement operand|#assignStatementOperand], [directly executable statement|#userCommand]||
|{anchor:usage_intParam}_[integer parameter|#intParam]_|[fetch clause|#fetchLimit], [limit clause|#limit]||
|{anchor:usage_intVal}_[unsigned integer|#intVal]_|[dynamic data statement|#dynamicCommand], [integer parameter|#intParam], [make dep options|#makedepOptions], [data type|#parseDataType], [text table column|#textColumn]
[text table column|#textColumn], [text table|#textTable], [unsigned value expression primary|#unsignedValueExpressionPrimary]||
|{anchor:usage_intervalType}_[time interval|#intervalType]_|[function|#function]||
|{anchor:usage_into}_[into clause|#into]_|[query|#query]||
...
|{anchor:usage_limit}_[limit clause|#limit]_|[query expression body|#queryExpressionBody]||
|{anchor:usage_loopStatement}_[loop statement|#loopStatement]_|[statement|#statement]||
|{anchor:usage_makedepOptions}_[make dep options|#makedepOptions]_|[option clause|#option], [table primary|#tablePrimary]||
|{anchor:usage_matchCrit}_[match predicate|#matchCrit]_|[boolean primary|#booleanPrimary]||
|{anchor:usage_namespaceItem}_[xml namespace element|#namespaceItem]_|[xml namespaces|#xmlNamespaces]||
...
[call statement|#storedProcedure], [update statement|#update]||
|{anchor:usage_optionPair}_[option pair|#optionPair]_|[add set option|#addSetOption], [options clause|#optionsClause]||
|{anchor:usage_optionsClause}_[options clause|#optionsClause]_|[table element|#createColumn], [create procedure|#createDDLProcedure], [create table|#createTable], [create table body|#createTableBody], [procedure parameter|#procedureParameter]
[procedure parameter|#procedureParameter], [procedure result column|#procedureRsColumn]||
|{anchor:usage_orderby}_[order by clause|#orderby]_|[function|#function], [ordered aggreate function|#orderedAgg], [query expression body|#queryExpressionBody], [text aggreate function|#textAgg]
[window specification|#windowSpecification]||
...
|{anchor:usage_unaryFromClause}_[table name|#unaryFromClause]_|[table primary|#tablePrimary]||
|{anchor:usage_unsignedNumericLiteral}_[unsigned numeric literal|#unsignedNumericLiteral]_|[option pair|#optionPair], [value expression primary|#valueExpressionPrimary]||
|{anchor:usage_unsignedValueExpressionPrimary}_[unsigned value expression primary|#unsignedValueExpressionPrimary]_|[integer parameter|#intParam], [value expression primary|#valueExpressionPrimary]||
|{anchor:usage_update}_[update statement|#update]_|[assignment statement operand|#assignStatementOperand], [directly executable statement|#userCommand]||
|{anchor:usage_userCommand}_[directly executable statement|#userCommand]_|[data statement|#sqlStatement]||
...

h3. {anchor:createTempTable}_[create temporary table|#usage_createTempTable]_ ::=
- |[CREATE|#token_CREATE] ( [LOCAL|#token_LOCAL] )? [TEMPORARY|#token_TEMPORARY] [TABLE|#token_TABLE] <[identifier|#id]> <[lparen|#token_LPAREN]> <[temporary table element|#tableElement]> ( <[comma|#token_COMMA]> <[temporary table element|#tableElement]> )\* ( <[comma|#token_COMMA]> [PRIMARY|#token_PRIMARY] [KEY|#token_KEY] <[column list|#columnList]> )? <[rparen|#token_RPAREN]>||

Creates a temporary table.
...

h3. {anchor:tablePrimary}_[table primary|#usage_tablePrimary]_ ::=
- |( <[text table|#textTable]> \| <[array table|#arrayTable]> \| <[xml table|#xmlTable]> \| <[object table|#objectTable]> \| <[table name|#unaryFromClause]> \| <[table subquery|#subqueryFromClause]> \| ( <[lparen|#token_LPAREN]> <[joined table|#joinedTable]> <[rparen|#token_RPAREN]> ) ) ( ( [MAKEDEP|#token_MAKEDEP] <[make dep options|#makedepOptions]> ) \| [MAKENOTDEP|#token_MAKENOTDEP] )?||

A single source of rows.
...
----

h3. {anchor:makedepOptions}_[make dep options|#usage_makedepOptions]_ ::=
- |( <[lparen|#token_LPAREN]> ( [MAX|#token_MAX] <[colon|#token_COLON]> <[unsigned integer|#intVal]> )? ( [JOIN|#token_JOIN] )? <[rparen|#token_RPAREN]> )?||

options for the make dep hint


Example:
{code:sql}(min:10000){code}


----

h3. {anchor:xmlSerialize}_[xml serialize|#usage_xmlSerialize]_ ::=
- |[XMLSERIALIZE|#token_XMLSERIALIZE] <[lparen|#token_LPAREN]> ( [DOCUMENT|#token_DOCUMENT] \| [CONTENT|#token_CONTENT] )? <[expression|#expression]> ( [AS|#token_AS] ( [STRING|#token_STRING] \| [VARCHAR|#token_VARCHAR] \| [CLOB|#token_CLOB] \| [VARBINARY|#token_VARBINARY] \| [BLOB|#token_BLOB] ) )? ( [ENCODING|#token_ENCODING] <[identifier|#id]> )? ( [VERSION|#token_VERSION] <[string|#stringVal]> )? ( ( [INCLUDING|#token_INCLUDING] \| [EXCLUDING|#token_EXCLUDING] ) [XMLDECLARATION|#token_XMLDECLARATION] )? <[rparen|#token_RPAREN]>||
...
h3. {anchor:intParam}_[integer parameter|#usage_intParam]_ ::=
- |<[unsigned integer|#intVal]>||
- |<[qmark|#token_QMARK]>||
- |<[unsigned value expression primary|#unsignedValueExpressionPrimary]>||

A literal integer or parameter reference to an integer.
...

h3. {anchor:option}_[option clause|#usage_option]_ ::=
- |[OPTION|#token_OPTION] ( [MAKEDEP|#token_MAKEDEP] <[identifier|#id]> <[make dep options|#makedepOptions]> ( <[comma|#token_COMMA]> <[identifier|#id]> <[make dep options|#makedepOptions]> )\* \| [MAKENOTDEP|#token_MAKENOTDEP] <[identifier|#id]> ( <[comma|#token_COMMA]> <[identifier|#id]> )\* \| [NOCACHE|#token_NOCACHE] ( <[identifier|#id]> ( <[comma|#token_COMMA]> <[identifier|#id]> )\* )? )\*||

Specifies query options.
...
- |[TIME|#token_TIME]||
- |[TIMESTAMP|#token_TIMESTAMP]||
- |[OBJECT|#token_OBJECT]||
- |( [OBJECT|#token_OBJECT] ( <[lparen|#token_LPAREN]> <[unsigned integer|#intVal]> <[rparen|#token_RPAREN]> )? )||
- |( [BLOB|#token_BLOB] ( <[lparen|#token_LPAREN]> <[unsigned integer|#intVal]> <[rparen|#token_RPAREN]> )? )||
- |( [CLOB|#token_CLOB] ( <[lparen|#token_LPAREN]> <[unsigned integer|#intVal]> <[rparen|#token_RPAREN]> )? )||
...

h3. {anchor:createTable}_[create table|#usage_createTable]_ ::=
- |[CREATE|#token_CREATE] ( ( [FOREIGN|#token_FOREIGN] [TABLE|#token_TABLE] ) \| ( ( [VIRTUAL|#token_VIRTUAL] )? [VIEW|#token_VIEW] ) \| ( [GLOBAL|#token_GLOBAL] [TEMPORARY|#token_TEMPORARY] [TABLE|#token_TABLE] ) ) <[identifier|#id]> ( <[create table body|#createTableBody]> \| ( <[options clause|#optionsClause]> )? ) ( [AS|#token_AS] <[query expression|#queryExpression]> )?||

Defines a table or view.
...

h3. {anchor:createForeignTempTable}_[create foreign temp table|#usage_createForeignTempTable]_ ::=
- |[CREATE|#token_CREATE] ( [LOCAL|#token_LOCAL] )? [FOREIGN|#token_FOREIGN] [TEMPORARY|#token_TEMPORARY] [TABLE|#token_TABLE] <[identifier|#id]> <[create table body|#createTableBody]> [ON|#token_ON] <[identifier|#id]>||

Defines a foreign temp table
...

h3. {anchor:createTableBody}_[create table body|#usage_createTableBody]_ ::=
- |( <[lparen|#token_LPAREN]> <[table element|#createColumn]> ( <[comma|#token_COMMA]> <[table element|#createColumn]> )\* ( <[comma|#token_COMMA]> ( [CONSTRAINT|#token_CONSTRAINT] <[identifier|#id]> )? ( <[primary key|#primaryKey]> \| <[other constraints|#constraint]> \| <[foreign key|#foreignKey]> ) ( <[options clause|#optionsClause]> )? )\* <[rparen|#token_RPAREN]> )? ( <[options clause|#optionsClause]> )?||

Defines a table.
...

h3. {anchor:createColumn}_[table element|#usage_createColumn]_ ::=
- |<[identifier|#id]> <[data type|#parseDataType]> ( [NOT|#token_NOT] [NULL|#token_NULL] )? ( [UNIQUE|#token_UNIQUE] \| ( [INDEX|#token_INDEX] \| [AUTO_INCREMENT|#token_AUTO_INCREMENT] )\+ \| ( [PRIMARY|#token_PRIMARY] [KEY|#token_KEY] ) )? ( [DEFAULT|#token_DEFAULT_KEYWORD] <[string|#stringVal]> )? ( <[options clause|#optionsClause]> )?||
- |<[identifier|#id]> ( [SERIAL|#token_SERIAL] \| ( <[data type|#parseDataType]> ( [NOT|#token_NOT] [NULL|#token_NULL] )? ( [AUTO_INCREMENT|#token_AUTO_INCREMENT] )? ) ) ( ( [PRIMARY|#token_PRIMARY] [KEY|#token_KEY] ) \| ( ( [UNIQUE|#token_UNIQUE] )? ( [INDEX|#token_INDEX] )? ) ) ( [DEFAULT|#token_DEFAULT_KEYWORD] <[string|#stringVal]> )? ( <[options clause|#optionsClause]> )?||

Defines a table column.
...

Full Content

  • Main Entry Points
    • callable statement
    • ddl statement
    • procedure body definition
    • directly executable statement
  • Reserved Keywords
  • Non-Reserved Keywords
  • Reserved Keywords For Future Use
  • Tokens
  • Production Cross-Reference
  • Productions

Reserved Keywords

Keyword Usage
ADD add set option
ALL standard aggregate function, function, query expression body, query term
select clause, quantified comparison predicate
ALTER alter, alter column options, alter options
AND between predicate, boolean term
ANY standard aggregate function, quantified comparison predicate
ARRAY_AGG ordered aggreate function
AS alter, array table, create procedure, option namespace
create table, create trigger, derived column, dynamic data statement
function, loop statement, xml namespace element, object table
select derived column, table subquery, text table, table name
with list element, xml serialize, xml table
ASC sort specification
ATOMIC compound statement, for each row trigger action
BEGIN compound statement, for each row trigger action
BETWEEN between predicate
BIGDECIMAL data type
BIGINT data type
BIGINTEGER data type
BLOB data type, xml serialize
BOOLEAN data type
BOTH function
BREAK branching statement
BY group by clause, order by clause, window specification
BYTE data type
CALL callable statement, call statement
CASE case expression, searched case expression
CAST function
CHAR function, data type
CLOB data type, xml serialize
COLUMN alter column options
CONSTRAINT create table body
CONTINUE branching statement
CONVERT function
CREATE create procedure, create foreign temp table, create table, create temporary table
create trigger, procedure body definition
CROSS cross join
DATE data type
DAY function
DECIMAL data type
DECLARE declare statement
DEFAULT table element, xml namespace element, object table column, procedure parameter
xml table column
DELETE alter, create trigger, delete statement
DESC sort specification
DISTINCT standard aggregate function, function, query expression body, query term
select clause
DOUBLE data type
DROP drop option, drop table
EACH for each row trigger action
ELSE case expression, if statement, searched case expression
END case expression, compound statement, for each row trigger action, searched case expression
ERROR raise error statement
ESCAPE match predicate, text table
EXCEPT query expression body
EXEC dynamic data statement, call statement
EXECUTE dynamic data statement, call statement
EXISTS exists predicate
FALSE non numeric literal
FETCH fetch clause
FILTER filter clause
FLOAT data type
FOR for each row trigger action, function, text aggreate function, xml table column
FOREIGN alter options, create procedure, create foreign temp table, create table
foreign key
FROM delete statement, from clause, function
FULL qualified table
FUNCTION create procedure
GLOBAL create table
GROUP group by clause
HAVING having clause
HOUR function
IF if statement
IMMEDIATE dynamic data statement
IN procedure parameter, in predicate
INNER qualified table
INOUT procedure parameter
INSERT alter, create trigger, function, insert statement
INTEGER data type
INTERSECT query term
INTO dynamic data statement, insert statement, into clause
IS is null predicate
JOIN cross join, make dep options, qualified table
LANGUAGE object table
LATERAL table subquery
LEADING function
LEAVE branching statement
LEFT function, qualified table
LIKE match predicate
LIKE_REGEX like regex predicate
LIMIT limit clause
LOCAL create foreign temp table, create temporary table
LONG data type
LOOP loop statement
MAKEDEP option clause, table primary
MAKENOTDEP option clause, table primary
MERGE insert statement
MINUTE function
MONTH function
NO xml namespace element, text table column, text table
NOCACHE option clause
NOT between predicate, compound statement, table element, is null predicate
match predicate, boolean factor, procedure parameter, procedure result column
like regex predicate, in predicate, temporary table element
NULL table element, is null predicate, non numeric literal, procedure parameter
procedure result column, temporary table element, xml query
OBJECT data type
OF alter, create trigger
OFFSET limit clause
ON alter, create foreign temp table, create trigger, loop statement
qualified table, xml query
ONLY fetch clause
OPTION option clause
OPTIONS alter options list, options clause
OR boolean value expression
ORDER order by clause
OUT procedure parameter
OUTER qualified table
OVER window specification
PARAMETER alter column options
PARTITION window specification
PRIMARY table element, create temporary table, primary key
PROCEDURE alter, alter options, create procedure, procedure body definition
REAL data type
REFERENCES foreign key
RETURN assignment statement, return statement, data statement
RETURNS create procedure
RIGHT function, qualified table
ROW fetch clause, for each row trigger action, limit clause, text table
ROWS fetch clause, limit clause
SECOND function
SELECT select clause
SET add set option, option namespace, update statement
SHORT data type
SIMILAR match predicate
SMALLINT data type
SOME standard aggregate function, quantified comparison predicate
SQLEXCEPTION sql exception
SQLSTATE sql exception
SQLWARNING raise statement
STRING dynamic data statement, data type, xml serialize
TABLE alter options, create procedure, create foreign temp table, create table
create temporary table, drop table, query primary, table subquery
TEMPORARY create foreign temp table, create table, create temporary table
THEN case expression, searched case expression
TIME data type
TIMESTAMP data type
TINYINT data type
TO match predicate
TRAILING function
TRANSLATE function
TRIGGER alter, create trigger
TRUE non numeric literal
UNION cross join, query expression body
UNIQUE other constraints, table element
UNKNOWN non numeric literal
UPDATE alter, create trigger, dynamic data statement, update statement
USER function
USING dynamic data statement
VALUES insert statement
VARBINARY data type, xml serialize
VARCHAR data type, xml serialize
VIRTUAL alter options, create procedure, create table, procedure body definition
WHEN case expression, searched case expression
WHERE filter clause, where clause
WHILE while statement
WITH assignment statement, query expression, data statement
WITHOUT assignment statement, data statement
XML data type
XMLAGG ordered aggreate function
XMLATTRIBUTES xml attributes
XMLCOMMENT function
XMLCONCAT function
XMLELEMENT xml element
XMLFOREST xml forest
XMLNAMESPACES xml namespaces
XMLPARSE xml parse
XMLPI function
XMLQUERY xml query
XMLSERIALIZE xml serialize
XMLTABLE xml table
YEAR function

Non-Reserved Keywords

Keyword Usage
ACCESSPATTERN other constraints, non-reserved identifier
ARRAYTABLE array table, non-reserved identifier
AUTO_INCREMENT table element, non-reserved identifier
AVG standard aggregate function, non-reserved identifier
CHAIN sql exception, non-reserved identifier
COLUMNS array table, non-reserved identifier, object table, text table
xml table
CONTENT non-reserved identifier, xml parse, xml serialize
COUNT standard aggregate function, non-reserved identifier
DELIMITER non-reserved identifier, text aggreate function, text table
DENSE_RANK analytic aggregate function, non-reserved identifier
DISABLED alter, non-reserved identifier
DOCUMENT non-reserved identifier, xml parse, xml serialize
EMPTY non-reserved identifier, xml query
ENABLED alter, non-reserved identifier
ENCODING non-reserved identifier, text aggreate function, xml serialize
EVERY standard aggregate function, non-reserved identifier
EXCEPTION compound statement, declare statement, non-reserved identifier
EXCLUDING non-reserved identifier, xml serialize
EXTRACT function, non-reserved identifier
FIRST fetch clause, non-reserved identifier, sort specification
HEADER non-reserved identifier, text aggreate function, text table
INCLUDING non-reserved identifier, xml serialize
INDEX other constraints, table element, non-reserved identifier
INSTEAD alter, create trigger, non-reserved identifier
JSONARRAY_AGG non-reserved identifier, ordered aggreate function
JSONOBJECT json object, non-reserved identifier
KEY table element, create temporary table, foreign key, non-reserved identifier
primary key
LAST non-reserved identifier, sort specification
MAX standard aggregate function, make dep options, non-reserved identifier
MIN standard aggregate function, non-reserved identifier
NAME function, non-reserved identifier, xml element
NAMESPACE option namespace, non-reserved identifier
NEXT fetch clause, non-reserved identifier
NULLS non-reserved identifier, sort specification
OBJECTTABLE non-reserved identifier, object table
ORDINALITY non-reserved identifier, xml table column
PASSING non-reserved identifier, object table, xml query, xml table
PATH non-reserved identifier, xml table column
QUERYSTRING non-reserved identifier, querystring function
QUOTE non-reserved identifier, text aggreate function, text table
RAISE non-reserved identifier, raise statement
RANK analytic aggregate function, non-reserved identifier
RESULT non-reserved identifier, procedure parameter
ROW_NUMBER analytic aggregate function, non-reserved identifier
SELECTOR non-reserved identifier, text table column, text table
SERIAL table element, non-reserved identifier, temporary table element
SKIP non-reserved identifier, text table
SQL_TSI_DAY time interval, non-reserved identifier
SQL_TSI_FRAC_SECOND time interval, non-reserved identifier
SQL_TSI_HOUR time interval, non-reserved identifier
SQL_TSI_MINUTE time interval, non-reserved identifier
SQL_TSI_MONTH time interval, non-reserved identifier
SQL_TSI_QUARTER time interval, non-reserved identifier
SQL_TSI_SECOND time interval, non-reserved identifier
SQL_TSI_WEEK time interval, non-reserved identifier
SQL_TSI_YEAR time interval, non-reserved identifier
STDDEV_POP standard aggregate function, non-reserved identifier
STDDEV_SAMP standard aggregate function, non-reserved identifier
SUBSTRING function, non-reserved identifier
SUM standard aggregate function, non-reserved identifier
TEXTAGG non-reserved identifier, text aggreate function
TEXTTABLE non-reserved identifier, text table
TIMESTAMPADD function, non-reserved identifier
TIMESTAMPDIFF function, non-reserved identifier
TO_BYTES function, non-reserved identifier
TO_CHARS function, non-reserved identifier
TRIM function, non-reserved identifier, text table column
VARIADIC non-reserved identifier, procedure parameter
VAR_POP standard aggregate function, non-reserved identifier
VAR_SAMP standard aggregate function, non-reserved identifier
VERSION non-reserved identifier, xml serialize
VIEW alter, alter options, create table, non-reserved identifier
WELLFORMED non-reserved identifier, xml parse
WIDTH non-reserved identifier, text table column
XMLDECLARATION non-reserved identifier, xml serialize

Reserved Keywords For Future Use

ALLOCATE ARE ARRAY ASENSITIVE ASYMETRIC AUTHORIZATION BINARY CALLED
CASCADED CHARACTER CHECK CLOSE COLLATE COMMIT CONNECT CORRESPONDING
CRITERIA CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE DATALINK
DEALLOCATE DEC DEREF DESCRIBE DETERMINISTIC DISCONNECT DLNEWCOPY DLPREVIOUSCOPY
DLURLCOMPLETE DLURLCOMPLETEONLY DLURLCOMPLETEWRITE DLURLPATH DLURLPATHONLY DLURLPATHWRITE DLURLSCHEME DLURLSERVER
DLVALUE DYNAMIC ELEMENT EXTERNAL FREE GET GRANT HAS
HOLD IDENTITY IMPORT INDICATOR INPUT INSENSITIVE INT INTERVAL
ISOLATION LARGE LOCALTIME LOCALTIMESTAMP MATCH MEMBER METHOD MODIFIES
MODULE MULTISET NATIONAL NATURAL NCHAR NCLOB NEW NONE
NUMERIC OLD OPEN OUTPUT OVERLAPS PRECISION PREPARE RANGE
READS RECURSIVE REFERENCING RELEASE REVOKE ROLLBACK ROLLUP SAVEPOINT
SCROLL SEARCH SENSITIVE SESSION_USER SPECIFIC SPECIFICTYPE SQL START
STATIC SUBMULTILIST SYMETRIC SYSTEM SYSTEM_USER TIMEZONE_HOUR TIMEZONE_MINUTE TRANSLATION
TREAT VALUE VARYING WHENEVER WINDOW WITHIN XMLBINARY XMLCAST
XMLDOCUMENT XMLEXISTS XMLITERATE XMLTEXT XMLVALIDATE

Tokens

Name Definition Usage
all in group identifier <identifier> <period> <star> all in group
binary string literal "X" | "x" "\'" (<hexit> <hexit>)+ "\'" non numeric literal
colon ":" make dep options, statement
comma "," alter options list, column list, create procedure, typed element list
create table body, create temporary table, derived column list, sql exception
named parameter list, expression list, from clause, function
limit clause, object table, option clause, options clause
order by clause, data type, query expression, querystring function
select clause, set clause list, in predicate, text aggreate function
text table, xml attributes, xml element, xml forest
xml namespaces, xml query, xml table
concat_op "||" common value expression
decimal numeric literal (<digit>)* <period> <unsigned integer literal> unsigned numeric literal
digit ["0"-"9"]
dollar "$" unsigned value expression primary
eq "=" assignment statement, callable statement, declare statement, named parameter list
comparison operator, set clause list
escaped function "{" "fn" unsigned value expression primary
escaped join "{" "oj" table reference
escaped type "{" ("d" | "t" | "ts" | "b") non numeric literal
approximate numeric literal <digit> <period> <unsigned integer literal> ["e","E"] (<plus> | <minus>)? <unsigned integer literal> unsigned numeric literal
ge ">=" comparison operator
gt ">" named parameter list, comparison operator
hexit ["a"-"f","A"-"F"] | <digit>
identifier <quoted_id> (<period> <quoted_id>)* identifier, unsigned value expression primary
id_part ("@" | "#" | <letter>) (<letter> | "_" | <digit>)*
lbrace "{" callable statement, match predicate
le "<=" comparison operator
letter ["a"-"z","A"-"Z"] | ["\u0153"-"\ufffd"]
lparen "(" standard aggregate function, alter options list, analytic aggregate function, array table
callable statement, column list, other constraints, create procedure
create table body, create temporary table, filter clause, function
if statement, insert statement, json object, loop statement
make dep options, object table, options clause, ordered aggreate function
data type, query primary, querystring function, in predicate
call statement, subquery, table subquery, table primary
text aggreate function, text table, unsigned value expression primary, while statement
window specification, with list element, xml attributes, xml element
xml forest, xml namespaces, xml parse, xml query
xml serialize, xml table
lsbrace "[" unsigned value expression primary
lt "<" comparison operator
minus "-" plus or minus
ne "<>" comparison operator
ne2 "!=" comparison operator
period "."
plus "+" plus or minus
qmark "?" callable statement, unsigned value expression primary
quoted_id <id_part> | "\"" ("\"\"" | ~["\""])+ "\""
rbrace "}" callable statement, match predicate, non numeric literal, table reference
unsigned value expression primary
rparen ")" standard aggregate function, alter options list, analytic aggregate function, array table
callable statement, column list, other constraints, create procedure
create table body, create temporary table, filter clause, function
if statement, insert statement, json object, loop statement
make dep options, object table, options clause, ordered aggreate function
data type, query primary, querystring function, in predicate
call statement, subquery, table subquery, table primary
text aggreate function, text table, unsigned value expression primary, while statement
window specification, with list element, xml attributes, xml element
xml forest, xml namespaces, xml parse, xml query
xml serialize, xml table
rsbrace "]" unsigned value expression primary
semicolon ";" ddl statement, delimited statement
slash "/" star or slash
star "*" standard aggregate function, dynamic data statement, select clause, star or slash
string literal ("N" | "E")? "\'" ("\'\'" | ~["\'"])* "\'" string
unsigned integer literal (<digit>)+ unsigned integer, unsigned numeric literal

Production Cross-Reference

Name Usage
add set option alter options list
standard aggregate function unsigned value expression primary
all in group select sublist
alter directly executable statement
alter column options alter options
alter options list alter column options, alter options
alter options ddl statement
analytic aggregate function unsigned value expression primary
array table table primary
assignment statement delimited statement
assignment statement operand assignment statement, declare statement
between predicate boolean primary
boolean primary filter clause, boolean factor
branching statement delimited statement
case expression unsigned value expression primary
character match predicate, text aggreate function, text table
column list other constraints, create temporary table, foreign key, insert statement
primary key, with list element
common value expression between predicate, boolean primary, comparison predicate, sql exception
match predicate, like regex predicate, in predicate, text table
unsigned value expression primary
comparison predicate boolean primary
boolean term boolean value expression
boolean value expression condition
compound statement statement
other constraints create table body
table element create table body
create procedure ddl statement
typed element list array table, dynamic data statement
create foreign temp table directly executable statement
option namespace ddl statement
create table ddl statement
create table body create foreign temp table, create table
create temporary table directly executable statement
create trigger ddl statement, directly executable statement
condition expression, having clause, if statement, qualified table
searched case expression, where clause, while statement
cross join joined table
declare statement delimited statement
delete statement assignment statement operand, directly executable statement
delimited statement statement
derived column derived column list, object table, querystring function, text aggreate function
xml attributes, xml query, xml table
derived column list json object, xml forest
drop option alter options list
drop table directly executable statement
dynamic data statement data statement
raise error statement delimited statement
sql exception assignment statement operand, exception reference
exception reference sql exception, raise statement
named parameter list call statement
exists predicate boolean primary
expression standard aggregate function, assignment statement operand, case expression, derived column
dynamic data statement, raise error statement, named parameter list, expression list
function, object table column, ordered aggreate function, querystring function
return statement, searched case expression, select derived column, set clause list
sort key, unsigned value expression primary, xml table column, xml element
xml parse, xml serialize
expression list callable statement, other constraints, function, group by clause
insert statement, call statement, window specification
fetch clause limit clause
filter clause function, unsigned value expression primary
for each row trigger action alter, create trigger
foreign key create table body
from clause query
function unsigned value expression primary
group by clause query
having clause query
identifier alter, alter column options, alter options, array table
assignment statement, branching statement, callable statement, column list
compound statement, table element, create procedure, typed element list
create foreign temp table, option namespace, create table, create table body
create temporary table, create trigger, declare statement, delete statement
derived column, drop option, drop table, dynamic data statement
exception reference, named parameter list, foreign key, function
insert statement, into clause, loop statement, xml namespace element
object table column, object table, option clause, option pair
procedure parameter, procedure result column, query primary, select derived column
set clause list, statement, call statement, table subquery
temporary table element, text aggreate function, text table column, text table
table name, update statement, with list element, xml table column
xml element, xml serialize, xml table
if statement statement
insert statement assignment statement operand, directly executable statement
integer parameter fetch clause, limit clause
unsigned integer dynamic data statement, integer parameter, make dep options, data type
text table column, text table, unsigned value expression primary
time interval function
into clause query
is null predicate boolean primary
joined table table primary, table reference
json object function
limit clause query expression body
loop statement statement
make dep options option clause, table primary
match predicate boolean primary
xml namespace element xml namespaces
non numeric literal option pair, value expression primary
non-reserved identifier identifier, unsigned value expression primary
boolean factor boolean term
object table column object table
object table table primary
comparison operator comparison predicate, quantified comparison predicate
option clause callable statement, delete statement, insert statement, query expression body
call statement, update statement
option pair add set option, options clause
options clause table element, create procedure, create table, create table body
procedure parameter, procedure result column
order by clause function, ordered aggreate function, query expression body, text aggreate function
window specification
ordered aggreate function unsigned value expression primary
data type table element, create procedure, typed element list, declare statement
function, object table column, procedure parameter, procedure result column
temporary table element, text table column, xml table column
numeric value expression common value expression
plus or minus option pair, numeric value expression, value expression primary
primary key create table body
procedure parameter create procedure
procedure result column create procedure
qualified table joined table
query query primary
query expression alter, assignment statement operand, create table, insert statement
loop statement, subquery, table subquery, directly executable statement
with list element
query expression body query expression, query primary
query primary query term
querystring function function
query term query expression body
raise statement delimited statement
like regex predicate boolean primary
return statement delimited statement
searched case expression unsigned value expression primary
select clause query
select derived column select sublist
select sublist select clause
set clause list dynamic data statement, update statement
in predicate boolean primary
sort key sort specification
sort specification order by clause
data statement delimited statement
statement alter, compound statement, create procedure, for each row trigger action
if statement, loop statement, procedure body definition, while statement
call statement assignment statement, subquery, table subquery, directly executable statement
string character, table element, option namespace, function
xml namespace element, non numeric literal, object table column, object table
procedure parameter, text table column, text table, xml table column
xml query, xml serialize, xml table
subquery exists predicate, in predicate, quantified comparison predicate, unsigned value expression primary
quantified comparison predicate boolean primary
table subquery table primary
temporary table element create temporary table
table primary cross join, joined table
table reference from clause, qualified table
text aggreate function unsigned value expression primary
text table column text table
text table table primary
term numeric value expression
star or slash term
table name table primary
unsigned numeric literal option pair, value expression primary
unsigned value expression primary integer parameter, value expression primary
update statement assignment statement operand, directly executable statement
directly executable statement data statement
value expression primary array table, term
where clause delete statement, query, update statement
while statement statement
window specification unsigned value expression primary
with list element query expression
xml attributes xml element
xml table column xml table
xml element function
xml forest function
xml namespaces xml element, xml forest, xml query, xml table
xml parse function
xml query function
xml serialize function
xml table table primary

Productions

string ::=

  • <string literal>

A string literal value. Use '' to escape ' in the string.

Example:

'a string'
'it''s a string'

non-reserved identifier ::=

  • INSTEAD
  • VIEW
  • ENABLED
  • DISABLED
  • KEY
  • SERIAL
  • TEXTAGG
  • COUNT
  • ROW_NUMBER
  • RANK
  • DENSE_RANK
  • SUM
  • AVG
  • MIN
  • MAX
  • EVERY
  • STDDEV_POP
  • STDDEV_SAMP
  • VAR_SAMP
  • VAR_POP
  • DOCUMENT
  • CONTENT
  • TRIM
  • EMPTY
  • ORDINALITY
  • PATH
  • FIRST
  • LAST
  • NEXT
  • SUBSTRING
  • EXTRACT
  • TO_CHARS
  • TO_BYTES
  • TIMESTAMPADD
  • TIMESTAMPDIFF
  • QUERYSTRING
  • NAMESPACE
  • RESULT
  • INDEX
  • ACCESSPATTERN
  • AUTO_INCREMENT
  • WELLFORMED
  • SQL_TSI_FRAC_SECOND
  • SQL_TSI_SECOND
  • SQL_TSI_MINUTE
  • SQL_TSI_HOUR
  • SQL_TSI_DAY
  • SQL_TSI_WEEK
  • SQL_TSI_MONTH
  • SQL_TSI_QUARTER
  • SQL_TSI_YEAR
  • TEXTTABLE
  • ARRAYTABLE
  • SELECTOR
  • SKIP
  • WIDTH
  • PASSING
  • NAME
  • ENCODING
  • COLUMNS
  • DELIMITER
  • QUOTE
  • HEADER
  • NULLS
  • OBJECTTABLE
  • VERSION
  • INCLUDING
  • EXCLUDING
  • XMLDECLARATION
  • VARIADIC
  • RAISE
  • EXCEPTION
  • CHAIN
  • JSONARRAY_AGG
  • JSONOBJECT

Allows non-reserved keywords to be parsed as identifiers

Example:
SELECT COUNT FROM ...


identifier ::=

  • <identifier>
  • <non-reserved identifier>

Partial or full name of a single entity.

Example:

tbl.col
"tbl"."col"

create trigger ::=

  • CREATE TRIGGER ON <identifier> INSTEAD OF ( INSERT | UPDATE | DELETE ) AS <for each row trigger action>

Creates a trigger action on the given target.

Example:

CREATE TRIGGER ON vw INSTEAD OF INSERT AS FOR EACH ROW BEGIN ATOMIC ... END

alter ::=

  • ALTER ( ( VIEW <identifier> AS <query expression> ) | ( PROCEDURE <identifier> AS <statement> ) | ( TRIGGER ON <identifier> INSTEAD OF ( INSERT | UPDATE | DELETE ) ( ( AS <for each row trigger action> ) | ENABLED | DISABLED ) ) )

Alter the given target.

Example:

ALTER VIEW vw AS SELECT col FROM tbl

for each row trigger action ::=

  • FOR EACH ROW ( ( BEGIN ( ATOMIC )? ( <statement> )* END ) | <statement> )

Defines an action to perform on each row.

Example:

FOR EACH ROW BEGIN ATOMIC ... END

directly executable statement ::=

  • <query expression>
  • <call statement>
  • <insert statement>
  • <update statement>
  • <delete statement>
  • <drop table>
  • <create temporary table>
  • <create foreign temp table>
  • <alter>
  • <create trigger>

A statement that can be executed at runtime.

Example:

SELECT * FROM tbl

drop table ::=

  • DROP TABLE <identifier>

Creates a trigger action on the given target.

Example:

CREATE TRIGGER ON vw INSTEAD OF INSERT AS FOR EACH ROW BEGIN ATOMIC ... END

create temporary table ::=

  • CREATE ( LOCAL )? TEMPORARY TABLE <identifier> <lparen> <temporary table element> ( <comma> <temporary table element> )* ( <comma> PRIMARY KEY <column list> )? <rparen>

Creates a temporary table.

Example:

CREATE LOCAL TEMPORARY TABLE tmp (col integer)

temporary table element ::=

  • <identifier> ( <data type> | SERIAL ) ( NOT NULL )?

Defines a temporary table column.

Example:

col string NOT NULL

raise error statement ::=

  • ERROR <expression>

Raises an error with the given message.

Example:

ERROR 'something went wrong'

raise statement ::=

  • RAISE ( SQLWARNING )? <exception reference>

Raises an error or warning with the given message.

Example:

RAISE SQLEXCEPTION 'something went wrong'

exception reference ::=

  • <identifier>
  • <sql exception>

a reference to an exception

Example:

SQLEXCEPTION 'something went wrong' SQLSTATE '00X', 2

sql exception ::=

  • SQLEXCEPTION <common value expression> ( SQLSTATE <common value expression> ( <comma> <common value expression> )? )? ( CHAIN <exception reference> )?

creates a sql exception or warning with the specified message, state, and code

Example:

SQLEXCEPTION 'something went wrong' SQLSTATE '00X', 2

statement ::=

  • ( ( <identifier> <colon> )? ( <loop statement> | <while statement> | <compound statement> ) )
  • <if statement> | <delimited statement>

A procedure statement.

Example:

IF (x = 5) BEGIN ... END

delimited statement ::=

  • ( <assignment statement> | <data statement> | <raise error statement> | <raise statement> | <declare statement> | <branching statement> | <return statement> ) <semicolon>

A procedure statement terminated by ;.

Example:

SELECT * FROM tbl;

compound statement ::=

  • BEGIN ( ( NOT )? ATOMIC )? ( <statement> )* ( EXCEPTION <identifier> ( <statement> )* )? END

A procedure statement block contained in BEGIN END.

Example:

BEGIN NOT ATOMIC ... END

branching statement ::=

  • ( ( BREAK | CONTINUE ) ( <identifier> )? )
  • ( LEAVE <identifier> )

A procedure branching control statement, which typically specifies a label to return control to.

Example:

BREAK x

return statement ::=

  • RETURN ( <expression> )?

A return statement.

Example:

RETURN 1

while statement ::=

  • WHILE <lparen> <condition> <rparen> <statement>

A procedure while statement that executes until its condition is false.

Example:

WHILE (var) BEGIN ... END

loop statement ::=

  • LOOP ON <lparen> <query expression> <rparen> AS <identifier> <statement>

A procedure loop statement that executes over the given cursor.

Example:

LOOP ON (SELECT * FROM tbl) AS x BEGIN ... END

if statement ::=

  • IF <lparen> <condition> <rparen> <statement> ( ELSE <statement> )?

A procedure loop statement that executes over the given cursor.

Example:

IF (boolVal) BEGIN variables.x = 1 END ELSE BEGIN variables.x = 2 END

declare statement ::=

  • DECLARE ( <data type> | EXCEPTION ) <identifier> ( <eq> <assignment statement operand> )?

A procedure declaration statement that creates a variable and optionally assigns a value.

Example:

DECLARE STRING x = 'a'

assignment statement ::=

  • <identifier> <eq> ( <assignment statement operand> | ( <call statement> ( ( WITH | WITHOUT ) RETURN )? ) )

Assigns a variable a value in a procedure.

Example:

x = 'b'

assignment statement operand ::=

  • <insert statement>
  • <update statement>
  • <delete statement>
  • <expression>
  • <query expression>
  • <sql exception>

A value or command that can be used in an assignment.

All assigments except for expression are deprecated.

data statement ::=

  • ( <directly executable statement> | <dynamic data statement> ) ( ( WITH | WITHOUT ) RETURN )?

A procedure statement that executes a SQL statement. An update statement can have its update count accessed via the ROWCOUNT variable.


procedure body definition ::=

  • ( CREATE ( VIRTUAL )? PROCEDURE )? <statement>

Defines a procedure body on a Procedure metadata object.

Example:

CREATE VIRTUAL PROCEDURE BEGIN ... END

dynamic data statement ::=

  • ( EXECUTE | EXEC ) ( STRING | IMMEDIATE )? <expression> ( AS <typed element list> ( INTO <identifier> )? )? ( USING <set clause list> )? ( UPDATE ( <unsigned integer> | <star> ) )?

A procedure statement that can execute arbitrary sql.

Example:

EXECUTE IMMEDIATE 'SELECT * FROM tbl' AS x STRING INTO #temp

set clause list ::=

  • <identifier> <eq> <expression> ( <comma> <identifier> <eq> <expression> )*

A list of value assignments.

Example:

col1 = 'x', col2 = 'y' ...

typed element list ::=

  • <identifier> <data type> ( <comma> <identifier> <data type> )*

A list of typed elements.

Example:

col1 string, col2 integer ...

callable statement ::=

  • <lbrace> ( <qmark> <eq> )? CALL <identifier> ( <lparen> ( <expression list> )? <rparen> )? <rbrace> ( <option clause> )?

A callable statement defined using JDBC escape syntax.

Example:

{? = CALL proc}

call statement ::=

  • ( ( EXEC | EXECUTE | CALL ) <identifier> <lparen> ( <named parameter list> | ( <expression list> )? ) <rparen> ) ( <option clause> )?

Executes the procedure with the given parameters.

Example:

CALL proc('a', 1)

named parameter list ::=

  • ( <identifier> <eq> ( <gt> )? <expression> ( <comma> <identifier> <eq> ( <gt> )? <expression> )* )

A list of named parameters.

Example:

param1 => 'x', param2 => 1

insert statement ::=

  • ( INSERT | MERGE ) INTO <identifier> ( <column list> )? ( ( VALUES <lparen> <expression list> <rparen> ) | <query expression> ) ( <option clause> )?

Inserts values into the given target.

Example:

INSERT INTO tbl (col1, col2) VALUES ('a', 1)

expression list ::=

  • <expression> ( <comma> <expression> )*

A list of expressions.

Example:

col1, 'a', ...

update statement ::=

  • UPDATE <identifier> SET <set clause list> ( <where clause> )? ( <option clause> )?

Update values in the given target.

Example:

UPDATE tbl SET (col1 = 'a') WHERE col2 = 1

delete statement ::=

  • DELETE FROM <identifier> ( <where clause> )? ( <option clause> )?

Delete rows from the given target.

Example:

DELETE FROM tbl WHERE col2 = 1

query expression ::=

  • ( WITH <with list element> ( <comma> <with list element> )* )? <query expression body>

A declarative query for data.

Example:

SELECT * FROM tbl WHERE col2 = 1

with list element ::=

  • <identifier> ( <column list> )? AS <lparen> <query expression> <rparen>

A query expression for use in the enclosing query.

Example:

X (Y, Z) AS (SELECT 1, 2)

query expression body ::=

  • <query term> ( ( UNION | EXCEPT ) ( ALL | DISTINCT )? <query term> )* ( <order by clause> )? ( <limit clause> )? ( <option clause> )?

The body of a query expression, which can optionally be ordered and limited.

Example:

SELECT * FROM tbl ORDER BY col1 LIMIT 1

query term ::=

  • <query primary> ( INTERSECT ( ALL | DISTINCT )? <query primary> )*

Used to establish INTERSECT precedence.

Example:

SELECT * FROM tbl
SELECT * FROM tbl1 INTERSECT SELECT * FROM tbl2

query primary ::=

  • <query>
  • ( TABLE <identifier> )
  • ( <lparen> <query expression body> <rparen> )

A declarative source of rows.

Example:

TABLE tbl
SELECT * FROM tbl1

query ::=

  • <select clause> ( <into clause> )? ( <from clause> ( <where clause> )? ( <group by clause> )? ( <having clause> )? )?

A SELECT query.

Example:

SELECT col1, max(col2) FROM tbl GROUP BY col1

into clause ::=

  • INTO <identifier>

Used to direct the query into a table.

This is deprecated. Use INSERT INTO with a query expression instead.

Example:

INTO tbl

select clause ::=

  • SELECT ( ALL | DISTINCT )? ( <star> | ( <select sublist> ( <comma> <select sublist> )* ) )

The columns returned by a query. Can optionally be distinct.

Example:

SELECT *
SELECT DISTINCT a, b, c

select sublist ::=

  • <select derived column>
  • <all in group >

An element in the select clause

Example:

tbl.*
tbl.col AS x

select derived column ::=

  • ( <expression> ( ( AS )? <identifier> )? )

A select clause item that selects a single column.

This is slightly different than a derived column in that the AS keyword is optional.

Example:

tbl.col AS x

derived column ::=

  • ( <expression> ( AS <identifier> )? )

An optionally named expression.

Example:

tbl.col AS x

all in group ::=

  • <all in group identifier>

A select sublist that can select all columns from the given group.

Example:

tbl.*

ordered aggreate function ::=

  • ( XMLAGG | ARRAY_AGG | JSONARRAY_AGG ) <lparen> <expression> ( <order by clause> )? <rparen>

An aggregate function that can optionally be ordered.

Example:

XMLAGG(col1) ORDER BY col2
ARRAY_AGG(col1)

text aggreate function ::=

  • TEXTAGG <lparen> ( FOR )? <derived column> ( <comma> <derived column> )* ( DELIMITER <character> )? ( QUOTE <character> )? ( HEADER )? ( ENCODING <identifier> )? ( <order by clause> )? <rparen>

An aggregate function for creating separated value clobs.

Example:

TEXTAGG (col1 as t1, col2 as t2 DELIMITER ',' HEADER)

standard aggregate function ::=

  • ( COUNT <lparen> <star> <rparen> )
  • ( ( COUNT | SUM | AVG | MIN | MAX | EVERY | STDDEV_POP | STDDEV_SAMP | VAR_SAMP | VAR_POP | SOME | ANY ) <lparen> ( DISTINCT | ALL )? <expression> <rparen> )

A standard aggregate function.

Example:

COUNT(*)

analytic aggregate function ::=

  • ( ROW_NUMBER | RANK | DENSE_RANK ) <lparen> <rparen>

An analytic aggregate function.

Example:

ROW_NUMBER()

filter clause ::=

  • FILTER <lparen> WHERE <boolean primary> <rparen>

An aggregate filter clause applied prior to accumulating the value.

Example:

FILTER (WHERE col1='a')

from clause ::=

  • FROM ( <table reference> ( <comma> <table reference> )* )

A query from clause containing a list of table references.

Example:

FROM a, b
FROM a right outer join b, c, d join e".</p>

table reference ::=

  • ( <escaped join> <joined table> <rbrace> )
  • <joined table>

An optionally escaped joined table.

Example:

a
a inner join b

joined table ::=

  • <table primary> ( <cross join> | <qualified table> )*

A table or join.

Example:

a
a inner join b

cross join ::=

  • ( ( CROSS | UNION ) JOIN <table primary> )

A cross join.

Example:

a CROSS JOIN b

qualified table ::=

  • ( ( ( RIGHT ( OUTER )? ) | ( LEFT ( OUTER )? ) | ( FULL ( OUTER )? ) | INNER )? JOIN <table reference> ON <condition> )

An INNER or OUTER join.

Example:

a inner join b

table primary ::=

  • ( <text table> | <array table> | <xml table> | <object table> | <table name> | <table subquery> | ( <lparen> <joined table> <rparen> ) ) ( ( MAKEDEP <make dep options> ) | MAKENOTDEP )?

A single source of rows.

Example:

a

make dep options ::=

  • ( <lparen> ( MAX <colon> <unsigned integer> )? ( JOIN )? <rparen> )?

options for the make dep hint

Example:

(min:10000)

xml serialize ::=

  • XMLSERIALIZE <lparen> ( DOCUMENT | CONTENT )? <expression> ( AS ( STRING | VARCHAR | CLOB | VARBINARY | BLOB ) )? ( ENCODING <identifier> )? ( VERSION <string> )? ( ( INCLUDING | EXCLUDING ) XMLDECLARATION )? <rparen>

Serializes an XML value.

Example:

XMLSERIALIZE(col1 AS CLOB)

array table ::=

  • ARRAYTABLE <lparen> <value expression primary> COLUMNS <typed element list> <rparen> ( AS )? <identifier>

The ARRAYTABLE table function creates tabular results from arrays. It can be used as a nested table reference.

Example:

ARRAYTABLE (col1 COLUMNS x STRING) AS y

text table ::=

  • TEXTTABLE <lparen> <common value expression> ( SELECTOR <string> )? COLUMNS <text table column> ( <comma> <text table column> )* ( NO ROW DELIMITER )? ( DELIMITER <character> )? ( ( ESCAPE <character> ) | ( QUOTE <character> ) )? ( HEADER ( <unsigned integer> )? )? ( SKIP <unsigned integer> )? <rparen> ( AS )? <identifier>

The TEXTTABLE table function creates tabular results from text. It can be used as a nested table reference.

Example:

TEXTTABLE (file COLUMNS x STRING) AS y

text table column ::=

  • <identifier> <data type> ( WIDTH <unsigned integer> ( NO TRIM )? )? ( SELECTOR <string> <unsigned integer> )?

A text table column.

Example:

x INTEGER WIDTH 6

xml query ::=

  • XMLQUERY <lparen> ( <xml namespaces> <comma> )? <string> ( PASSING <derived column> ( <comma> <derived column> )* )? ( ( NULL | EMPTY ) ON EMPTY )? <rparen>

Executes an XQuery to return an XML result.

Example:

XMLQUERY('<a>...</a>' PASSING doc)

object table ::=

  • OBJECTTABLE <lparen> ( LANGUAGE <string> )? <string> ( PASSING <derived column> ( <comma> <derived column> )* )? COLUMNS <object table column> ( <comma> <object table column> )* <rparen> ( AS )? <identifier>

Returns table results by processing a script.

Example:

OBJECTTABLE('z' PASSING val AS z COLUMNS col OBJECT 'teiid_row') AS X

object table column ::=

  • <identifier> <data type> <string> ( DEFAULT <expression> )?

object table column.

Example:

y integer 'teiid_row_number'

xml table ::=

  • XMLTABLE <lparen> ( <xml namespaces> <comma> )? <string> ( PASSING <derived column> ( <comma> <derived column> )* )? ( COLUMNS <xml table column> ( <comma> <xml table column> )* )? <rparen> ( AS )? <identifier>

Returns table results by processing an XQuery.

Example:

XMLTABLE('/a/b' PASSING doc COLUMNS col XML PATH '.') AS X

xml table column ::=

  • <identifier> ( ( FOR ORDINALITY ) | ( <data type> ( DEFAULT <expression> )? ( PATH <string> )? ) )

XML table column.

Example:

y FOR ORDINALITY

unsigned integer ::=

  • <unsigned integer literal>

An unsigned interger value.

Example:

12345

table subquery ::=

  • ( TABLE | LATERAL )? <lparen> ( <query expression> | <call statement> ) <rparen> ( AS )? <identifier>

A table defined by a subquery.

Example:

(SELECT * FROM tbl) AS x

table name ::=

  • ( <identifier> ( ( AS )? <identifier> )? )

A table named in the FROM clause.

Example:

tbl AS x

where clause ::=

  • WHERE <condition>

Specifies a search condition

Example:

WHERE x = 'a'

condition ::=

  • <boolean value expression>

A boolean expression.


boolean value expression ::=

  • <boolean term> ( OR <boolean term> )*

An optionally ORed boolean expression.


boolean term ::=

  • <boolean factor> ( AND <boolean factor> )*

An optional ANDed boolean factor.


boolean factor ::=

  • ( NOT )? <boolean primary>

A boolean factor.

Example:

NOT x = 'a'

boolean primary ::=

  • ( <common value expression> ( <between predicate> | <match predicate> | <like regex predicate> | <in predicate> | <is null predicate> | <quantified comparison predicate> | <comparison predicate> )? )
  • <exists predicate>

A boolean predicate or simple expression.

Example:

col LIKE 'a%'

comparison operator ::=

  • <eq>
  • <ne>
  • <ne2>
  • <lt>
  • <le>
  • <gt>
  • <ge>

A comparison operator.

Example:

=

comparison predicate ::=

  • <comparison operator> <common value expression>

A value comparison.

Example:

= 'a'

subquery ::=

  • <lparen> ( <query expression> | <call statement> ) <rparen>

A subquery.

Example:

(SELECT * FROM tbl)

quantified comparison predicate ::=

  • <comparison operator> ( ANY | SOME | ALL ) <subquery>

A subquery comparison.

Example:

= ANY (SELECT col FROM tbl)

match predicate ::=

  • ( NOT )? ( LIKE | ( SIMILAR TO ) ) <common value expression> ( ESCAPE <character> | ( <lbrace> ESCAPE <character> <rbrace> ) )?

Matches based upon a pattern.

Example:

LIKE 'a_'

like regex predicate ::=

  • ( NOT )? LIKE_REGEX <common value expression>

A regular expression match.

Example:

LIKE_REGEX 'a.*b'

character ::=

  • <string>

A single character.

Example:

'a'

between predicate ::=

  • ( NOT )? BETWEEN <common value expression> AND <common value expression>

A comparison between two values.

Example:

BETWEEN 1 AND 5

is null predicate ::=

  • IS ( NOT )? NULL

A null test.

Example:

IS NOT NULL

in predicate ::=

  • ( NOT )? IN ( <subquery> | ( <lparen> <common value expression> ( <comma> <common value expression> )* <rparen> ) )

A comparison with multiple values.

Example:

IN (1, 5)

exists predicate ::=

  • EXISTS <subquery>

A test if rows exist.

Example:

EXISTS (SELECT col FROM tbl)

group by clause ::=

  • GROUP BY <expression list>

Defines the grouping columns

Example:

GROUP BY col1, col2

having clause ::=

  • HAVING <condition>

Search condition applied after grouping.

Example:

HAVING max(col1) = 5

order by clause ::=

  • ORDER BY <sort specification> ( <comma> <sort specification> )*

Specifices row ordering.

Example:

ORDER BY x, y DESC

sort specification ::=

  • <sort key> ( ASC | DESC )? ( NULLS ( FIRST | LAST ) )?

Defines how to sort on a particular expression

Example:

col1 NULLS FIRST

sort key ::=

  • <expression>

A sort expression.

Example:

col1

integer parameter ::=

  • <unsigned integer>
  • <unsigned value expression primary>

A literal integer or parameter reference to an integer.

Example:

?

limit clause ::=

  • ( LIMIT <integer parameter> ( <comma> <integer parameter> )? )
  • ( OFFSET <integer parameter> ( ROW | ROWS ) ( <fetch clause> )? )
  • <fetch clause>

Limits and/or offsets the resultant rows.

Example:

LIMIT 2

fetch clause ::=

  • FETCH ( FIRST | NEXT ) ( <integer parameter> )? ( ROW | ROWS ) ONLY

ANSI limit.

Example:

FETCH FIRST 1 ROWS ONLY

option clause ::=

  • OPTION ( MAKEDEP <identifier> <make dep options> ( <comma> <identifier> <make dep options> )* | MAKENOTDEP <identifier> ( <comma> <identifier> )* | NOCACHE ( <identifier> ( <comma> <identifier> )* )? )*

Specifies query options.

Example:

OPTION MAKEDEP tbl

expression ::=

  • <condition>

A value.

Example:

col1

common value expression ::=

  • ( <numeric value expression> ( <concat_op> <numeric value expression> )* )

Establishes the precedence of concat.

Example:

'a' || 'b'

numeric value expression ::=

  • ( <term> ( <plus or minus> <term> )* )

Example:

1 + 2

plus or minus ::=

  • <plus>
  • <minus>

The + or - operator.

Example:

+

term ::=

  • ( <value expression primary> ( <star or slash> <value expression primary> )* )

A numeric term

Example:

1 * 2

star or slash ::=

  • <star>
  • <slash>

The * or / operator.

Example:

/

value expression primary ::=

  • <non numeric literal>
  • ( <plus or minus> )? ( <unsigned numeric literal> | <unsigned value expression primary> )

A simple value expression.

Example:

+col1

unsigned value expression primary ::=

  • <qmark>
  • ( <dollar> <unsigned integer> )
  • ( <escaped function> <function> <rbrace> )
  • ( ( <text aggreate function> | <standard aggregate function> | <ordered aggreate function> ) ( <filter clause> )? ( <window specification> )? )
  • ( <analytic aggregate function> ( <filter clause> )? <window specification> )
  • ( <function> ( <window specification> )? )
  • ( ( <identifier> | <non-reserved identifier> ) ( <lsbrace> <common value expression> <rsbrace> )? )
  • <subquery>
  • ( <lparen> <expression> <rparen> ( <lsbrace> <common value expression> <rsbrace> )? )
  • <searched case expression>
  • <case expression>

An unsigned simple value expression.

Example:

col1

window specification ::=

  • OVER <lparen> ( PARTITION BY <expression list> )? ( <order by clause> )? <rparen>

The window specification for an analytical or windowed aggregate function.

Example:

OVER (PARTION BY col1)

case expression ::=

  • CASE <expression> ( WHEN <expression> THEN <expression> )+ ( ELSE <expression> )? END

If/then/else chain using a common search predicand.

Example:

CASE col1 WHEN 'a' THEN 1 ELSE 2

searched case expression ::=

  • CASE ( WHEN <condition> THEN <expression> )+ ( ELSE <expression> )? END

If/then/else chain using multiple search conditions.

Example:

CASE WHEN x = 'a' THEN 1 WHEN y = 'b' THEN 2

function ::=

  • ( CONVERT <lparen> <expression> <comma> <data type> <rparen> )
  • ( CAST <lparen> <expression> AS <data type> <rparen> )
  • ( SUBSTRING <lparen> <expression> ( ( FROM <expression> ( FOR <expression> )? ) | ( <comma> <expression list> ) ) <rparen> )
  • ( EXTRACT <lparen> ( YEAR | MONTH | DAY | HOUR | MINUTE | SECOND ) FROM <expression> <rparen> )
  • ( TRIM <lparen> ( ( ( ( LEADING | TRAILING | BOTH ) ( <expression> )? ) | <expression> ) FROM )? <expression> <rparen> )
  • ( ( TO_CHARS | TO_BYTES ) <lparen> <expression> <comma> <string> <rparen> )
  • ( ( TIMESTAMPADD | TIMESTAMPDIFF ) <lparen> <time interval> <comma> <expression> <comma> <expression> <rparen> )
  • <querystring function>
  • ( ( LEFT | RIGHT | CHAR | USER | YEAR | MONTH | HOUR | MINUTE | SECOND | XMLCONCAT | XMLCOMMENT ) <lparen> ( <expression list> )? <rparen> )
  • ( ( TRANSLATE | INSERT ) <lparen> ( <expression list> )? <rparen> )
  • <xml parse>
  • <xml element>
  • ( XMLPI <lparen> ( ( NAME )? <identifier> ) ( <comma> <expression> )? <rparen> )
  • <xml forest>
  • <json object>
  • <xml serialize>
  • <xml query>
  • ( <identifier> <lparen> ( ALL | DISTINCT )? ( <expression list> )? ( <order by clause> )? <rparen> ( <filter clause> )? )

Calls a scalar function.

Example:

func('1', col1)

xml parse ::=

  • XMLPARSE <lparen> ( DOCUMENT | CONTENT ) <expression> ( WELLFORMED )? <rparen>

Parses the given value as XML.

Example:

XMLPARSE(DOCUMENT doc WELLFORMED)

querystring function ::=

  • QUERYSTRING <lparen> <expression> ( <comma> <derived column> )* <rparen>

Produces a URL query string from the given arguments.

Example:

QUERYSTRING(col1 AS opt, col2 AS val)

xml element ::=

  • XMLELEMENT <lparen> ( ( NAME )? <identifier> ) ( <comma> <xml namespaces> )? ( <comma> <xml attributes> )? ( <comma> <expression> )* <rparen>

Creates an XML element.

Example:

XMLELEMENT(NAME "root", child)

xml attributes ::=

  • XMLATTRIBUTES <lparen> <derived column> ( <comma> <derived column> )* <rparen>

Creates attributes for the containing element.

Example:

XMLATTRIBUTES(col1 AS attr1, col2 AS attr2)

json object ::=

  • JSONOBJECT <lparen> <derived column list> <rparen>

Produces a JSON object containing name value pairs.

Example:

JSONOBJECT(col1 AS val1, col2 AS val2)

derived column list ::=

  • <derived column> ( <comma> <derived column> )*

a list of name value pairs

Example:

col1 AS val1, col2 AS val2

xml forest ::=

  • XMLFOREST <lparen> ( <xml namespaces> <comma> )? <derived column list> <rparen>

Produces an element for each derived column.

Example:

XMLFOREST(col1 AS ELEM1, col2 AS ELEM2)

xml namespaces ::=

  • XMLNAMESPACES <lparen> <xml namespace element> ( <comma> <xml namespace element> )* <rparen>

Defines XML namespace URI/prefix combinations

Example:

XMLNAMESPACES('http://foo' AS foo)

xml namespace element ::=

  • ( <string> AS <identifier> )
  • ( NO DEFAULT )
  • ( DEFAULT <string> )

An xml namespace

Example:

NO DEFAULT

data type ::=

  • ( STRING ( <lparen> <unsigned integer> <rparen> )? )
  • ( VARCHAR ( <lparen> <unsigned integer> <rparen> )? )
  • BOOLEAN
  • BYTE
  • TINYINT
  • SHORT
  • SMALLINT
  • ( CHAR ( <lparen> <unsigned integer> <rparen> )? )
  • INTEGER
  • LONG
  • BIGINT
  • ( BIGINTEGER ( <lparen> <unsigned integer> <rparen> )? )
  • FLOAT
  • REAL
  • DOUBLE
  • ( BIGDECIMAL ( <lparen> <unsigned integer> ( <comma> <unsigned integer> )? <rparen> )? )
  • ( DECIMAL ( <lparen> <unsigned integer> ( <comma> <unsigned integer> )? <rparen> )? )
  • DATE
  • TIME
  • TIMESTAMP
  • ( OBJECT ( <lparen> <unsigned integer> <rparen> )? )
  • ( BLOB ( <lparen> <unsigned integer> <rparen> )? )
  • ( CLOB ( <lparen> <unsigned integer> <rparen> )? )
  • ( VARBINARY ( <lparen> <unsigned integer> <rparen> )? )
  • XML

A data type.

Example:

STRING

time interval ::=

  • SQL_TSI_FRAC_SECOND
  • SQL_TSI_SECOND
  • SQL_TSI_MINUTE
  • SQL_TSI_HOUR
  • SQL_TSI_DAY
  • SQL_TSI_WEEK
  • SQL_TSI_MONTH
  • SQL_TSI_QUARTER
  • SQL_TSI_YEAR

A time interval keyword.

Example:

SQL_TSI_HOUR

non numeric literal ::=

  • <string>
  • <binary string literal>
  • FALSE
  • TRUE
  • UNKNOWN
  • NULL
  • ( <escaped type> <string> <rbrace> )

An escaped or simple non numeric literal.

Example:

'a'

unsigned numeric literal ::=

  • <unsigned integer literal>
  • <approximate numeric literal>
  • <decimal numeric literal>

An unsigned numeric literal value.

Example:

1.234

ddl statement ::=

  • ( <create table> | <create procedure> | <option namespace> | <alter options> | <create trigger> ) ( <semicolon> )?

A data definition statement.

Example:

CREATE FOREIGN TABLE X (Y STRING)

option namespace ::=

  • SET NAMESPACE <string> AS <identifier>

A namespace used to shorten the full name of an option key.

Example:

SET NAMESPACE 'http://foo' AS foo

create procedure ::=

  • CREATE ( VIRTUAL | FOREIGN )? ( PROCEDURE | FUNCTION ) ( <identifier> <lparen> ( <procedure parameter> ( <comma> <procedure parameter> )* )? <rparen> ( RETURNS ( ( ( TABLE )? <lparen> <procedure result column> ( <comma> <procedure result column> )* <rparen> ) | <data type> ) )? ( <options clause> )? ( AS <statement> )? )

Defines a procedure or function invocation.

Example:

CREATE FOREIGN PROCEDURE proc (param STRING) RETURNS STRING

procedure parameter ::=

  • ( IN | OUT | INOUT | VARIADIC )? <identifier> <data type> ( NOT NULL )? ( RESULT )? ( DEFAULT <string> )? ( <options clause> )?

A procedure or function parameter

Example:

OUT x INTEGER

procedure result column ::=

  • <identifier> <data type> ( NOT NULL )? ( <options clause> )?

A procedure result column.

Example:

x INTEGER

create table ::=

  • CREATE ( ( FOREIGN TABLE ) | ( ( VIRTUAL )? VIEW ) | ( GLOBAL TEMPORARY TABLE ) ) <identifier> ( <create table body> | ( <options clause> )? ) ( AS <query expression> )?

Defines a table or view.

Example:

CREATE VIEW vw AS SELECT 1

create foreign temp table ::=

  • CREATE ( LOCAL )? FOREIGN TEMPORARY TABLE <identifier> <create table body> ON <identifier>

Defines a foreign temp table

Example:

CREATE FOREIGN TEMPORARY TABLE t (x string) ON z

create table body ::=

  • <lparen> <table element> ( <comma> <table element> )* ( <comma> ( CONSTRAINT <identifier> )? ( <primary key> | <other constraints> | <foreign key> ) ( <options clause> )? )* <rparen> ( <options clause> )?

Defines a table.

Example:

(x string) OPTIONS (CARDINALITY 100)

foreign key ::=

  • FOREIGN KEY <column list> REFERENCES <identifier> ( <column list> )?

Defines the foreign key referential constraint.

Example:

FOREIGN KEY (a, b) REFERENCES tbl (x, y)

primary key ::=

  • PRIMARY KEY <column list>

Defines the primary key.

Example:

PRIMARY KEY (a, b)

other constraints ::=

  • ( ( UNIQUE | ACCESSPATTERN ) <column list> )
  • ( INDEX <lparen> <expression list> <rparen> )

Defines ACCESSPATTERN and UNIQUE constraints and INDEXes.

Example:

UNIQUE (a)

column list ::=

  • <lparen> <identifier> ( <comma> <identifier> )* <rparen>

A list of column names.

Example:

(a, b)

table element ::=

  • <identifier> ( SERIAL | ( <data type> ( NOT NULL )? ( AUTO_INCREMENT )? ) ) ( ( PRIMARY KEY ) | ( ( UNIQUE )? ( INDEX )? ) ) ( DEFAULT <string> )? ( <options clause> )?

Defines a table column.

Example:

x INTEGER NOT NULL

options clause ::=

  • OPTIONS <lparen> <option pair> ( <comma> <option pair> )* <rparen>

A list of statement options.

Example:

OPTIONS ('x' 'y', 'a' 'b')

option pair ::=

  • <identifier> ( <non numeric literal> | ( <plus or minus> )? <unsigned numeric literal> )

An option key/value pair.

Example:

'key' 'value'

alter options ::=

  • ALTER ( VIRTUAL | FOREIGN )? ( TABLE | VIEW | PROCEDURE ) <identifier> ( <alter options list> | <alter column options> )

alters options of tables/procedure

Example:

ALTER FOREIGN TABLE foo OPTIONS (ADD cardinality 100)

alter options list ::=

  • OPTIONS <lparen> ( <add set option> | <drop option> ) ( <comma> ( <add set option> | <drop option> ) )* <rparen>

a list of alterations to options

Example:

OPTIONS (ADD updatable true)

drop option ::=

  • DROP <identifier>

drop option

Example:

DROP updatable

add set option ::=

  • ( ADD | SET ) <option pair>

add or set an option pair

Example:

ADD updatable true

alter column options ::=

  • ALTER ( COLUMN | PARAMETER )? <identifier> <alter options list>

alters a set of column options

Example:

ALTER COLUMN bar OPTIONS (ADD updatable true)

Stop watching space | Change email notification preferences
View Online | View Changes | Add Comment