PostgreSQL composite primary key

前端 未结 3 1841
天命终不由人
天命终不由人 2020-12-02 20:05

In MySQL, when I create a composite primary key, say with columns X, Y, Z, then all three columns become indexes automatically. Does the same happen for Postgre

3条回答
  •  情歌与酒
    2020-12-02 21:04

    Yes:

    PostgreSQL automatically creates a unique index when a unique constraint or primary key is defined for a table. The index covers the columns that make up the primary key or unique constraint (a multicolumn index, if appropriate), and is the mechanism that enforces the constraint.

提交回复
热议问题