更新时间:2022-12-08 12:23:17
基本上,主键是(在实现级别)一种特殊的索引。具体来说:
Basically, a primary key is (at the implementation level) a special kind of index. Specifically:
UNIQUE
- 你不能有多个具有相同主键的行,因为它的目的是唯一地标识行。 NULL
,所以它所包含的行必须是NOT NULL UNIQUE
- you cannot have more than one row with the same primary key, since its purpose is to uniquely identify rows.NULL
, so the row(s) it consists of must be NOT NULL一个表可以有多个索引,索引不一定是 UNIQUE
。索引存在有两个原因:
A table can have multiple indexes, and indexes are not necessarily UNIQUE
. Indexes exist for two reasons: