PostgreSQL: default constraint names

后端 未结 2 794
误落风尘
误落风尘 2020-12-12 09:01

When creating a table in PostgreSQL, default constraint names will assigned if not provided:

CREATE TABLE example (
    a integer,
    b integer,
    UNIQUE          


        
2条回答
  •  天命终不由人
    2020-12-12 09:06

    The manual is pretty clear about this ("tableconstraint: This form adds a new constraint to a table using the same syntax as CREATE TABLE.")

    So you can simply run:

    ALTER TABLE example ADD UNIQUE (a, b);
    

提交回复
热议问题