A literal is a fixed value written directly in an SQL statement. It is not read from a column or calculated dynamically. Think of typing a known spreadsheet value directly into a formula: 'customer', 1049, or '2021-11-30' becomes part of the query. section 13.4.1 section 20.5
Use literal values to label, supply, or establish known data:
- Assign a known value to a variable with SELECT, such as the date '2021-11-30'. section 13.4.1
- Add a label to UNION results so each row identifies its originating table, such as 'customer' or 'author'. section 10.2
- Pass a known argument directly to a stored procedure, such as the order ID 1049. section 20.5
- Define a fixed DEFAULT value for a column; a default expression must produce the same kind of value for each inserted row. section 19.1.2
Labeling rows after UNION
SELECT FirstName, LastName, 'customer' AS TableName FROM customer UNION SELECT FirstName, LastName, 'author' FROM author; The quoted words are literal values. They create a third result column that tells readers where each row came from. Because UNION removes duplicate rows, changing or omitting this label can also change which rows count as duplicates. section 10.2
SELECT @SomeDate := '2021-11-30';
Inspect the compact SELECT example that assigns the literal date '2021-11-30' to a variable. section 13.4.1





