首页 > 代码库 > You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine.
You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine.
w
https://dev.mysql.com/doc/refman/5.7/en/create-index.html
MySQL :: MySQL 5.7 Reference Manual :: B.5.4.3 Problems with NULL Values
https://dev.mysql.com/doc/refman/5.7/en/problems-with-null.html
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.
MySQL :: MySQL 5.7 Reference Manual :: 14.1.14 CREATE INDEX Syntax
https://dev.mysql.com/doc/refman/5.7/en/create-index.html
The MyISAM
, InnoDB
, NDB
, and ARCHIVE
storage engines support spatial columns such as (POINT
and GEOMETRY
. (Section 12.5, “Extensions for Spatial Data”, describes the spatial data types.) However, support for spatial column indexing varies among engines. Spatial and nonspatial indexes are available according to the following rules.
Spatial indexes (created using SPATIAL INDEX
) have these characteristics:
-
Available only for
MyISAM
andInnoDB
tables. SpecifyingSPATIAL INDEX
for other storage engines results in an error. -
Indexed columns must be
NOT NULL
. -
Column prefix lengths are prohibited. The full width of each column is indexed.
Characteristics of nonspatial indexes (created with INDEX
, UNIQUE
, or PRIMARY KEY
):
-
Permitted for any storage engine that supports spatial columns except
ARCHIVE
. -
Columns can be
NULL
unless the index is a primary key. -
For each spatial column in a non-
SPATIAL
index exceptPOINT
columns, a column prefix length must be specified. (This is the same requirement as for indexedBLOB
columns.) The prefix length is given in bytes. -
The index type for a non-
SPATIAL
index depends on the storage engine. Currently, B-tree is used. -
You can add an index on a column that can have
NULL
values only forInnoDB
,MyISAM
, andMEMORY
tables. -
You can add an index on a
BLOB
orTEXT
column only for using theInnoDB
andMyISAM
tables. -
When the
innodb_stats_persistent
setting is enabled, run theANALYZE TABLE
statement for anInnoDB
table after creating an index on that table.
You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine.