Why ever declare a column `NOT NULL DEFAULT ‘-’`?

Jason Dusek
The Lyf So Short
Published in
2 min readJul 16, 2017

--

When NULL values are present, a row can both not match a predicate, and not match its opposite.

It can be confusing to remember the consequences of SQL’s three-valued logic. One hears that NOT NULL can be good for query performance — it allows the database to make certain optimizations — but better performance is not the real reason to set columns NOT NULL as a general practice. Even when a column occasionally has no meaningful value, it can be better to declare it NOT NULL with a default valuing signifying nil, like DEFAULT ‘-’.

--

--