skip to main content
Querying data stores with SQL : Supported SQL and Extensions : SQL Expressions : Literals
  

Try Now
Literals
Literals are fixed data values. For example, in the expression PRICE * 1.05, the value 1.05 is a constant. Literals are classified into types, including the following:
*Binary
*Character string
*Date
*Floating point
*Integer
*Numeric
*Time
*Timestamp
The following table describes the literal format for supported SQL data types.
Table 197. Literal Syntax Examples
SQL Type
Literal Syntax
Example
BIGINT
n where n is any valid integer value in the range of the INTEGER data type
12 or -34 or 0
BOOLEAN
Min Value: 0
Max Value: 1
0
1
DATE
yyyy-mm-dd
'2010-05-21'
DATETIME
yyyy-mm-dd hh:mm:ss.SSSSSS'
'2010-05-21 18:33:05.025'
DECIMAL
n.f where n is the integral part and f is the fractional part
0.25 or 3.1415 or -7.48
DOUBLE
n.f E x where n is the integral part, f is the fractional part, and x is the exponent
1.2E0 or 2.5E40 or -3.45E2 or 5.67E-4
INTEGER
n where n is a valid integer value in the range of the INTEGER data type
12 or -34 or 0
LONGVARBINARY
hex_value
'000482ff'
LONGVARCHAR
value
'Hello World, how are you'
TIME
hh:mm:ss
'18:33:05'
VARCHAR
value
'Hello World'

Character String Literals

Text specifies a character string literal. A character string literal must be enclosed in single quotation marks. To represent one single quotation mark within a literal, you must enter two single quotation marks. When the data in the fields is returned to the client, trailing blanks are stripped.
A character string literal can have a maximum length of 32 KB, that is, (32*1024) bytes.
Example
'Hello'
'Jim''s friend is Joe'

Integer Literals

Integer literals are represented by a string of numbers that are not enclosed in quotation marks and do not contain decimal points.
*Integer constants must be whole numbers; they cannot contain decimals.
*Integer literals can start with sign characters (+/-).
Example
1994 or -2

Numeric Literals

Unquoted numeric values are treated as numeric literals. If the unquoted numeric value contains a decimal point or exponent, it is treated as a real literal; otherwise, it is treated as an integer literal.
Example
+1894.1204

Binary Literals

Binary literals are represented with single quotation marks. The valid characters in a binary literal are 0-9, a-f, and A-F.
Example
'00af123d'

Date/Time Literals

Date and time literal values are:
*A Date literal is enclosed in single quotation marks (' '). The format is yyyy-mm-dd.
*A Time literal is enclosed in single quotation marks (' '). The format is hh:mm:ss.
*A Timestamp is enclosed in single quotation marks (' '). The format is yyyy-mm-dd hh:mm:ss.SSSSSS.