主键是否在 MySQL 中自动索引?
问题描述:
是否需要显式创建索引,还是在定义主键时隐式创建?MyISAM 和 InnoDB 的答案是否相同?
Do you need to explicitly create an index, or is it implicit when defining the primary key? Is the answer the same for MyISAM and InnoDB?
答
主键总是被索引的.这对于 MyISAM 和 InnoDB 是相同的,并且对于所有支持索引的存储引擎通常都是如此.
The primary key is always indexed. This is the same for MyISAM and InnoDB, and is generally true for all storage engines that at all supports indices.