MySQL creates a clustered index automatically when I create a primary key.
But is there a situation where MySQL creates a nonclustered index automatically?
MySQL creates a clustered index automatically when I create a primary key.
But is there a situation where MySQL creates a nonclustered index automatically?
PRIMARY KEY
is a UNIQUE
key; it is also "clustered". (Note: Clustered)UNIQUE
key containing only non-NULL column(s) is effectively promoted to be the PK.If that fails, a hidden 6-byte number is used for the PK.
A UNIQUE
key is an INDEX
, plus a uniqueness constraint. (Note: may be clustered)
INDEX
is a BTree that is used for efficient access.FOREIGN
key creates an INDEX
if there is not already a suitable index. (Note: Non-clustered)The 3 "Notes" are implicitly-created indexes, but not necessarily non-clustered.