mysql null 和索引
在mysql中如果要在有null值的列上创建索引,存储引擎必须使用MyISAM
, InnoDB
, 或者 MEMORY。如果不是这三种中的一个,那么被索引的列必须是not null;
官方文档:https://dev.mysql.com/doc/refman/5.5/en/problems-with-null.html
You can add an index on a column that can have
NULL
values if you are using theMyISAM
,InnoDB
, orMEMORY
storage engine. Otherwise, you must declare an indexed columnNOT NULL
, and you cannot insertNULL
into the column.