Answer the question
In order to leave comments, you need to log in
Are rows from dependent tables deleted in a single/general transaction?
On fingers. There are 2 tables connected by a relation:
CREATE TABLE `post` (
`id` int(11) NOT NULL AUTO_INCREMENT,
..
PRIMARY KEY (`id`)
);
CREATE TABLE `post_comment` (
`post_id` int(11) NOT NULL,
...
FOREIGN KEY (`post_id`) REFERENCES `post`(`id`) ON DELETE CASCADE
);
DELETE FROM `post` WHERE `id` = 1
Answer the question
In order to leave comments, you need to log in
postgres:
Actually, yes, FOR UPDATE row-level lock is always taken when delete is done on a row, reference does not affect this.
You can look at the loci like this.
From one psql console we do
BEGIN;
delete from post where id = 1;
BEGIN;
select * from post where id = 1 for update;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question