Trying to modify a constraint in PostgreSQL

后端 未结 4 1507
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 11:57

I have checked the documentation provided by Oracle and found a way to modify a constraint without dropping the table. Problem is, it errors out at modify as it does not recogn

4条回答
  •  醉话见心
    2021-02-01 12:26

    There is no ALTER command for constraints in Postgres. The easiest way to accomplish this is to drop the constraint and re-add it with the desired parameters. Of course any change of the constraint will be run against the current table data.

    BEGIN;
    ALTER TABLE t1 DROP CONSTRAINT ...
    ALTER TABLE t1 ADD CONSTRAINT ...
    COMMIT;
    

提交回复
热议问题