Literals
Description
A literal or constant is a fixed data value, composed of a sequence of characters or a numeric constant. (Redshift SQL Language reference Literals).
Amazon Redshift supports several types of literals, including:
Numeric literals for integer, decimal, and floating-point numbers.
Character literals, also referred to as strings, character strings, or character constants.
Datetime and interval literals, used with datetime data types.
Sample Source Patterns
Input Code:
-- Number literals.
SELECT 42 AS integer_literal, -- Simple integer
-123 AS negative_integer, -- Negative integer
3.14159 AS decimal_literal, -- Decimal number
1E0 AS simple_float; -- Floating-point representation of 1
-- Character literals.
SELECT 'Hello, World!' AS simple_string,
'Line1\nLine2' AS newline_character, -- Interprets \n as literal
'Tab\tCharacter' AS tab_character, -- Interprets \t as literal
'The value is ' || 42 AS mixed_literal;integer_literal
negative_integer
decimal_literal
simple_float
42
-123
3.14159
1
simple_string
newline_character
tab_character
mixed_literal
42
Line1
Line2
Tab Character
The value is 42
Output Code:
-- Number literals.
SELECT 42 AS integer_literal, -- Simple integer
-123 AS negative_integer, -- Negative integer
3.14159 AS decimal_literal, -- Decimal number
1E0 AS simple_float; -- Floating-point representation of 1
-- Character literals.
SELECT 'Hello, World!' AS simple_string,
'Line1\nLine2' AS newline_character, -- Interprets \n as literal
'Tab\tCharacter' AS tab_character, -- Interprets \t as literal
'The value is ' || 42 AS mixed_literal;integer_literal
negative_integer
decimal_literal
simple_float
42
-123
3.14159
1
simple_string
newline_character
tab_character
mixed_literal
42
Line1
Line2
Tab Character
The value is 42
Know Issues
This functionality is not currently supported in Snowflake, but it will be supported through a future migration.
select $MyTagForLiteral$
This is
a test
of a tag literal
$MyTagForLiteral$ as c1;Related EWIs
There are no known issues.
Last updated
