Using NULL in MySQL

The data in my dabatase comes from an external source and where ever there is no data, I store it NULLin these places. Can someone tell me if there are any consequences when used NULLto represent an empty value? Should I follow another agreement, for example 'data_not_available'? or something like that?

Can anyone suggest?

+3
source share
3 answers

I have always used NULL. I saw the argument that NULL was hacked and should never have been used in normal mode, and now it has gotten out of control, but I can’t think of a better way to handle something as “without value”.

, ? 0 - . -1 - . -9999999 - .

NULL, , .

+2

NULL SQL . NULL , , FK.

+1

, NULL " ", , . , NULL MySQL, , =, <, < > .

Since you will have columns that may have “missing or fuzzy” values, you must set them to accept NULL. On the other hand, a table with many NULL columns may indicate that this table needs to be converted into smaller tables that better describe the entities they represent.

Please note that, in general, using an agreement like 'data_not_available' is not recommended. Using NULL is a convention, and your DBMS already knows about it.

+1
source

Source: https://habr.com/ru/post/1734859/


All Articles