Literals are numbers or strings used in SQL as constants. Literals are included in the select-list, along with expressions and built-in functions and can also be constants.
Lyftron provides support for number-type literals (integers, numerics, money), string literals, VARBINARY string literals, and date/time literals. The various string literal formats are discussed in this section.
Number-type Literals
Syntax
digits
digits.[digits] | [_digits].digits
digitse[+-]digits | [digits].digitse[+-]digits | digits.[digits]e[+-]digits
[+-]$[+-]digits | [+-]$[+-]digits | [+-]$[+-]digits.[digits] | [+-]$[+-][digits].digits
Parameters
digits | Represents one or more numeric characters (0 through 9). |
e | Represents an exponent marker. |
$ | Represents a money symbol |
Notes
- In most cases a numeric-type constant is automatically coerced to the most appropriate type depending on context. When necessary, you can force a numeric value to be interpreted as a specific data type by casting
- It is allowed to have multiple subsequent positive/negative symbols.
Examples
select 3123 , 22. , .09 , 11e9 , 11e+9 , 11e-9 , 4.e-10 , 0000123456789e
Money-typed values:
select $120.90 , $.90 , $1. , $-90.90 , $+.0808
String Literals
String literals are string values surrounded by single quotes. Single-quoted strings do not require a backslash, except for ' and \.
You can embed single quotes, backslashes and another backslash (escape) sequences, such as \t (tab), into strings.
Character String Literals
Character string literals are a sequence of characters from a predefined character set and are enclosed by single quotes. If the single quote is part of the sequence, it must be doubled as "''".
Syntax
'characters'
Parameters
characters
Arbitrary sequence of characters bounded by single quotes (')
Unicode String Literals
Syntax
N'characters'
Parameters
characters
Arbitrary sequence of UTF-8 characters bounded by single quotes (')
VARBINARY String Literals
VARBINARY string literals allow you to specify hexadecimal digits in a string literal.
Syntax
0x'hexadecimal_digits'
Parameters
hexadecimal_digits
Specifies hexadecimal digits.
Date/Time Literals
Date or time literal input must be enclosed in single quotes or curly braces. Input is accepted in almost any reasonable format, including ISO 8601, SQL-compatible, ODBC, and others.
Lyftron handles date/time input more flexibly than the SQL standard requires. The exact parsing rules of date/time input and for the recognized text fields including months, and days of the week are described in Date/Time Expressions.
Time Zone Values
Lyftron currently does not support date and time with time zones definitions.