![]() Home Download Cheat Sheet Documentation Quickstart Installation Tutorial Features Security Performance Advanced Reference Commands Functions • Aggregate• Window Data Types SQL Grammar System Tables Javadoc PDF (2 MB) Support FAQ Error Analyzer Google Group Appendix History License Build Links MVStore Architecture Migration to 2.0 | SQL GrammarIndexLiteralsDatetime fieldsOther GrammarDetailsClick on the header of the grammar element to switch between railroad diagram and BNF. Non-standard syntax is marked in green. Compatibility-only non-standard syntax is marked in red,don't use it unless you need it for compatibility with other databases or old versions of H2. LiteralsValuestring |{dollarQuotedString } |numeric |dateAndTime |boolean |bytes|interval |array |{geometry |json |uuid } |null A literal value of any data type, or null. Example: 10 Approximate numeric[ + | - ] { {number [ . [number ] ] } | { .number } }E [ + | - ]expNumber An approximate numeric value. Approximate numeric values have Example: -1.4e-10 ArrayARRAY '[' [expression [,...] ] ']'
An array of values. Example: ARRAY[1, 2] BooleanTRUE | FALSE | UNKNOWN
A boolean value. Example: TRUE BytesX'hex' [ 'hex' [...] ] A binary string value. The hex value is not case sensitive and may contain space characters as separators. If there are more than one group of quoted hex values, groups must be separated with whitespace. Example: X'' DateDATE '[-]yyyy-MM-dd'
A date literal. Example: DATE '2004-12-31' Date and timedate |time |timeWithTimeZone |timestamp |timestampWithTimeZone A literal value of any date-time data type. Example: TIMESTAMP '1999-01-31 10:00:00' Dollar Quoted String$$anything$$
A string starts and ends with two dollar signs. Two dollar signs are not allowed within the text. A whitespace is required before the first set of dollar signs. No escaping is required within the text. Example: $$John's car$$ Exact numeric[ + | - ] { {number [ .number ] } | { .number } } An exact numeric value. Exact numeric values with dot have Example: -1600.05 Hex Number[+|-] {0x|0X} { [_] {digit | a-f | A-F } [...] } [...]
A number written in hexadecimal notation. Example: 0xff Octal Number[+|-] {0o|0O} { [_] { 0-7 } [...] } [...]
A number written in octal notation. Example: 0o664 Binary Number[+|-] {0b|0B} { [_] { 0-1 } [...] } [...]
A number written in binary notation. Example: 0b101 Int[ + | - ]number
The maximum integer number is 2147483647, the minimum is -2147483648. Example: 10 GEOMETRYGEOMETRY {bytes |string } A binary string or character string with A binary string should contain Well-known Binary Representation ( A character string should contain Well-known Text Representation ( Example: GEOMETRY 'GEOMETRYCOLLECTION (POINT (1 2))' JSONJSON {bytes |string } A binary or character string with a Example: JSON '{"id":10,"name":"What''s this?"}' Long[ + | - ]number
Long numbers are between -9223372036854775808 and 9223372036854775807. Example: 100000 NullNULL NULL
Example: NULL Numberdigit [ [_]digit [...] ] [...] The maximum length of the number depends on the data type used. Example: 100 NumericexactNumeric |approximateNumeric |int |long |hexNumber |octalNumber |binaryNumber The data type of a numeric literal is the one of numeric data types, such as An explicit Example: -1600.05 String[N]'anything' [...]| U&{'anything' [...]} [ UESCAPE 'anything' ]
A character string literal starts and ends with a single quote. Two single quotes can be used to create a single quote inside a string. Prefix String literals staring with Example: 'John''s car' UUIDUUID '{digit | a-f | A-F | - } [...]'
A Example: UUID '12345678-1234-1234-1234-123456789ABC' TimeTIME [ WITHOUT TIME ZONE ] 'hh:mm:ss[.nnnnnnnnn]'
A time literal. A value is between 0:00:00 and 23:59:59.999999999 and has nanosecond resolution. Example: TIME '23:59:59' Time with time zoneTIME WITH TIME ZONE 'hh:mm:ss[.nnnnnnnnn]{{ Z } | { - | + }timeZoneOffsetString}'
A time with time zone literal. A value is between 0:00:00 and 23:59:59.999999999 and has nanosecond resolution. Example: TIME WITH TIME ZONE '23:59:59+01' TimestampTIMESTAMP [ WITHOUT TIME ZONE ] '[-]yyyy-MM-dd hh:mm:ss[.nnnnnnnnn]'
A timestamp literal. Example: TIMESTAMP '2005-12-31 23:59:59' Timestamp with time zoneTIMESTAMP WITH TIME ZONE '[-]yyyy-MM-dd hh:mm:ss[.nnnnnnnnn][{ Z } | { - | + }timeZoneOffsetString |{timeZoneNameString } ]' A timestamp with time zone literal. If name of time zone is specified it will be converted to time zone offset. Example: TIMESTAMP WITH TIME ZONE '2005-12-31 23:59:59Z' IntervalintervalYear |intervalMonth |intervalDay |intervalHour |intervalMinute|intervalSecond |intervalYearToMonth |intervalDayToHour|intervalDayToMinute |intervalDayToSecond |intervalHourToMinute|intervalHourToSecond |intervalMinuteToSecond An interval literal. Example: INTERVAL '1-2' YEAR TO MONTH INTERVAL YEARINTERVAL [-|+] '[-|+]yearInt' YEAR [ (precisionInt ) ]
An Example: INTERVAL '10' YEAR INTERVAL MONTHINTERVAL [-|+] '[-|+]monthInt' MONTH [ (precisionInt ) ]
An Example: INTERVAL '10' MONTH INTERVAL DAYINTERVAL [-|+] '[-|+]dayInt' DAY [ (precisionInt ) ]
An Example: INTERVAL '10' DAY INTERVAL HOURINTERVAL [-|+] '[-|+]hourInt' HOUR [ (precisionInt ) ]
An Example: INTERVAL '10' HOUR INTERVAL MINUTEINTERVAL [-|+] '[-|+]minuteInt' MINUTE [ (precisionInt ) ]
An Example: INTERVAL '10' MINUTE INTERVAL SECONDINTERVAL [-|+] '[-|+]secondInt[.nnnnnnnnn]'SECOND [ (precisionInt [,fractionalPrecisionInt ] ) ] An Example: INTERVAL '10.123' SECOND INTERVAL YEAR TO MONTHINTERVAL [-|+] '[-|+]yearInt-monthInt' YEAR [ (precisionInt ) ] TO MONTH
An Example: INTERVAL '1-6' YEAR TO MONTH INTERVAL DAY TO HOURINTERVAL [-|+] '[-|+]dayInthoursInt' DAY [ (precisionInt ) ] TO HOUR
An Example: INTERVAL '10 11' DAY TO HOUR INTERVAL DAY TO MINUTEINTERVAL [-|+] '[-|+]dayInt hh:mm' DAY [ (precisionInt ) ] TO MINUTE
An Example: INTERVAL '10 11:12' DAY TO MINUTE INTERVAL DAY TO SECONDINTERVAL [-|+] '[-|+]dayInt hh:mm:ss[.nnnnnnnnn]' DAY [ (precisionInt ) ]TO SECOND [ (fractionalPrecisionInt ) ] An Example: INTERVAL '10 11:12:13.123' DAY TO SECOND INTERVAL HOUR TO MINUTEINTERVAL [-|+] '[-|+]hh:mm' HOUR [ (precisionInt ) ] TO MINUTE
An Example: INTERVAL '10:11' HOUR TO MINUTE INTERVAL HOUR TO SECONDINTERVAL [-|+] '[-|+]hh:mm:ss[.nnnnnnnnn]' HOUR [ (precisionInt ) ]TO SECOND [ (fractionalPrecisionInt ) ] An Example: INTERVAL '10:11:12.123' HOUR TO SECOND INTERVAL MINUTE TO SECONDINTERVAL [-|+] '[-|+]mm:ss[.nnnnnnnnn]' MINUTE [ (precisionInt ) ]TO SECOND [ (fractionalPrecisionInt ) ] An Example: INTERVAL '11:12.123' MINUTE TO SECOND Datetime fieldsDatetime fieldyearField |monthField |dayOfMonthField|hourField |minuteField |secondField|timezoneHourField |timezoneMinuteField|{timezoneSecondField|millenniumField |centuryField |decadeField|quarterField|millisecondField |microsecondField |nanosecondField|dayOfYearField|isoDayOfWeekField |isoWeekField |isoWeekYearField|dayOfWeekField |weekField |weekYearField|epochField }
Fields for Example: YEAR Year fieldYEAR |{ YYYY | YY | SQL_TSI_YEAR }
Year. Example: YEAR Month fieldMONTH |{ MM | M | SQL_TSI_MONTH }
Month (1-12). Example: MONTH Day of month fieldDAY |{ DD | D | SQL_TSI_DAY }
Day of month (1-31). Example: DAY Hour fieldHOUR |{ HH | SQL_TSI_HOUR }
Hour (0-23). Example: HOUR Minute fieldMINUTE |{ MI | N | SQL_TSI_MINUTE }
Minute (0-59). Example: MINUTE Second fieldSECOND |{ SS | S | SQL_TSI_SECOND }
Second (0-59). Example: SECOND Timezone hour fieldTIMEZONE_HOUR TIMEZONE_HOUR Timezone hour (from -18 to +18). Example: TIMEZONE_HOUR Timezone minute fieldTIMEZONE_MINUTE TIMEZONE_MINUTE Timezone minute (from -59 to +59). Example: TIMEZONE_MINUTE Timezone second fieldTIMEZONE_SECOND TIMEZONE_SECOND Timezone second (from -59 to +59). Local mean time ( Example: TIMEZONE_SECOND Millennium fieldMILLENNIUM MILLENNIUM Century, or one thousand years (2001-01-01 to 3000-12-31). Example: MILLENNIUM Century fieldCENTURY CENTURY Century, or one hundred years (2001-01-01 to 2100-12-31). Example: CENTURY Decade fieldDECADE DECADE Decade, or ten years (2020-01-01 to 2029-12-31). Example: DECADE Quarter fieldQUARTER QUARTER Quarter (1-4). Example: QUARTER Millisecond field{ MILLISECOND } |{ MS }
Millisecond (0-999). Example: MILLISECOND Microsecond field{ MICROSECOND } |{ MCS }
Microsecond (0-999999). Example: MICROSECOND Nanosecond field{ NANOSECOND } |{ NS }
Nanosecond (0-999999999). Example: NANOSECOND Day of year field{ DAYOFYEAR | DAY_OF_YEAR } |{ DOY | DY }
Day of year (1-366). Example: DAYOFYEAR ISO day of week field{ ISO_DAY_OF_WEEK } |{ ISODOW }
Example: ISO_DAY_OF_WEEK ISO week fieldISO_WEEK ISO_WEEK
Example: ISO_WEEK ISO week year field{ ISO_WEEK_YEAR } |{ ISO_YEAR | ISOYEAR }
Returns the Example: ISO_WEEK_YEAR Day of week field{ DAY_OF_WEEK | DAYOFWEEK } |{ DOW }
Day of week (1-7), locale-specific. Example: DAY_OF_WEEK Week field{ WEEK } |{ WW | W | SQL_TSI_WEEK }
Week of year (1-53) using local rules. Example: WEEK Week year field{ WEEK_YEAR } WEEK_YEAR Returns the week-based year (locale-specific) from a date/time value. Example: WEEK_YEAR Epoch fieldEPOCH EPOCH For Example: EPOCH Other GrammarAliasname An alias is a name that is only valid in the context of the statement. Example: A And Conditioncondition [ { ANDcondition } [...] ] Value or condition. Example: ID=1 AND NAME='Hi' Array element reference{array |json } '['indexInt ']' Returns array element at specified 1-based index. Returns Example: A[2] Field reference(expression).fieldName
Returns field value from the row value or Example: (R).FIELD1 Array value constructor by queryARRAY (query)
Collects values from the subquery into array. The subquery should have exactly one column. Number of elements in the returned array is the number of rows in the subquery. Example: ARRAY(SELECT * FROM SYSTEM_RANGE(1, 10)); Case expressionsimpleCase |searchedCase Performs conditional evaluation of expressions. Example: CASE A WHEN 'a' THEN 1 ELSE 2 END Simple caseCASEexpression{ WHEN {expression |conditionRightHandSide } [,...] THENexpression } [...][ ELSEexpression ] END Returns then expression from the first when clause where one of its operands was was evaluated to Plain expressions are tested for equality with the case expression, Example: CASE CNT WHEN IS NULL THEN 'Null' WHEN 0 THEN 'No' WHEN 1 THEN 'One' WHEN 2, 3 THEN 'Few' ELSE 'Some' END Searched caseCASE { WHENexpression THENexpression } [...][ ELSEexpression ] END Returns the first expression where the condition is true. If no else part is specified, return Example: CASE WHEN CNT<10 THEN 'Low' ELSE 'High' END Cast specificationCAST(value ASdataTypeOrDomain [ FORMATtemplateString ])
Converts a value to another data type. The following conversion rules are used: When converting a number to a boolean, 0 is false and every other value is true. When converting a boolean to a number, false is 0 and true is 1. When converting a number to a number of another type, the value is checked for overflow. When converting a string to binary, Template may only be specified for casts from datetime data types to character string data types and for casts from character string data types to datetime data types. '-', '.', '/', ',', '''', ';', ':' and ' ' (space) characters can be used as delimiters. Y,
Multiple patterns for the same datetime field may not be specified. If year is not specified, current year is used. If month is not specified, current month is used. If day is not specified, 1 is used. If some fields of time or time zone are not specified, 0 is used. Example: CAST(NAME AS INT); CipherAES AES Only the algorithm Example: AES Column DefinitiondataTypeOrDomain[ VISIBLE | INVISIBLE ][ { DEFAULTexpression| GENERATED ALWAYS AS (generatedColumnExpression)| GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY [(sequenceOption [...])]} ][ ON UPDATEexpression ][ DEFAULT ON NULL ][ SELECTIVITYselectivityInt ][ COMMENTexpression ][columnConstraintDefinition ] [...]
The default expression is used if no explicit value was used when adding a row and when A column is either a generated column or a base column. The generated column has a generated column expression. The generated column expression is evaluated and assigned whenever the row changes. This expression may reference base columns of the table, but may not reference other data. The value of the generated column cannot be set explicitly. Generated columns may not have On update column expression is used if row is updated, at least one column has a new value that is different from its previous value and value for this column is not set explicitly in update statement. Identity column is a column generated with a sequence. The column declared as the identity column with
The invisible column will not be displayed as a result of Column constraint definitions are not supported for Example: CREATE TABLE TEST(ID INT PRIMARY KEY, Column Constraint Definition[constraintNameDefinition ]NOT NULL | PRIMARY KEY | UNIQUE [nullsDistinct ] |referencesSpecification | CHECK (condition)
Referential constraint requires values that exist in other column (usually in another table). Check constraint require a specified condition to return Example: NOT NULL CommentbracketedComment | -- anything |// anything
Comments can be used anywhere in a command and are ignored by the database. Line comments Example: -- comment Bracketed comment/* [ [bracketedComment ] [ anything ] [...] ] */
Comments can be used anywhere in a command and are ignored by the database. Bracketed comments Example: /* comment */ Compare<> | <= | >= | = | < | > |{ != } |&&
Comparison operator. The operator != is the same as <>. The operator Example: <> Conditionoperand [conditionRightHandSide ]| NOTcondition| EXISTS (query )| UNIQUE [nullsDistinct ] (query )|INTERSECTS (operand,operand)
Boolean value or condition.
Example: ID <> 2 Condition Right Hand SidecomparisonRightHandSide|quantifiedComparisonRightHandSide|nullPredicateRightHandSide|distinctPredicateRightHandSide|quantifiedDistinctPredicateRightHandSide|booleanTestRightHandSide|typePredicateRightHandSide|jsonPredicateRightHandSide|betweenPredicateRightHandSide|inPredicateRightHandSide|likePredicateRightHandSide|regexpPredicateRightHandSide The right hand side of a condition. Example: > 10 Comparison Right Hand Sidecompareoperand Right side of comparison predicates. Example: > 10 Quantified Comparison Right Hand Sidecompare { ALL | ANY | SOME } ( {query |{array } } ) Right side of quantified comparison predicates. Quantified comparison predicate Quantified comparison predicates Note that these predicates have priority over If version with array is required and this array is returned from a subquery, wrap this subquery with a cast to distinguish this operation from standard quantified comparison predicate with a query. Example: < ALL(SELECT V FROM TEST) Null Predicate Right Hand SideIS [ NOT ] NULL
Right side of null predicate. Check whether the specified value(s) are Example: IS NULL Distinct Predicate Right Hand SideIS [ NOT ] [ DISTINCT FROM ]operand
Right side of distinct predicate. Distinct predicate is null-safe, meaning Example: IS NOT DISTINCT FROM OTHER Quantified Distinct Predicate Right Hand SideIS [ NOT ] [ DISTINCT FROM ] { ALL | ANY | SOME } ( {query |array } ) Right side of quantified distinct predicate. Quantified distinct predicate is null-safe, meaning Quantified distinct predicate Quantified distinct predicates Note that these predicates have priority over If version with array is required and this array is returned from a subquery, wrap this subquery with a cast to distinguish this operation from quantified comparison predicate with a query. Example: IS DISTINCT FROM ALL(SELECT V FROM TEST) Boolean Test Right Hand SideIS [ NOT ] { TRUE | FALSE | UNKNOWN }
Right side of boolean test. Checks whether the specified value is (not) Example: IS TRUE Type Predicate Right Hand SideIS [ NOT ] OF (dataType [,...])
Right side of type predicate. Checks whether the data type of the specified operand is one of the specified data types. Some data types have multiple names, these names are considered as equal here. Domains and their base data types are currently not distinguished from each other. Precision and scale are also ignored. If operand is Example: IS OF (INTEGER, BIGINT) JSON Predicate Right Hand SideIS [ NOT ] JSON [ VALUE | ARRAY | OBJECT | SCALAR ] [ [ WITH | WITHOUT ] UNIQUE [ KEYS ] ]
Right side of Checks whether value of the specified string, binary data, or a Example: IS JSON OBJECT WITH UNIQUE KEYS Between Predicate Right Hand Side[ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ]operand ANDoperand Right side of between predicate. Checks whether the value is within the range inclusive. Example: BETWEEN LOW AND HIGH In Predicate Right Hand Side[ NOT ] IN ( {query |expression [,...] } )
Right side of in predicate. Checks presence of value in the specified list of values or in result of the specified query. Returns This operation is logically equivalent to Example: IN (A, B, C) Like Predicate Right Hand Side[ NOT ] { LIKE |{ ILIKE } }operand [ ESCAPEstring ] Right side of like predicate. The wildcards characters are
Example: LIKE 'a%' Regexp Predicate Right Hand Side{ [ NOT ] REGEXPoperand }
Right side of Regexp predicate. Regular expression matching is used. See Java Example: REGEXP '[a-z]' Nulls DistinctNULLS { DISTINCT | NOT DISTINCT |{ ALL DISTINCT } }
Are nulls distinct for unique constraint, index, or predicate. If Treatment of null values inside composite data types is not affected. Example: NULLS DISTINCT Table Constraint Definition[constraintNameDefinition ]{ PRIMARY KEY[ HASH ] (columnName [,...] ) }| UNIQUE [nullsDistinct ] ( {columnName [,...] | VALUE } )|referentialConstraint| CHECK (condition)
Defines a constraint.
Referential constraint requires values that exist in other column(s) (usually in another table). Check constraint requires a specified condition to return Example: PRIMARY KEY(ID, NAME) Constraint Name DefinitionCONSTRAINT[ IF NOT EXISTS ]newConstraintName
Defines a constraint name. Example: CONSTRAINT CONST_ID Csv OptionscharsetString [,fieldSepString [,fieldDelimString [,escString [,nullString]]]]|optionString Optional parameters for
For a newline or other special character, use Example: CALL CSVWRITE('test2.csv', 'SELECT * FROM TEST', 'charset=UTF-8 fieldSeparator=|'); Data Change Delta Table{ OLD | NEW | FINAL } TABLE( {insert |update |delete |{mergeInto } |mergeUsing } ) Executes the inner data change command and returns old, new, or final rows.
Example: SELECT ID FROM FINAL TABLE (INSERT INTO TEST (A, B) VALUES (1, 2)) Data Type or DomaindataType | [schemaName.]domainName A data type or domain name. Example: INTEGER Data TypepredefinedType |arrayType |rowType A data type. Example: INTEGER Predefined TypecharacterType |characterVaryingType |characterLargeObjectType|binaryType |binaryVaryingType |binaryLargeObjectType|booleanType|smallintType |integerType |bigintType|numericType |realType |doublePrecisionType |decfloatType|dateType |timeType |timeWithTimeZoneType|timestampType |timestampWithTimeZoneType|intervalType|{tinyintType |javaObjectType |enumType|geometryType |jsonType |uuidType } A predefined data type. Example: INTEGER Digit0-9 0-9 A digit. Example: 0 ExpressionandCondition [ { ORandCondition } [...] ]
Value or condition. Example: ID=1 OR NAME='Hi' Factorterm [ { { * | / |{ % } }term } [...] ] A value or a numeric factor. Example: ID * 10 Grouping elementexpression | (expression [, ...]) | ()
A grouping element of Example: A Hex[' ' [...]] { {digit | a-f | A-F } [' ' [...]] {digit | a-f | A-F } [' ' [...]] } [...] The hexadecimal representation of a number or of bytes with optional space characters. Two hexadecimal digit characters are one byte. Example: cafe Index ColumncolumnName [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
Indexes this column in ascending or descending order. Usually it is not required to specify the order; however doing so will speed up large queries that order the column in the same way. Example: NAME Insert valuesVALUES { DEFAULT|expression | [ROW] ({DEFAULT|expression} [,...]) }, [,...]
Values for Example: VALUES (1, 'Test') Interval qualifierYEAR [(precisionInt)] [ TO MONTH ]| MONTH [(precisionInt)]| DAY [(precisionInt)] [ TO { HOUR | MINUTE | SECOND [(scaleInt)] } ]| HOUR [(precisionInt)] [ TO { MINUTE | SECOND [(scaleInt)] } ]| MINUTE [(precisionInt)] [ TO SECOND [(scaleInt)] ]| SECOND [(precisionInt [,scaleInt])]
An interval qualifier. Example: DAY TO SECOND Join specificationONexpression | USING (columnName [,...])
Specifies a join condition or column names. Example: ON B.ID = A.PARENT_ID Merge when clausemergeWhenMatchedClause|mergeWhenNotMatchedClause
Example: WHEN MATCHED THEN DELETE Merge when matched clauseWHEN MATCHED [ ANDexpression ] THENUPDATE SETsetClauseList | DELETE
Updates or deletes rows in a target table. Example: WHEN MATCHED THEN UPDATE SET NAME = S.NAME Merge when not matched clauseWHEN NOT MATCHED [ ANDexpression ] THEN INSERT[ (columnName [,...] ) ][overrideClause ]VALUES ({DEFAULT|expression} [,...])
Inserts rows into a target table. If column names aren't specified a list of all visible columns in the target table is assumed. Example: WHEN NOT MATCHED THEN INSERT (ID, NAME) VALUES (S.ID, S.NAME) Name{ { A-Z|_ } [ { A-Z|_|0-9 } [...] ] } |quotedName
With default settings unquoted names are converted to upper case. The maximum name length is 256 characters. Identifiers in H2 are case sensitive by default. Because unquoted names are converted to upper case, they can be written in any case anyway. When both quoted and unquoted names are used for the same identifier the quoted names must be written in upper case. Identifiers with lowercase characters can be written only as a quoted name, they aren't accessible with unquoted names. If If If Example: TEST Operandsummand [ { ||summand } [...] ] Performs the concatenation of character string, binary string, or array values. In the default mode, the result is Example: 'Hi' || ' Eva' Override clauseOVERRIDING { USER | SYSTEM } VALUE
If If If neither clauses are specified, Example: OVERRIDING SYSTEM VALUE Queryselect |explicitTable |tableValue A query, such as Example: SELECT ID FROM TEST; Quoted Name"anything"| U&"anything" [ UESCAPE 'anything' ]
Case of characters in quoted names is preserved as is. Such names can contain spaces. The maximum name length is 256 characters. Two double quotes can be used to create a single double quote inside an identifier. With default settings identifiers in H2 are case sensitive. Identifiers staring with Example: "FirstName" Referential ConstraintFOREIGN KEY (columnName [,...] )referencesSpecification
Defines a referential constraint. Example: FOREIGN KEY(ID) REFERENCES TEST(ID) References SpecificationREFERENCES [refTableName ] [ (refColumnName [,...] ) ][ ON DELETEreferentialAction ] [ ON UPDATEreferentialAction ] Defines a referential specification of a referential constraint. If the table name is not specified, then the same table is referenced. Example: REFERENCES TEST(ID) Referential ActionCASCADE | RESTRICT | NO ACTION | SET { DEFAULT | NULL }
The action Example: CASCADE Script Compression Encryption[ COMPRESSION { DEFLATE | LZF | ZIP | GZIP } ][ CIPHERcipher PASSWORDstring ] The compression and encryption algorithm to use for script files. When using encryption, only Example: COMPRESSION LZF Select order{expression |{int } } [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
Sorts the result by the given column number, or by an expression. If the expression is a single parameter, then the value is interpreted as a column number. Negative column numbers reverse the sort order. Example: NAME DESC NULLS LAST Row value expressionROW (expression, [,...])| ( [expression,expression [,...] ] )|expression
A row value expression. Example: ROW (1) Select ExpressionwildcardExpression |expression [ [ AS ]columnAlias ] An expression in a Example: ID AS DOCUMENT_ID Sequence value expression{ NEXT |{ CURRENT } } VALUE FOR [schemaName.]sequenceName
The next or current value of a sequence. When the next value is requested the sequence is incremented and the current value of the sequence and the last identity in the current session are updated with the generated value. The next value of the sequence is generated only once for each processed row. If this expression is used multiple times with the same sequence it returns the same value within a processed row. Used values are never re-used, even when the transaction is rolled back. Current value may only be requested after generation of the sequence value in the current session. It returns the latest generated value for the current session. If a single command contains next and current value expressions for the same sequence there is no guarantee that the next value expression will be evaluated before the evaluation of current value expression. Example: NEXT VALUE FOR SEQ1 Sequence optionSTART WITHlong|{ RESTART WITHlong }|basicSequenceOption
Option of a sequence.
Example: START WITH 10000 Alter sequence option{ START WITHlong }| RESTART [ WITHlong ]|basicSequenceOption
Option of a sequence.
Example: START WITH 10000 Alter identity column option{ START WITHlong }| RESTART [ WITHlong ]| SETbasicSequenceOption
Option of an identity column.
Example: START WITH 10000 Basic sequence optionINCREMENT BYlong| MINVALUElong | NO MINVALUE |{ NOMINVALUE }| MAXVALUElong | NO MAXVALUE |{ NOMAXVALUE }| CYCLE | NO CYCLE |{ EXHAUSTED } |{ NOCYCLE }|{ CACHElong } |{ NO CACHE } |{ NOCACHE }
Basic option of a sequence.
Sequences with The Example: MAXVALUE 100000 Set clause list{ {updateTarget = { DEFAULT |expression } }| { (updateTarget [,...] ) = {rowValueExpression | (query) } } } [,...]
List of Each column may be specified only once in update targets. Example: NAME = 'Test', PRICE = 2 Sort specificationexpression [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
Sorts the result by an expression. Example: X ASC NULLS FIRST Sort specification listsortSpecification [,...]
Sorts the result by expressions. Example: V Summandfactor [ { { + | - }factor } [...] ] A value or a numeric sum. Please note the text concatenation operator is Example: ID + 20 Table Expression{ [schemaName. ]tableName| (query )|unnest|table|dataChangeDeltaTable }[ [ AS ]newTableAlias [ (columnName [,...] ) ] ][ USE INDEX ([indexName [,...] ]) ][ { { LEFT | RIGHT } [ OUTER ] | [ INNER ] | CROSS | NATURAL }JOINtableExpression [joinSpecification ] ]
Joins a table. The join specification is not supported for cross and natural joins. A natural join is an inner join, where the condition is automatically on the columns with the same name. Example: TEST1 AS T1 LEFT JOIN TEST2 AS T2 ON T1.ID = T2.PARENT_ID Update targetcolumnName [ '['int ']' [...] ]
Column or element of a column of If array indexes are specified, column must have a compatible Example: A Within group specificationWITHIN GROUP (ORDER BYsortSpecificationList)
Group specification for ordered set functions. Example: WITHIN GROUP (ORDER BY ID DESC) Wildcard expression[[schemaName.]tableAlias.]*[EXCEPT ([[schemaName.]tableAlias.]columnName, [,...])] A wildcard expression in a Example: * Window name or specificationwindowName |windowSpecification A window name or inline specification for a window function or aggregate. Window functions in H2 may require a lot of memory for large queries. Example: W1 Window specification([existingWindowName][PARTITION BYexpression [,...]] [ORDER BYsortSpecificationList][windowFrame]) A window specification for a window, window function or aggregate. If name of an existing window is specified its clauses are used by default. Optional window partition clause separates rows into independent partitions. Each partition is processed separately. If this clause is not present there is one implicit partition with all rows. Optional window order clause specifies order of rows in the partition. If some rows have the same order position they are considered as a group of rows in optional window frame clause. Optional window frame clause specifies which rows are processed by a window function, see its documentation for a more details. Example: () Window frameROWS|RANGE|GROUP{windowFramePreceding|BETWEENwindowFrameBound ANDwindowFrameBound}[EXCLUDE {CURRENT ROW|GROUP|TIES|NO OTHERS}]
A window frame clause. May be specified only for aggregates and If this clause is not specified for an aggregate or window function that supports this clause the default window frame depends on window order clause. If window order clause is also not specified the default window frame contains all the rows in the partition. If window order clause is specified the default window frame contains all preceding rows and all rows from the current group. Window frame unit determines how rows or groups of rows are selected and counted. If If only window frame preceding clause is specified it is treated as Optional window frame exclusion clause specifies rows that should be excluded from the frame. Example: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW EXCLUDE TIES Window frame precedingUNBOUNDED PRECEDING|value PRECEDING|CURRENT ROW
A window frame preceding clause. If value is specified it should not be negative. Example: UNBOUNDED PRECEDING Window frame boundUNBOUNDED PRECEDING|value PRECEDING|CURRENT ROW|value FOLLOWING|UNBOUNDED FOLLOWING A window frame bound clause. If value is specified it should not be negative. Example: UNBOUNDED PRECEDING Term{value|column| ?[int ]|sequenceValueExpression| function| { - | + }term| (expression )|arrayElementReference|fieldReference| (query )|caseExpression|castSpecification|userDefinedFunctionName }[timeZone |intervalQualifier ]
A value. Parameters can be indexed, for example Interval qualifier may only be specified for a compatible value or for a subtraction operation between two datetime values. The subtraction operation ignores the leading field precision of the qualifier. Example: 'Hello' Time zoneAT { TIME ZONE {intervalHourToMinute |intervalHourToSecond |{string } } | LOCAL }
A time zone. Converts the timestamp with or without time zone into timestamp with time zone at specified time zone. If a day-time interval is specified as a time zone, it may not have fractional seconds and must be between -18 to 18 hours inclusive. Example: AT LOCAL Column[[schemaName.]tableAlias.] {columnName |{ _ROWID_ } }
A column name with optional table alias and schema. _ Example: ID |