This topic describes the basic lexical structure of Lindorm SQL.
Background information
A SQL statement consists of a sequence of tokens and ends with a semicolon (;). The token can be a keyword, an identifier, a constant, or a special character. Two tokens are usually separated by a space, a tab, or a new line.
Identifier
An identifier is used in SQL statements to indicate a data object, such as a database, table, or column. Identifiers in Lindorm SQL are quoted by using backticks (`
).
Identifiers that are not quoted by backticks can contain only letters, digits, and underscores (
_
).Quoted identifiers must start and end with a backtick. Example:
`Employee Name`
. Quoted identifiers can contain all characters.
In Lindorm SQL, two data objects at different levels are separated by periods (.
). For example, you can use db.tbl
to specify a table named tbl in a database named db.
In addition to the preceding common lexical constraints, identifiers must also follow the constraints of the Lindorm engine in which they are actually used.
For more information about the constraints of LindormTable, see General limits.
For more information about the constraints of LindormTSDB, see Limits.
Constant
Lindorm SQL supports two types of implicit constants: string constants and numeric constants.
String constants
A string constant is a sequence of characters enclosed by quotation marks (
'
). Example:'This is a string'
.Numeric constants
The following table describes the numeric constant formats supported by Lindorm SQL.
Format
Overview
digits
A value in this format indicates one or more decimal digits (0 to 9).
digitse[+-]digits
A value in this format indicates a numeric constant that contains the exponent mark (e). Example: 4e3.
digits.[digits][e[+-]digits]
A value in this format indicates a numeric constant that contains a decimal point (
.
) and the exponent mark (e). Example: 5.3e2.[digits].digits[e[+-]digits]
ImportantA numeric constant cannot contain spaces or characters that are not contained in the preceding formats.
If a numeric constant contains a decimal point (
.
), at least one decimal digit is required before the decimal point.If a numeric constant contains an exponent mark (e), at least one decimal digit is required before the exponent mark.
Special characters
Some special characters may have specific usage in different scenarios.
A pair of parentheses (
()
) is used to group expressions and prioritize the content in it. In specific cases, parentheses may be used in a SQL syntax.Commas (
,
) are used in some syntaxes to separate listed elements.A semicolon (
;
) is used to end a SQL statement. Semicolons can be used only at the end of SQL statements or in string constants.Colons (
:
) can be used in identifiers to separate column family names and column names.Asterisks (
*
) are used to indicate all fields in a table or a combination of values in the context.Periods (
.
) are mostly used in numeric constants as decimal points. Periods can also be used in identifiers to separate data objects at different levels.
Keywords
SQL keywords are classified into reserved keywords and non-reserved keywords. According to the definition of SQL, reserved keywords are true keywords that can be used as identifiers only when they are referenced by quotes. Non-reserved keywords have special semantics only in specific contexts and can be used as identifiers in non-semantic contexts.
The keywords described in this topic may not be updated at the earliest opportunity. Therefore, we recommend that you query the INFORMATION_SCHEMA.KEYWORDS
system view to obtain the reserved and non-reserved keywords in Lindorm SQL in LindormTable 2.6.3 and later versions.
Reserved keywords in Lindorm SQL
The following table lists the reserved keywords in Lindorm SQL
Initial | Reserved keyword |
A | ABS, ALL, ALLOCATE, ALLOW, ALTER, AND, ANY, ARE, ARRAY, ARRAY_MAX_CARDINALITY, AS, ASENSITIVE, ASYMMETRIC, AT, ATOMIC, AUTHORIZATION, AVG |
B | BEGIN, BEGIN_FRAME, BEGIN_PARTITION, BETWEEN, BIGINT, BINARY, BIT, BLOB, BOOLEAN, BOTH, BY |
C | CALL, CALLED, CARDINALITY, CASCADED, CASE, CAST, CEIL, CEILING, CHAR, CHARACTER, CHARACTER_LENGTH, CHAR_LENGTH, CHECK, CLASSIFIER, CLOB, CLOSE, COALESCE, COLLATE, COLLECT, COLUMN, COMMIT, CONDITION, CONNECT, CONSTRAINT, CONTAINS, CONVERT, CORR, CORRESPONDING, COUNT, COVAR_POP, COVAR_SAMP, CREATE, CROSS, CUBE, CUME_DIST, CURRENT, CURRENT_CATALOG, CURRENT_DATE, CURRENT_DEFAULT_TRANSFORM_GROUP, CURRENT_PATH, CURRENT_ROLE, CURRENT_ROW, CURRENT_SCHEMA, CURRENT_TIME, CURRENT_TIMESTAMP, CURRENT_TRANSFORM_GROUP_FOR_TYPE, CURRENT_USER, CURSOR, CYCLE |
D | DATE, DATETIME, DAY, DEALLOCATE, DEC, DECIMAL, DECLARE, DEFAULT, DEFINE, DELETE, DENSE_RANK, DEREF, DESCRIBE, DETERMINISTIC, DISALLOW, DISCONNECT, DISTINCT, DOUBLE, DROP, DYNAMIC |
E | EACH, ELEMENT, ELSE, EMPTY, END, END-EXEC, END_FRAME, END_PARTITION, EQUALS, ESCAPE, EVERY, EXCEPT, EXEC, EXECUTE, EXISTS, EXP, EXPLAIN, EXTEND, EXTERNAL, EXTRACT |
F | FALSE, FETCH, FILTER, FIRST_VALUE, FLOAT, FLOOR, FOR, FOREIGN, FRAME_ROW, FREE, FRIDAY, FROM, FULL, FUNCTION, FUSION |
G | GEOMETRYCOLLECTION, GET, GLOBAL, GRANT, GROUP, GROUPING, GROUPS |
H | HAVING, HOLD, HOUR |
I | IDENTITY, IMPORT, IN, INDICATOR, INITIAL, INNER, INOUT, INSENSITIVE, INSERT, INT, INTEGER, INTERSECT, INTERSECTION, INTERVAL, INTO, IS |
J | JOIN, JSON_ARRAY, JSON_ARRAYAGG, JSON_EXISTS, JSON_OBJECT, JSON_OBJECTAGG, JSON_QUERY, JSON_VALUE |
L | LAG, LANGUAGE, LARGE, LAST_VALUE, LATERAL, LEAD, LEADING, LEFT, LIKE, LIKE_REGEX, LIMIT, LINESTRING, LN, LOCAL, LOCALTIME, LOCALTIMESTAMP, LOWER |
M | MATCH, MATCHES, MATCH_NUMBER, MATCH_RECOGNIZE, MAX, MEASURES, MEMBER, MERGE, METHOD, MIN, MINUS, MINUTE, MOD, MODIFIES, MODULE, MONDAY, MONTH, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, MULTISET |
N | NATIONAL, NATURAL, NCHAR, NCLOB, NEW, NEXT, NO, NONE, NORMALIZE, NOT, NTH_VALUE, NTILE, NULL, NULLIF, NUMERIC |
O | OCCURRENCES_REGEX, OCTET_LENGTH, OF, OFFSET, OLD, OMIT, ON, ONE, ONLY, OPEN, OR, ORDER, ORDINAL, OUT, OUTER, OVER, OVERLAPS, OVERLAY |
P | PARAMETER, PARTITION, PATTERN, PER, PERCENT, PERCENT_RANK, PERIOD, PERMUTE, PORTION, POSITION, POSITION_REGEX, POINT, POLYGON, POWER, PRECEDES, PRECISION, PREPARE, PREV, PRIMARY, PROCEDURE |
Q | QUALIFY |
R | RANGE, RANK, READS, REAL, RECURSIVE, REF, REFERENCES, REFERENCING, REGR_AVGX, REGR_AVGY, REGR_COUNT, REGR_INTERCEPT, REGR_R2, REGR_SLOPE, REGR_SXX, REGR_SXY, REGR_SYY, RELEASE, RESET, RESULT, RETURN, RETURNS, REVOKE, RIGHT, ROLLBACK, ROLLUP, ROW, ROWS, ROW_NUMBER, RUNNING |
S | SAFE_CAST, SAFE_OFFSET, SAFE_ORDINAL, SATURDAY, SAVEPOINT, SCOPE, SCROLL, SEARCH, SECOND, SEEK, SELECT, SENSITIVE, SESSION_USER, SET, SHOW, SIMILAR, SKIP, SMALLINT, SOME, SPECIFIC, SPECIFICTYPE, SQL, SQLEXCEPTION, SQLSTATE, SQLWARNING, SQRT, START, STATIC, STDDEV_POP, STDDEV_SAMP, STREAM, SUBMULTISET, SUBSET, SUBSTRING, SUBSTRING_REGEX, SUCCEEDS, SUM, SUNDAY, SYMMETRIC, SYSTEM, SYSTEM_TIME, SYSTEM_USER |
T | TABLE, TABLESAMPLE, THEN, THURSDAY, TIME, TIMESTAMP, TIMEZONE_HOUR, TIMEZONE_MINUTE, TINYINT, TO, TRAILING, TRANSLATE, TRANSLATE_REGEX, TRANSLATION, TREAT, TRIGGER, TRIM, TRIM_ARRAY, TRUE, TRUNCATE, TRY_CAST, TUESDAY |
U | UESCAPE, UNION, UNIQUE, UNKNOWN, UNNEST, UPDATE, UPPER, UPSERT, USER, USING |
V | VALUE, VALUES, VALUE_OF, VARBINARY, VARCHAR, VARYING, VAR_POP, VAR_SAMP, VERSIONING, WEDNESDAY |
W | WHEN, WHENEVER, WHERE, WIDTH_BUCKET, WINDOW, WITH, WITHIN, WITHOUT |
Y | YEAR |
Non-reserved keywords in Lindorm SQL
The following table lists the non-reserved keywords in Lindorm SQL.
Initial | Non-reserved keyword |
A | A, ABSENT, ABSOLUTE, ACTION, ADA, ADD, ADMIN, AFTER, AGGREGATORS, ALWAYS, APPLY, ARRAY_AGG, ARRAY_CONCAT_AGG, ASC, ASSERTION, ASSIGNMENT, ATTR, ATTRIBUTE, ATTRIBUTES, AUTO_INCREMENT |
B | BEFORE, BERNOULLI, BREADTH |
C | C, CASCADE, CATALOG, CATALOG_NAME, CENTURY, CHAIN, CHARACTERISTICS, CHARACTERS, CHARACTER_SET_CATALOG, CHARACTER_SET_NAME, CHARACTER_SET_SCHEMA, CLASS_ORIGIN, COBOL, COLLATION, COLLATION_CATALOG, COLLATION_NAME, COLLATION_SCHEMA, COLUMN_FAMILY, COLUMN_NAME, COLUMNS, COMMAND_FUNCTION, COMMAND_FUNCTION_CODE, COMMENT, COMMITTED, CONDITIONAL, COMPACT, CONDITION_NUMBER, CONNECTION, CONNECTION_NAME, CONSTRAINTS, CONSTRAINT_CATALOG, CONSTRAINT_NAME, CONSTRAINT_SCHEMA, CONSTRUCTOR, CONTINUE, CONTINUOUS, CURSOR_NAME |
D | DATA, DATABASE, DATETIME_DIFF, DATETIME_INTERVAL_CODE, DATETIME_INTERVAL_PRECISION, DATETIME_TRUNC, DATE_DIFF, DATE_TRUNC, DAYOFWEEK, DAYOFYEAR, DAYS, DECADE, DEFAULTS, DEFERRABLE, DEFERRED, DEFINED, DEFINER, DEGREE, DEPTH, DERIVED, DESC, DESCRIPTION, DESCRIPTOR, DIAGNOSTICS, DISPATCH, DOMAIN, DOT, DOW, DOY, DYNAMIC_FUNCTION, DYNAMIC_FUNCTION_CODE |
E | ENCODING, EPOCH, ERROR, EXCEPTION, EXCLUDE, EXCLUDING |
F | FINAL, FIRST, FOLLOWING, FORMAT, FORTRAN, FOUND, FRAC_SECOND |
G | G, GENERAL, GENERATED, GEOMETRY, GO, GOTO, GRANTED, GROUP_CONCAT |
H | HBOOLEAN, HDOUBLE, HIERARCHY, HINTEGER, HLONG, HOP, HOURS, HSHORT, HSTRING |
I | IGNORE, IF, ILIKE, IMMEDIATE, IMMEDIATELY, IMPLEMENTATION, INCLUDE, INCLUDING, INCREMENT, INITIALLY, INPUT, INSTANCE, INSTANTIABLE, INVOKER, ISODOW, ISOLATION, ISOYEAR |
J | JAVA, JSON |
K | K, KEY, KEY_MEMBER, KEY_TYPE |
L | LABEL, LAST, LENGTH, LEVEL, LIBRARY, LOCATOR |
M | M, MAP, MATCHED, MAXVALUE, MESSAGE_LENGTH, MESSAGE_OCTET_LENGTH, MESSAGE_TEXT, MICROSECOND, MILLENNIUM, MILLISECOND, MINUTES, MINVALUE, MONTHS, MORE, MUMPS |
N | NAME, NAMES, NAMESPACE, NANOSECOND, NESTING, NORMALIZED, NULLABLE, NULLS, NUMBER |
O | OBJECT, OCTETS, OPTION, OPTIONS, ORDERING, ORDINALITY, OTHERS, OUTPUT, OVERRIDING |
P | PAD, PARAMETER_MODE, PARAMETER_NAME, PARAMETER_ORDINAL_POSITION, PARAMETER_SPECIFIC_CATALOG, PARAMETER_SPECIFIC_NAME, PARAMETER_SPECIFIC_SCHEMA, PARTIAL, PARTITIONS, PASCAL, PASSING, PASSTHROUGH, PASSWORD, PAST, PATH, PERCENTILE_CONT, PERCENTILE_DISC, PIVOT, PLACING, PLAN, PLI, PRECEDING, PREDOWNSAMPLE, PREDOWNSAMPLES, PRESERVE, PRIOR, PRIVILEGES, PUBLIC |
Q | QUARTER, QUARTERS, QUERY, QUERIES |
R | READ, RELATIVE, REPEATABLE, REPLACE, RESPECT, RESTART, RESTRICT, RETURNED_CARDINALITY, RETURNED_LENGTH, RETURNED_OCTET_LENGTH, RETURNED_SQLSTATE, RETURNING, RLIKE, ROLE, ROUTINE, ROUTINE_CATALOG, ROUTINE_NAME, ROUTINE_SCHEMA, ROW, ROW_COUNT |
S | SCALAR, SCALE, SCHEMA, SCHEMA_NAME, SCOPE_CATALOGS, SCOPE_NAME, SCOPE_SCHEMA, SEARCH, SECONDS, SECTION, SECURITY, SELF, SEPARATOR, SEQUENCE, SERIALIZABLE, SERVER, SERVER_NAME, SESSION, SETS, SIMPLE, SIZE, SOURCE, SPACE, SPECIFIC_NAME, SQL_BIGINT, SQL_BINARY, SQL_BIT, SQL_BLOB, SQL_BOOLEAN, SQL_CHAR, SQL_CLOB, SQL_DATE, SQL_DECIMAL, SQL_DOUBLE, SQL_FLOAT, SQL_INTEGER, SQL_INTERVAL_DAY, SQL_INTERVAL_DAY_TO_HOUR, SQL_INTERVAL_DAY_TO_MINUTE, SQL_INTERVAL_DAY_TO_SECOND, SQL_INTERVAL_HOUR, SQL_INTERVAL_HOUR_TO_MINUTE, SQL_INTERVAL_HOUR_TO_SECOND, SQL_INTERVAL_MINUTE, SQL_INTERVAL_MINUTE_TO_SECOND, SQL_INTERVAL_MONTH, SQL_INTERVAL_SECOND, SQL_INTERVAL_YEAR, SQL_INTERVAL_YEAR_TO_MONTH, SQL_LONGVARBINARY, SQL_LONGVARCHAR, SQL_LONGVARNCHAR, SQL_NCHAR, SQL_NCLOB, SQL_NUMERIC, SQL_NVARCHAR, SQL_REAL, SQL_SMALLINT, SQL_TIME, SQL_TIMESTAMP, SQL_TINYINT, SQL_TSI_DAY, SQL_TSI_FRAC_SECOND, SQL_TSI_HOUR, SQL_TSI_MICROSECOND, SQL_TSI_MINUTE, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_SECOND, SQL_TSI_WEEK, SQL_TSI_YEAR, SQL_VARBINARY, SQL_VARCHAR, STATE, STATEMENT, STRING_AGG, STRUCTURE, STYLE, SUBCLASS_ORIGIN, SUBSTITUTE |
T | TABLES, TABLE_NAME, TAG, TEMPORARY, TIES, TIMESTAMPADD, TIMESTAMPDIFF, TIMESTAMP_DIFF, TIMESTAMP_TRUNC, TIME_DIFF, TIME_TRUNC, TOP_LEVEL_COUNT, TRANSACTION, TRANSACTIONS_ACTIVE, TRANSACTIONS_COMMITTED, TRANSACTIONS_ROLLED_BACK, TRANSFORM, TRANSFORMS, TRASH, TRIGGER_CATALOG, TRIGGER_NAME, TRIGGER_SCHEMA, TTL, TUMBLE, TYPE |
U | UNBOUNDED, UNCOMMITTED, UNCONDITIONAL, UNDER, UNMAP, UNNAMED, UNPIVOT, USAGE, USE, USERS, USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_CODE, USER_DEFINED_TYPE_NAME, USER_DEFINED_TYPE_SCHEMA, UTF16, UTF32, UTF8 |
V | VARIABLES, VERSION, VIEW, WEEK, WEEKS |
W | WILDCARD, WORK, WRAPPER, WRITE |
X | XML |
Y | YEARS |
Z | ZONE |