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 are always surrounded by single quotes (‘) or double quotes (“).
|‘skholingua.com’||String literal with single quotes|
|“skholingua.com”||String literal with double quotes|
- 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.
|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|
Date and Time Literals:
- Date and time literals can be expressed as strings.
|‘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’|
- There are no boolean literals in SQLite, instead, boolean literals are stored as numeric values.
|1||Equivalent to TRUE (stored as a number)|
|0||Equivalent to FALSE (stored as a number)|