When to use NULL in MySQL tables

后端 未结 11 1871
春和景丽
春和景丽 2020-11-29 22:59

I appreciate the semantic meaning of a NULL value in a database table, different from both false and the empty string \'\'. However, I have often read about performance pro

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 23:28

    Any self-respecting database engine these days should offer no penalty for properly using NULLs, unless your query is not designed correctly (which is usually not a problem you'll have very often with regard to NULLs).

    You should pay first attention to using the database (including NULLs) as intended; then worry about the optimizatin consequences when and if they occur.

    The cumulative effect of improperly NULLed column values in both SQL complexity and accuracy will almost surely outweigh the benefits of fooling with Mother DBMS. Besides, it will mess up your head, as well as that of anyone later who tries to figure out what you were trying to do.

提交回复
热议问题