Mysql How do you create a clustered index?

后端 未结 4 622
温柔的废话
温柔的废话 2020-12-05 19:58

I\'m reading all about how clustered indexes work, and think they would be beneficial to my app. I understand that primary keys are automatically clustered indexes, but how

4条回答
  •  一向
    一向 (楼主)
    2020-12-05 20:45

    When you define a primary key for an InnoDB table, MySQL uses the primary key as the clustered index.

    If you do not have a primary key for a table, MySQL will search for the first UNIQUE index where all the key columns are NOT NULL and use this UNIQUE index as the clustered index.

    In case the InnoDB table has no primary key or suitable UNIQUE index, MySQL internally generates a hidden clustered index named GEN_CLUST_INDEX on a synthetic column which contains the row ID values.

提交回复
热议问题