Can I have create an InnoDB table without a PK? If so, would a secondary index be used as the clustered index?

StackOverflow https://stackoverflow.com/questions/5494565

Pergunta

Is it possible to create an InnoDB table without a Primary Key?

Since InnoDB tables are structured as clustered index around the PK, what would be the structure of a table without PK? Would that table still be a clustered index, but around a secondary key?

Thanks.

Foi útil?

Solução

http://www.sqlinfo.net/mysqldocs/v50/storage-engines.html#innodb-table-and-index

14.2.13. InnoDB Table and Index Structures

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top