NitroSQLite
Concepts

Tables and values

Rows, constraints, and SQLite storage classes.

A table stores records as rows with named columns. Its schema defines those columns and constraints such as PRIMARY KEY and NOT NULL.

Create a table and read its rows

CREATE TABLE notes (
  id INTEGER PRIMARY KEY,
  body TEXT NOT NULL
);

INSERT INTO notes (body) VALUES ('Buy milk');
SELECT id, body FROM notes;

The primary key identifies each row. NOT NULL prevents a row from storing a missing value in body.

Storage classes and type affinity

SQLite values have five storage classes: NULL, INTEGER, REAL, TEXT, and BLOB. The storage class belongs to the value. In ordinary tables, a column's declared type gives it a type affinity, which influences conversion without generally enforcing one storage class. STRICT tables enforce column types.

SQLite stores booleans as the integers 0 and 1. It has no separate date storage class; applications can represent dates as text or numbers. See SQLite's datatype guide.

For binding values and reading JavaScript results in Nitro SQLite, see parameters and results.

On this page