SQLiteDB – Data Types:
SQLite is a dynamic type system which is backward compatible with many static type systems of other database engines.
Storage classes / Datatypes:
Each value stored in SQLite database will have one of the below storage classes:
NULL – Defines a NULL value.
INTEGER – Defines a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
REAL – Defines a floating point value, stored as an 8-byte IEEE floating point number.
TEXT – Defines a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).
BLOB – Defines a blob of data, stored exactly as it was input.
Any column in an SQLite version 3 database, except an INTEGER PRIMARY KEY column, may be used to store a value of any storage class.
There is no Boolean Datatype in SQLite. Rather, Boolean values are stored as integers 0 (false) and 1 (true).
There are no Data/Time datatypes in SQLite. Rather, the built-in Date and Time functions of SQLite will be used to store dates and times as TEXT, REAL, INTEGER values.
Each column in an SQLite 3 database is assigned one of the below type affinities:
TEXT
NUMERIC
INTEGER
REAL
BLOB
Rigidly-typed database will convert the string ‘123’ into an integer 123 and the integer 456 into a string ‘456’ prior to doing the insert.Below is the list of small subset of the datatype names that SQLite will allow.
| Example Type names From The CREATE TABLE Statement or CAST Expression | Resulting Affinity | Rule Used To Determine Affinity |
| INT INTEGER TINYINT SMALLINT MEDIUMINT BIGINT UNSIGNED BIG INT INT2 INT8 | INTEGER | 1 |
| CHARACTER(20) VARCHAR(255) VARYING CHARACTER(255) NCHAR(55) NATIVE CHARACTER(70) NVARCHAR(100) TEXT CLOB | TEXT | 2 |
| BLOB no datatype specified | BLOB | 3 |
| REAL DOUBLE DOUBLE PRECISION FLOAT | REAL | 4 |
| NUMERIC DECIMAL(10,5) BOOLEAN DATE DATETIME | NUMERIC | 5 |