Lacking Natural Simplicity

Random musings on books, code, and tabletop games.

sqlite implements table constraints

It's nice to see SQLite supports table constraints:

$ sqlite3 test.db
SQLite version 3.6.19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t1
   ...> (k int,
   ...>  s int,
   ...>  e int,
   ...>  d int,
   ...>  constraint se_or_duration check
   ...>    ((s is not null and e is not null) or d is not null));
sqlite> insert into t1 values (1, 8, 4, null);
sqlite> insert into t1 values (2, null, null, 8);
sqlite> insert into t1 values (3, null, null, null);
SQL error: constraint failed
sqlite>
Print Friendly and PDF

Comments

Comments powered by Disqus