In Postgresql, force unique on combination of two columns

后端 未结 4 2084
故里飘歌
故里飘歌 2020-12-23 00:23

I would like to set up a table in PostgreSQL such that two columns together must be unique. There can be multiple values of either value, so long as there are not two that s

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 00:51

    Seems like regular UNIQUE CONSTRAINT :)

    CREATE TABLE example (
    a integer,
    b integer,
    c integer,
    UNIQUE (a, c));
    

    More here

提交回复
热议问题