2016-03-22 24 views
1

我有上有這個FOREIGN KEY約束的accounts表:爲什麼我不能爲我的帳戶表放棄這個FOREIGN KEY約束?

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命令來查看它。這是爲什麼發生?

------------- ----------- EDIT

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...... 
+0

我在該輸出中看不到名爲'edits_account_id_fkey1'的約束。 –

回答

2

該約束被放置在桌子上edits,但是你正在改變表accounts。在查詢中將accounts更改爲edits,然後它將起作用。

相關問題