Not empty string constraint in SQLite

constraints, sqlite

Solution

Yes you can:

sqlite> create table foo (bar TEXT, CHECK(bar <> ''));
sqlite> insert into foo values (NULL);
sqlite> insert into foo values ('bla');
sqlite> insert into foo values ('');
Error: constraint failed

Problem

Can I create a database constraint on a TEXT column in SQLite disallowing the value of the column to be empty string ""? I want to allow the column to be null, but disallow empty string.

Original source