Remove uniqueness of index in PostgreSQL

后端 未结 5 1312
南笙
南笙 2021-01-31 06:56

In my PostgreSQL database I have a unique index created this way:

CREATE UNIQUE INDEX  ON  USING btree (my_column)
5条回答
  •  死守一世寂寞
    2021-01-31 07:26

    Assume you have the following:

    Indexes:
        "feature_pkey" PRIMARY KEY, btree (id, f_id)
        "feature_unique" UNIQUE, btree (feature, f_class)
        "feature_constraint" UNIQUE CONSTRAINT, btree (feature, f_class)
    

    To drop the UNIQUE CONSTRAINT, you would use ALTER TABLE:

    ALTER TABLE feature DROP CONSTRAINT feature_constraint;
    

    To drop the PRIMARY KEY, you would also use ALTER TABLE:

    ALTER TABLE feature DROP CONSTRAINT feature_pkey;
    

    To drop the UNIQUE [index], you would use DROP INDEX:

    DROP INDEX feature_unique;
    

提交回复
热议问题