Handling null values

I don't want to turn this into a why MariaDB is bad chapter, but I wanted to add a final example here, which I consider to be of high importance:

MariaDB [test]> UPDATE data SET id = NULL WHERE id = 1;Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 1

Remember, the id column was explicitly marked as NOT NULL:

MariaDB [test]> SELECT * FROM data; +----+------+ | id | data | +----+------+ | 0  | 9.99 | +----+------+ 1 row in set (0.00 sec)

Obviously, MySQL and MariaDB think that null and zero are the same thing. Let me try to explain the problem with a simple analogy: if you know your wallet is empty, it is not the same as not knowing how much you have. As I am writing these lines, I don't ...

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.