Get Started Free

SQLite data types

The five SQLite storage classes, how declared types become affinities, STRICT tables, and how to store booleans, dates and money in SQLite.

Updated November 30, 2026 ยท Tested on SQLite 3.43.2 (sqlite3 CLI), 3.45.3 (Python 3.12 sqlite3), 3.49.2 (better-sqlite3 11.10)

Quick Answer

SQLite stores every value as one of five types: NULL, INTEGER, REAL, TEXT or BLOB. The type you declare on a column only sets its affinity, a preference SQLite applies when it can, so a column declared INTEGER still accepts 'abc'. To make SQLite enforce the types, add STRICT (SQLite 3.37+):

CREATE TABLE products (
  id    INTEGER PRIMARY KEY,
  name  TEXT NOT NULL,
  price REAL,
  qty   INTEGER,
  photo BLOB
) STRICT;

There is no boolean, date or decimal type. Store booleans as 0 and 1, dates as ISO-8601 text or Unix seconds, and money as an integer number of cents. typeof(column) tells you what a row really holds.

Storage classes and type affinity

The same text value '42', inserted into six columns with different declared types, ends up stored four different ways:

CREATE TABLE t (a INTEGER, b TEXT, c REAL, d NUMERIC, e BLOB, f);
INSERT INTO t VALUES ('42', 42, '42', '42', '42', '42');
SELECT typeof(a), typeof(b), typeof(c), typeof(d), typeof(e), typeof(f) FROM t;
integer|text|real|integer|text|text

An INTEGER, REAL or NUMERIC column converts text that looks like a number. A TEXT column turns numbers into text. A BLOB column, or one with no type at all, keeps exactly what you gave it. When text can't be converted, it is stored as text: 'abc' in an INTEGER column is still 'abc'.

SQLite picks the affinity from the declared type name with five rules, checked in order. Any name works, which is why VARCHAR(255) or DATETIME don't cause an error:

Declared type containsAffinityExamples
INTINTEGERINT, INTEGER, BIGINT, TINYINT
CHAR, CLOB or TEXTTEXTTEXT, VARCHAR(255), NCHAR(10)
BLOB, or no typeBLOBBLOB, a column with no type
REAL, FLOA or DOUBREALREAL, DOUBLE, FLOAT
Anything elseNUMERICNUMERIC, DECIMAL(10,2), BOOLEAN, DATE, DATETIME

A length is never enforced: a VARCHAR(5) column stored 'abcdefghij' in full. Use CHECK (length(code) <= 5) if the limit matters.

In VisuaLeaf

See what each row really stores in VisuaLeaf

Open the .db file in VisuaLeaf, right-click the table and choose Tables Info to see each column's declared type, default and keys, and Show DDL for the full CREATE TABLE, including whether it ends in STRICT. The data grid shows each cell as it is actually stored, so a text value sitting in an INTEGER column stands out instead of hiding behind the declared type.

To count the types in a column, run this in the SQL editor:

SELECT typeof(price) AS stored_as, COUNT(*) AS n
FROM products
GROUP BY stored_as;

More than one row in the result means the column holds mixed types, which is worth fixing before you add STRICT or compare the column with a number. See VisuaLeaf for SQLite.

What we found testing this

  • A column declared STRING drops leading zeros. STRING isn't one of the type names SQLite looks for, so it gets NUMERIC affinity. The ZIP code '02134' came back as the integer 2134 from a STRING column and from an INTEGER column, and as '02134' only from TEXT.
  • FLOATING POINT is an integer column. The rules check for INT first, and POINT contains it. '1e3' inserted into a FLOATING POINT column was stored as the integer 1000.
  • STRICT still converts text that looks like a number. In a STRICT table, '42' went into an INTEGER column as 42 and 2.0 as 2. Only values that can't be converted without loss were refused: 'abc' failed with cannot store TEXT value in INTEGER column s.qty and 1.5 with cannot store REAL value in INTEGER column s.qty.
  • ANY means different things in STRICT and normal tables. In a STRICT table, ANY kept '042' as text. In a normal table, ANY is just an unknown type name, so it got NUMERIC affinity and stored '042' as 42.
  • 'true' is not true. In a BOOLEAN column holding TRUE, 'true', '1', 1, 'yes' and 2, WHERE flag matched 4 rows, WHERE flag = TRUE matched 3 (2 isn't equal to 1) and WHERE flag IS TRUE matched 4. The strings 'true' and 'yes' stayed text and matched none of them.
  • Numbers in a TEXT column sort as text. Python inserted 10 and 9 into a TEXT column, and ORDER BY returned '10' before '9'.
  • Large integers lose precision in Node. better-sqlite3 stored 9007199254740993n correctly, but reading it back returned 9007199254740992. With .safeIntegers() on the statement it returned 9007199254740993n.

STRICT tables

Add STRICT after the closing parenthesis. Each column must then have one of six types, and a value that doesn't fit is an error instead of being stored as something else:

STRICT typeAccepts
INT or INTEGERIntegers, and text or reals that convert to an integer exactly
REALReals, and integers (stored as reals)
TEXTText, and numbers (stored as text)
BLOBBlobs only
ANYAnything, stored exactly as given

NULL is allowed in every column unless it's NOT NULL. Other type names are refused when the table is created:

sqlite> CREATE TABLE s2 (d DATETIME) STRICT;
Parse error: unknown datatype for s2.d: "DATETIME"
sqlite> CREATE TABLE s6 (x) STRICT;
Parse error: missing datatype for s6.x

VARCHAR(10), NUMERIC and BOOLEAN were refused the same way. You can't add STRICT to an existing table: rebuild it as shown on the ALTER TABLE page. To check which tables are strict:

SELECT name, strict FROM pragma_table_list
WHERE type = 'table' AND name NOT LIKE 'sqlite_%';

A database with STRICT tables needs SQLite 3.37.0 or newer to read them. Check SELECT sqlite_version(); in every app and tool that opens the file, not just the one that creates it.

Booleans in SQLite

SQLite has no boolean type. TRUE and FALSE are keywords for 1 and 0 (SQLite 3.23+), and typeof(TRUE) returns integer. Use an INTEGER column with a CHECK so only 0 and 1 get in:

CREATE TABLE tasks (
  id    INTEGER PRIMARY KEY,
  title TEXT NOT NULL,
  done  INTEGER NOT NULL DEFAULT 0 CHECK (done IN (0, 1))
);

INSERT INTO tasks (title, done) VALUES ('write docs', TRUE);
SELECT title FROM tasks WHERE done;      -- or WHERE done = 1

With the CHECK, 2 failed with CHECK constraint failed: done IN (0, 1), and the string '1' was converted to 1 and accepted. Without the CHECK, a BOOLEAN column takes anything, including the text 'true', which is false in a WHERE clause.

Dates, money and other types SQLite lacks

You wantStore it asWhy
Date or timestampTEXT 2026-11-26 14:30:00 (UTC) or INTEGER Unix secondsThe date functions read both. See date and time in SQLite
MoneyINTEGER centsSELECT 0.1 + 0.2 returned 0.30000000000000004 and 0.1 + 0.2 = 0.3 returned 0
DECIMAL(10,2)INTEGER cents, or TEXT if you only display itIt gets NUMERIC affinity: '19.99' was stored as the REAL 19.99 and '20.00' as the integer 20
ZIP codes, phone numbers, IDs with leading zerosTEXTAny numeric affinity turns '02134' into 2134
UUIDTEXT, or a 16-byte BLOBBLOB is smaller, TEXT is readable in any viewer
JSONTEXTQuery it with the JSON functions. See JSON in SQLite

From Python and Node

Python's sqlite3 binds True and False as 1 and 0 and reads them back as integers, so convert with bool():

conn.execute("INSERT INTO tasks (title, done) VALUES (?, ?)", ("write docs", True))
done = [bool(row[0]) for row in conn.execute("SELECT done FROM tasks")]   # [True, False]

A decimal.Decimal isn't supported at all: ProgrammingError: Error binding parameter 2: type 'decimal.Decimal' is not supported. Convert it to integer cents or a string first.

better-sqlite3 refuses booleans: binding true threw TypeError: SQLite3 can only bind numbers, strings, bigints, buffers, and null. Convert with Number(), and use .safeIntegers() for integers above Number.MAX_SAFE_INTEGER:

db.prepare('INSERT INTO tasks (title, done) VALUES (?, ?)').run('write docs', Number(true))

const big = db.prepare('SELECT id FROM events WHERE id = ?').safeIntegers()
big.get(9007199254740993n)   // { id: 9007199254740993n }

JavaScript numbers are doubles, but better-sqlite3 binds whole numbers as integers: in a STRICT INTEGER column, 2 was accepted and 2.5 was refused.

Frequently Asked Questions

What data types does SQLite support?

SQLite stores values as NULL, INTEGER, REAL, TEXT or BLOB. Declared types such as VARCHAR, DATETIME or BOOLEAN are accepted but only set a type affinity, one of INTEGER, TEXT, BLOB, REAL or NUMERIC.

Does SQLite have a boolean type?

No. TRUE and FALSE are aliases for 1 and 0. Store booleans in an INTEGER column with CHECK (col IN (0, 1)) so other values are refused.

What is a STRICT table in SQLite?

A table created with STRICT after the column list (SQLite 3.37+). Each column must be INT, INTEGER, REAL, TEXT, BLOB or ANY, and a value that cannot be converted to the column type without loss is an error.

Does SQLite enforce VARCHAR length?

No. VARCHAR(5) gets TEXT affinity and stores text of any length. Add CHECK (length(col) <= 5) to enforce a limit.

Free Tools

VisuaLeaf for SQLite

See what your SQLite columns really hold

VisuaLeaf opens any SQLite file, shows each column's declared type and the full CREATE TABLE, and displays every cell as it is actually stored.