Do not set a primary key table when MySQL was built

In mysql technical documentation which has the following text:

          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. 

Translated: If you do not take the initiative to set the primary key, it will select the first unique index does not contain a NULL column as the primary key column, and use it as a clustered index. If no such index will be used to generate a clustered index line numbers, to serve as the primary key, the line number 6bytes, self-energizing. You can select _rowid from table to query.

Guess you like

Origin www.cnblogs.com/kevin-lee123/p/11519585.html