SQLite 3 reference · Conditional and Type Functions
SQLite TYPEOF() Function
Return the storage class of a value: 'null', 'integer', 'real', 'text' or 'blob'. Shows how SQLite stored it.
SQLite 3
Syntax
typeof(X)
Parameters
| Parameter | Description |
|---|---|
X |
Any value or column. |
Return value
One of 'null', 'integer', 'real', 'text', 'blob'.
Examples
SELECT typeof(42) AS a, typeof(4.2) AS b, typeof('42') AS c, typeof(NULL) AS d, typeof(x'2A') AS e;
Output
a | b | c | d | e integer | real | text | null | blob
SELECT price, typeof(price) AS price_type, signup_date, typeof(signup_date) AS date_type
FROM products, customers
WHERE product_id = 1 AND customer_id = 1;
Output
price | price_type | signup_date | date_type 29.99 | real | 2025-01-15 | text
In other languages
PG_TYPEOF()· PostgreSQL
Related
CAST· Convert a value to another type: CAST(X AS INTEGER), REAL, TEXT, NUMERIC or BLOB. Text that isn't a number becomes 0.QUOTE()· Return a value written as an SQL literal: text in single quotes with quotes doubled, BLOBs as X'..', NULL as NULL.- SQL CREATE TABLE · tutorial