SQLite Data Types
This page introduces the data types used in SQLite.
Overview of SQLite Data Types
Unlike traditional relational database management systems (RDBMS) such as Oracle, SQL Server, or MySQL, SQLite assigns data types to values rather than strictly to columns. This means that specifying a column data type is not mandatory.
However, you can still declare column data types. In that case, SQLite will attempt to convert inserted values to the declared column type, much like other RDBMS systems.
In this guide, we will demonstrate how to use SQLite in a way that is as consistent as possible with typical RDBMS usage.
Supported Data Types in SQLite
In SQLite 3, the following storage classes (value data types) are supported:
SQLite Storage Class | Description |
---|---|
NULL | Represents a NULL value |
INTEGER | Signed integer |
REAL | Floating-point value |
TEXT | String value |
BLOB | Binary large object |
In addition, SQLite 3 allows you to declare the following column data types:
SQLite Data Type | Equivalent in Other RDBMS | Description |
---|---|---|
INTEGER | INT, BIGINT, etc. | Integer values |
NUMERIC | NUMERIC, DECIMAL | Exact numeric values |
REAL | DOUBLE, FLOAT | Floating-point values |
TEXT | CHAR, VARCHAR | String values |
BLOB | BLOB | Binary large objects |
Unsupported Data Types in SQLite
Some commonly used data types are not directly supported in SQLite. These must be converted into supported types for storage. Examples include:
Unsupported Data Type | How to Store in SQLite |
---|---|
BOOL / BIT | Convert to 0 or 1 and store as INTEGER |
DATETIME | Convert to TEXT (string) or store as INTEGER using Unix time |
That's it — this was an overview of the data types in SQLite.