Skip to main content
SQL input consists of a sequence of commands, each terminated by a semicolon (;). Each command is composed of a sequence of tokens. Tokens can be keywords, identifiers, literals, operators, or special characters. Tokens are normally separated by whitespace (spaces, tabs, newlines), but need not be if there is no ambiguity.

Identifiers

Identifiers are names used to refer to database objects such as tables, columns, views, indexes, and engines. For detailed rules about identifier syntax and naming requirements, see Object identifiers.

Key rules

Identifiers must contain at least one character and no more than 255 characters. Unquoted identifiers:
  • Must begin with a letter (a-z) or underscore (_)
  • Subsequent characters can be letters, underscores, or digits (0-9)
  • Are case-insensitive and evaluated entirely in lowercase
Quoted identifiers:
  • Are enclosed in double quotes (")
  • Can contain any UTF-8 characters, including spaces and special characters
  • Are case-sensitive

Reserved words

Certain words are reserved by the SQL language and cannot be used as unquoted identifiers. If you need to use a reserved word as an identifier, enclose it in double quotes. For a complete list, see Reserved words.

Literals

Literals (also called constants) are fixed data values written directly in SQL statements.

String literals

String literals are enclosed in single quotes ('). To include a single quote within a string, write two adjacent single quotes.
Two string literals separated only by whitespace with at least one newline are concatenated into a single string.

Dollar-quoted string literals

For strings containing single quotes, newlines, or other special characters, you can use dollar-quoted strings. These are enclosed by $$ markers and do not require escaping.
Dollar-quoted strings are particularly useful when creating user-defined functions with embedded code.

Escape string literals

Escape string literals are prefixed with the letter E (case-insensitive) before the opening single quote. They support backslash escape sequences for special characters.
Any other character following a backslash is taken literally.
For compatibility, the standard_conforming_strings setting can be set to false to make regular string literals also recognize backslash escape sequences. However, using E'' syntax is recommended for clarity.

Numeric literals

Numeric literals represent integer and floating-point values. Integer literals:
Floating-point literals:
NUMERIC literals with precision:

Boolean literals

Boolean literals represent true or false values.

NULL literal

The NULL literal represents a missing or unknown value.

Date and time literals

Date and time literals can be written using the type name followed by a string literal, or by casting a string. DATE literals:
TIMESTAMP literals:
TIMESTAMPTZ literals:
For more details on date and time types, see DATE, TIMESTAMP, and TIMESTAMPTZ.

Interval literals

Interval literals represent a duration of time and are used in date/time arithmetic. Intervals must be used as part of an arithmetic expression with a date or timestamp value.
For complete syntax and unit options, see Arithmetic with date/time and intervals.

Array literals

Array literals are enclosed in square brackets with elements separated by commas.
For more information, see ARRAY data type.

STRUCT literals

STRUCT literals are written using the STRUCT keyword.

Rows: 1Execution time: 41.01ms

For more information, see STRUCT data type.

Type casting

Literals can be cast to specific data types using the :: operator, the CAST function, or type name prefix syntax.
For complete type conversion rules, see Type conversion.

Operators

Operators are special symbols or keywords that perform operations on values. Firebolt supports arithmetic, comparison, logical, string, and other operators.
For the complete list of operators and their precedence, see Operators.

Comments

Comments are used to add notes or temporarily disable portions of SQL code. Firebolt supports two styles of comments.

Single-line comments

Single-line comments begin with two dashes (--) and extend to the end of the line.

Block comments

Block comments begin with /* and end with */. They can span multiple lines.

Query parameters

Firebolt supports parameterized queries using positional placeholders ($1, $2, $3, etc.). Parameters allow you to write query templates and supply values at execution time.
Parameters provide several benefits:
  • Security: Prevents SQL injection by separating query logic from data
  • Reusability: The same query template can be executed with different values
For complete details on specifying parameters via the SQL workspace, REST API, or SDKs, see Parameterized queries.

Whitespace

Whitespace (spaces, tabs, newlines) separates tokens and is generally ignored except within string literals. Multiple whitespace characters are equivalent to a single space.
Since query result caching is based on the plan fingerprint rather than the literal query text, all of the above queries will also share the same cached query result. Note that whitespace within string literals is preserved: