Personal website Rudolf Adamkovič

Home / SQLite


Example: Constraining tables to exactly one row

CREATE TABLE t(v, singleton BOOL UNIQUE DEFAULT TRUE CHECK(singleton = TRUE));
INSERT INTO t(v) VALUES (10);
INSERT OR REPLACE INTO t(v) VALUES (20);
SELECT * FROM t;
v singleton
20 1

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.