Literals
This SQL tutorial explains how to use literals (strings, integers, decimals, and datetime values) in SQL with examples.
Description
In SQL, a literal is the same as a constant. We'll cover several types of literals - string, integer, decimal, and datetime literals.
String Literals
String literals are always surrounded by single quotes (').
For example:
'TechOnTheNet.com' 'This is a literal' 'XYZ' '123'
These string literal examples contain of strings enclosed in single quotes.
Integer Literals
Integer literals can be either positive numbers or negative numbers, but do not contain decimals. If you do not specify a sign, then a positive number is assumed. Here are some examples of valid integer literals:
536 +536 -536
Decimal Literals
Decimal literals can be either positive numbers or negative numbers and contain decimals. If you do not specify a sign, then a positive number is assumed. Here are some examples of valid decimal literals:
24.7 +24.7 -24.7
Datetime Literals
Datetime literals are character representations of datetime values that are enclosed in single quotes. Here are some examples of valid datetime literals:
'April 30, 2015' '2015/04/30' '2015/04/30 08:34:25'