What are the main data types supported by SQLite?

Beginner

Answer

SQLite supports five storage classes:

  1. NULL: Null value
  2. INTEGER: Signed integers (1, 2, 3, 4, 6, or 8 bytes)
  3. REAL: Floating-point numbers (8-byte IEEE floating point)
  4. TEXT: Text strings (UTF-8, UTF-16BE, or UTF-16LE encoding)
  5. BLOB: Binary data stored exactly as input

SQLite uses dynamic typing - columns can store any type of data regardless of declared type. However, it's good practice to declare appropriate types for clarity.

CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    age INTEGER,
    salary REAL,
    profile_picture BLOB
);