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 |
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 |