正如在理论书籍中这两个术语用于解释索引一样,但在实践中,当我尝试在也是主键的特定字段上创建索引时,MySQL 会生成警告,尽管索引已创建。mysql warning : primary key and index on the same field in MYSQL .
谁能解释一下吗?
最佳答案
主键已经意味着构成该键的列集上的索引,因此需要第二个(单独的)索引 is redundant :
The primary key for a table represents the column or set of columns that you use in your most vital queries. It has an associated index, for fast query performance.
因此,通过创建显式索引,您不会获得任何好处,反而会让数据库承担维护两个单独索引的责任。
关于MySQL警告: primary key and index on the same field in MYSQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19209863/