是否可以创建没有主键的 InnoDB 表?
由于 InnoDB 表的结构是围绕 PK 的聚集索引,那么没有 PK 的表的结构会是什么?该表仍然是聚集索引,但围绕辅助键吗?
谢谢。
最佳答案
http://www.sqlinfo.net/mysqldocs/v50/storage-engines.html#innodb-table-and-index
14.2.13。 InnoDB 表和索引结构
If you do not define a PRIMARY KEY for your table, MySQL picks the first UNIQUE index that has only NOT NULL columns as the primary key and InnoDB uses it as the clustered index. If there is no such index in the table, InnoDB internally generates a clustered index where the rows are ordered by the row ID that InnoDB assigns to the rows in such a table. The row ID is a 6-byte field that increases monotonically as new rows are inserted. Thus, the rows ordered by the row ID are physically in insertion order.
关于mysql - 我可以创建一个没有 PK 的 InnoDB 表吗?如果是的话,是否会使用二级索引作为聚集索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5494565/