In standard SQL, I believe the easiest way to do this is to You have to drop the constraint first, then add the correct version. I'm pretty sure you can't simply add on delete cascade to an existing foreign key constraint. UPDATE: Thank you, and also I've got the advice at the mailing list, that I could manage it in 1 statement and thus without explicitly starting a transaction: ALTER TABLE public.scores TABLE "status" CONSTRAINT "status_id_fkey" FOREIGN KEY (id) REFERENCES users(id)Īnd also I wonder if it makes sense to add 2 index'es to the former table? TABLE "scores" CONSTRAINT "scores_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "rep" CONSTRAINT "rep_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "rep" CONSTRAINT "rep_author_fkey" FOREIGN KEY (author) REFERENCES users(id) TABLE "payment" CONSTRAINT "payment_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "pass" CONSTRAINT "pass_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "money" CONSTRAINT "money_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "misere" CONSTRAINT "misere_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "match" CONSTRAINT "match_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "luck" CONSTRAINT "luck_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "hand" CONSTRAINT "hand_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "game" CONSTRAINT "game_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "chat" CONSTRAINT "chat_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "catch" CONSTRAINT "catch_id_fkey" FOREIGN KEY (id) REFERENCES users(id) TABLE "cards" CONSTRAINT "cards_id_fkey" FOREIGN KEY (id) REFERENCES users(id) Login | timestamp without time zone | default now() TABLE "scores" CONSTRAINT "scores_gid_fkey" FOREIGN KEY (gid) REFERENCES games(gid) Gid | integer | not null default nextval('games_gid_seq'::regclass)įinished | timestamp without time zone | default now() "scores_id_fkey" FOREIGN KEY (id) REFERENCES users(id)īoth referenced tables are below - here: # \d games "scores_gid_fkey" FOREIGN KEY (gid) REFERENCES games(gid) Version locking: Version will not be verified on deletion of cascaded object.Įvents: Deletion events may not be executed on the cascaded objects if the objects are not loaded.Ĭascading: The remove operation should still be configured to cascade in the mapping if using CascadeOnDelete.Įxample 2-18 shows the cascading deletion of the Employee secondary table and all of its owned relationships.In PostgreSQL 8 is it possible to add ON DELETE CASCADES to the both foreign keys in the following table without dropping the latter? # \d scores ManyToMany: SQL will not be executed to delete from the join table.ĮlementCollection: SQL will not be executed to delete from the collection table.Ĭache: Cascaded objects will still be removed from the cache and persistence context. OneToMany: If the mapping uses cascading or orphanRemoval, SQL will not be executed to delete target objects. OneToOne: If the mapping uses cascading or orphanRemoval, SQL will not be executed to delete target object. The deletion of the collection table is cascaded on the has the following behavior:ĭDL generation: If DDL generation is used, the generated constraint will include the cascade deletion option.Įntity: Remove will not execute SQL for deletion from secondary or joined inheritance tables (as constraint will handle deletion). The deletion of the join table is cascaded on the database (target objects cannot be cascaded even if private because of constraint direction). This is only allowed for mappedBy/target-foreign key OneToOne mappings (because of constraint direction).įor a OneToMany using a mappedBy or JoinColumn, the deletion of the related objects is cascaded on the database.įor a OneToMany using a JoinTable, the deletion of the join table is cascaded on the database (target objects cannot be cascaded even if private because of constraint direction). The deletion of the related object is cascaded on the database. Table 2-8 Using on Different Elements ElementĮffect of that secondary or joined inheritance tables should cascade the delete on the database
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |