Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

STRICT Tables

If you really want, you can defined a table to be STRICT, but you need to do that on a per-table basis and the data types you can use are limited.

  • INT
  • INTEGER
  • REAL
  • TEXT (UTF-8)
  • BLOB (for binary)
  • ANY
CREATE TABLE strict_data (
    id INTEGER,
    name TEXT,
    height REAL
) STRICT;

INSERT INTO strict_data (id, name, height) VALUES (1, 'foo', 1.8);
INSERT INTO strict_data (id, name, height) VALUES ('2', 'bar', '2.1');

INSERT INTO strict_data (id, name, height) VALUES ('three', 'Jane', 1.3);
-- Runtime error near line 10: cannot store TEXT value in INTEGER column strict_data.id (19)

SELECT * from strict_data;


$ sqlite < examples/strict-table.out
Error near line 10: cannot store TEXT value in INTEGER column strict_data.id
1|foo|1.8
2|bar|2.1