The primary key for a table represents the column or set of columns that you use in your most vital queries. 表的主键表示在最重要的查询中使用的列或列集。It has an associated index, for fast query performance. 它有一个关联索引,用于快速查询性能。Query performance benefits from the 查询性能得益NOT NULL
optimization, because it cannot include any NULL
values. NOT NULL
优化,因为它不能包含任何NULL
值。With the 利用InnoDB
storage engine, the table data is physically organized to do ultra-fast lookups and sorts based on the primary key column or columns.InnoDB
存储引擎,表数据被物理组织起来,根据主键列进行超快速的查找和排序。
If your table is big and important, but does not have an obvious column or set of columns to use as a primary key, you might create a separate column with auto-increment values to use as the primary key. 如果表很大且很重要,但没有明显的列或列集用作主键,则可以创建一个单独的列,并使用自动递增值作为主键。These unique IDs can serve as pointers to corresponding rows in other tables when you join tables using foreign keys.当您使用外键联接表时,这些唯一ID可以作为指向其他表中相应行的指针。