Does MySQL index NULL values?

前端 未结 6 1236
再見小時候
再見小時候 2020-12-04 21:17

I have a MySQL table where an indexed INT column is going to be 0 for 90% of the rows. If I change those rows to use NULL instead of 0, will they b

6条回答
  •  無奈伤痛
    2020-12-04 21:25

    Just to bring more information to this topic. Take a look what kind of storage engine your table is using first.

    You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine. Otherwise, you must declare an indexed column NOT NULL, and you cannot insert NULL into the column.

    https://dev.mysql.com/doc/refman/8.0/en/problems-with-null.html

提交回复
热议问题