5 ms·
I actually like how NULLs behave in SQL. They mean "I don't know" In the modern programming language we all care about Null safety. But no matter how you model
by lolpanda 2y ago
I actually like how NULLs behave in SQL. They mean "I don't know" In the modern programming language we all care about Null safety. But no matter how you model your data, you will always run into the situations when you don't know everything. So I believe NOT NULL is not very practical. NULLs in SQL handle these case very well - when the input is unknown your output is unknown
- int_19h 2y agoExcept they don't consistently behave that way. If NULL means "unknown", why do they show up in outer joins, or when you SUM an empty table?
- cglace 2y agoThe most annoying is having to order by DESC NULLS LAST to get the largest value from an aggregation.
- dalton_zk 2y agoI feel like the same, Null equal null is null is totally right
- afiori 2y agoI feel like a select for: - col1 = 1 should not return NULLS - !(col1 = 1) should return NULLS - col1 <> 1 should not return NULLS
- kijin 2y agoAgreed. If SQL didn't have NULL, we'd have other special values meaning "I don't know" or "no data" all over the place. Too many newbies hear that NULL is bad, so they declare all columns as NOT NULL and end up inserting ad hoc values like 0, -1, '', or {} when they inevitably come across cases where they don't have data. Which is even worse than NULL.