Postgresql 为什么可以';我不能删除accounts表的外键约束吗?
我有一个Postgresql 为什么可以';我不能删除accounts表的外键约束吗?,postgresql,Postgresql,我有一个accounts表,该表具有此外键约束: TABLE "edits" CONSTRAINT "edits_account_id_fkey1" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE 我想删除此约束,但每次尝试执行以下命令时: ALTER TABLE accounts DROP CONSTRAINT edits_account_id_fkey1; 我得到这个错误: ERROR: constr
accounts
表,该表具有此外键
约束:
TABLE "edits" CONSTRAINT "edits_account_id_fkey1" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
我想删除此约束,但每次尝试执行以下命令时:
ALTER TABLE accounts DROP CONSTRAINT edits_account_id_fkey1;
我得到这个错误:
ERROR: constraint "edits_account_id_fkey1" of relation "accounts" does not exist
它显然存在。我正在使用\d accounts
命令查看它。为什么会这样
-------------编辑-----------
账户
Indexes:
........
Check constraint:
......
Foreign-key constraints:
"accounts_about_markup_id_fkey" FOREIGN KEY (about_markup_id) REFERENCES markups(id) ON DELETE CASCADE
"accounts_best_vita_id_fkey" FOREIGN KEY (best_vita_id) REFERENCES vitae(id)
"accounts_organization_id_fkey" FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE
Referenced by:
TABLE "account_reports" CONSTRAINT "account_reports_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "actions" CONSTRAINT "actions_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "api_keys" CONSTRAINT "api_keys_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "authorizations" CONSTRAINT "authorizations_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "positions" CONSTRAINT "claims_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "duplicates" CONSTRAINT "duplicates_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
TABLE "old_edits" CONSTRAINT "edits_account_id_fkey" FOREIGN KEY (account_id) REFERENCES accounts(id)
TABLE "edits" CONSTRAINT "edits_account_id_fkey1" FOREIGN KEY (account_id) REFERENCES accounts(id) ON DELETE CASCADE
etc...... etc......
约束放置在表
编辑
,但您正在更改表帐户
。将查询中的accounts
更改为edits
,然后它就会工作。我在该输出中没有看到名为edits\u account\u id\u fkey1
的约束。