尝试修改PostgreSQL中的约束

前端之家收集整理的这篇文章主要介绍了尝试修改PostgreSQL中的约束前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Postgres最近变得非常烦人。

我已经检查了Oracle提供的文档,并找到了一种方法,而不会丢弃表。问题是,它在修改时出错,因为它不能识别关键字。
使用EMS sql Manager for Postgresql

Alter table public.public_insurer_credit MODIFY CONSTRAINT public_insurer_credit_fk1
    deferrable,initially deferred;

我可以通过删除约束来解决它:

ALTER TABLE "public"."public_insurer_credit"
  DROP CONSTRAINT "public_insurer_credit_fk1" RESTRICT;

ALTER TABLE "public"."public_insurer_credit"
  ADD CONSTRAINT "public_insurer_credit_fk1" FOREIGN KEY ("branch_id","order_id","public_insurer_id")
    REFERENCES "public"."order_public_insurer"("branch_id","public_insurer_id")
    ON UPDATE CASCADE
    ON DELETE NO ACTION
    DEFERRABLE 
    INITIALLY DEFERRED;
根据正确的手册(由Postgresql提供,不是由Oracle提供),ALTER TABLE语句中没有可用的修改约束:

以下是正确手册的链接

http://www.postgresql.org/docs/current/static/sql-altertable.html

猜你在找的Postgre SQL相关文章