本文介绍了尝试在PostgreSQL中修改约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我检查了Oracle提供的文档,并找到了一种无需删除表即可修改约束的方法。问题是,由于无法识别关键字,因此在修改时出错。
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 recognize the keyword.
使用PostgreSQL的EMS SQL Manager。
Using 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", "order_id", "public_insurer_id")
ON UPDATE CASCADE
ON DELETE NO ACTION
DEFERRABLE
INITIALLY DEFERRED;
推荐答案
根据正确的手册(由PostgreSQL提供) ,不是),ALTER TABLE语句中没有修改约束:
According to the correct manual (which is supplied by PostgreSQL, not by Oracle), there is no modify constraint available in the ALTER TABLE statement:
以下是正确手册的链接:
Here is the link to the correct manual:
这篇关于尝试在PostgreSQL中修改约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!