Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Except 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?


The most annoying is having to order by DESC NULLS LAST to get the largest value from an aggregation.


I feel like the same, Null equal null is null is totally right


I feel like a select for:

- col1 = 1 should not return NULLS

- !(col1 = 1) should return NULLS

- col1 <> 1 should not return NULLS


Agreed. 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: