On 1/24/19 12:35 AM, Nagy László Zsolt wrote:Hello, I have deferred the only fk constraint to this table inside a transaction, but I still cannot delete rows from it. How is that possible? master=> ALTER TABLE doc.display_mode disable trigger user; ALTER TABLE master=> BEGIN; BEGIN master=> SET CONSTRAINTS doc.fk_book_display_mode_id DEFERRED; SET CONSTRAINTS master=> DELETE FROM doc.display_mode; ERROR: update or delete on table "display_mode" violates foreign key constraint "fk_book_display_mode_id" on table "book" DETAIL: Key (id)=(1) is still referenced from table "book". master=> Deferring a constraint doesn't mean "disappearing" the constraint; it just means... deferring it until later (i.e. commit time). It's only purpose is to allow your code to delete from doc.display_mode before deleting from book . But you do have to delete from book at some point in the transaction. --
Angular momentum makes the world go 'round. |