Skip to content

SQLite data types

SQLite has five storage classes: NULL, INTEGER, REAL, TEXT and BLOB. A column’s declared type does not fix the class of each value in it. SQLite only gives the column a type affinity, which is a preference for one class.

In the tables below, Supported means TableAI shows the value in the grid and lets you edit it where the column allows editing.

Storage class What it stores TableAI
NULL An absent value, distinct from empty text or zero. Supported
INTEGER A signed whole number, stored in 1, 2, 3, 4, 6 or 8 bytes depending on its size. Supported
REAL An 8-byte IEEE floating-point number. Supported
TEXT A string in the database encoding: UTF-8, UTF-16LE or UTF-16BE. Supported
BLOB Bytes, stored exactly as given. Supported

SQLite accepts any type name in a column definition. It chooses the column’s affinity from the name:

  • A name containing INT gets INTEGER affinity.
  • A name containing CHAR, CLOB or TEXT gets TEXT affinity.
  • A name containing BLOB, or no type at all, gets BLOB affinity.
  • A name containing REAL, FLOA or DOUB gets REAL affinity.
  • Any other name gets NUMERIC affinity.
Affinity Common declared names TableAI
INTEGER INT, INTEGER, TINYINT, SMALLINT, MEDIUMINT, BIGINT, UNSIGNED BIG INT, INT2, INT8 Supported
TEXT CHARACTER(20), VARCHAR(255), VARYING CHARACTER(255), NCHAR(55), NATIVE CHARACTER(70), NVARCHAR(100), TEXT, CLOB Supported
BLOB BLOB, or no declared type Supported
REAL REAL, DOUBLE, DOUBLE PRECISION, FLOAT Supported
NUMERIC NUMERIC, DECIMAL(10,5), BOOLEAN, DATE, DATETIME Supported

A STRICT table accepts only INT, INTEGER, REAL, TEXT, BLOB and ANY as column types, and rejects a value of the wrong class.

How does SQLite store dates, booleans and JSON?

Section titled “How does SQLite store dates, booleans and JSON?”

SQLite has no separate date, boolean or JSON type. The application chooses the representation:

Kind of value How SQLite stores it TableAI
Boolean An INTEGER: 0 for false, 1 for true Supported
Date and time TEXT in ISO 8601 form, a REAL Julian day number, or an INTEGER Unix timestamp Supported
JSON TEXT, including JSON arrays Supported

Confirm the application’s format, time zone and numeric unit before changing a date or timestamp value. A column name alone does not establish those rules. Preserve the document’s syntax when editing JSON. Use Cell Value or Row Detail to inspect longer values.

SQLite real numbers are approximate. For exact amounts, choose a representation that fits your application’s rules, such as integer minor units. Keep that representation consistent when importing data or writing SQL.

The data editing guide explains the separate actions for NULL, defaults and empty text. For binary values, the results guide covers saving bytes and selecting replacement files.

Use import and export to choose file formats and representations for NULL and binary data. Check the destination column types when moving rows to another database.