Literals (Constants)


SQLite: Literals

This SQLite tutorial explains how to use literals (string, number, date, time, and boolean literals) in SQLite with examples.


In SQLite, a literal is the same as a constant. We’ll cover several types of literals – string literals, number literals, date and time literals and boolean literals.


String Literals:

  • String literals are always surrounded by single quotes (‘) or double quotes (“).

For example:

Example Explanation
‘’ String literal with single quotes
“” String literal with double quotes


Number Literals:

  • Number literals can be either positive or negative numbers that are exact or floating point values. If you do not specify a sign, then a positive number is assumed.

For example:

Example Explanation
72 Integer literal with no sign (positive sign is assumed)
+72 Integer literal with positive sign
-72 Integer literal with negative sign
72e-04 Floating point literal
72.607 Decimal literal


Date and Time Literals:

  • Date and time literals can be expressed as strings.

For example:

Example Explanation
‘2015-04-27’ Date literal formatted as ‘YYYY-MM-DD’
‘2015-04-27 11:44:23’ Datetime literal formatted as ‘YYYY-MM-DD HH:MM:SS’


Boolean Literals:

  • There are no boolean literals in SQLite, instead, boolean literals are stored as numeric values.

For example:

Example Explanation
1 Equivalent to TRUE (stored as a number)
0 Equivalent to FALSE (stored as a number)