Literals represent constant values.
SQream DB contains several types of literals:
Number literals - define numbers such as
String literals - define text values like
'Foxes are cool',
Typed literals - define values with explicit types like
(3.0 :: float)
Other constants - predfined values like
A number literal can be expressed in the following way:
number_literal ::= [+-] digits | digits . [ digits ] [ e [+-] digits ] | [ digits ] . digits [ e [+-] digits ] | digits e[+-]digits
1234 1234.56 12. .34 123.56e-45 0.23 3.141 42
The actual data type of the value changes based on context, the format used, and the value itself.
For example, any number containing the decimal point will be considered
FLOAT by default.
Any whole number will considered
INT, unless the value is larger than the maximum value, in which case the type will become a
String literals are string (text) values, encoded either in ASCII or UTF-8.
A string literal is quoted with single quotes (
') or dollars (
To use a single quote in a string, repeat the single quote twice. See examples below.
'This is an example of a string' 'Hello? Is it me you''re looking for?' -- Repeated single quotes are treated as a single quote $$That is my brother's company's CEO's son's dog's toy$$ -- Dollar-quoted '1997-01-01' -- This is a string
The actual data type of the value changes based on context, the format used, and the value itself. In the example below, the first value is interpreted as a
DATE, while the second is interpreted as a
INSERT INTO cool_dates(date_col, reason) VALUES ('1955-11-05', 'Doc Brown discovers flux capacitor');
A typed literal allows the creation of any data type using either of the following syntaxes:
CAST(literal AS type_name) -- or literal :: type_name
See also cast for more information about supported casts.
typed_literal ::= cast(literal AS type_name) | literal :: type_name literal ::= string_literal | number_literal | NULL | TRUE | FALSE type_name ::= BOOL | TINYINT | SMALLINT | INT | BIGINT | FLOAT | REAL | DATE | DATETIME | VARCHAR ( digits ) | TEXT ( digits )
'1955-11-05' :: date 'TRUE' :: BOOL CAST('2300' as BIGINT) CAST(42 :: FLOAT)
FALSEare interpreted as values of type
NULL- which has no type by itself. The type is inferred from context during query compilation.