Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top