testdb=# \d test.sample ユニーク制約

testdb=# \d sample
                     Table "test.sample"
  Column   |  Type   | Collation | Nullable |    Default     
-----------+---------+-----------+----------+----------------
 id        | integer |           | not null | 
 name      | text    |           |          | 
 address   | text    |           |          | 
 groupname | text    |           |          | '営業部'::text
 memo      | text    |           |          | 
Indexes:
    "sample_pkey" PRIMARY KEY, btree (id)
    "sample_name_key" UNIQUE CONSTRAINT, btree (name)

ユニーク制約の削除

testdb=# ALTER TABLE sample DROP CONSTRAINT sample_name_key;
ALTER TABLE

ユニーク制約を設定

ALTER TABLE sample ADD UNIQUE(name);

いいなと思ったら応援しよう!