In Postgresql, force unique on combination of two columns

后端 未结 4 2083
故里飘歌
故里飘歌 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:35

    Create unique constraint that two numbers together CANNOT together be repeated:

    ALTER TABLE someTable
    ADD UNIQUE (col1, col2)
    

提交回复
热议问题