Created
August 21, 2023 14:21
-
-
Save portnov/a58596ce86b68e81e623df6515d59781 to your computer and use it in GitHub Desktop.
delete cascade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table tst_t1 ( | |
id int not null primary key, | |
name text | |
); | |
create table tst_a ( | |
id int not null primary key, | |
t1id int references tst_t1 on delete cascade, | |
name text | |
); | |
create table tst_b ( | |
id int not null primary key, | |
aid int references tst_a on delete cascade, | |
name text | |
); | |
create table tst_d ( | |
id int not null primary key, | |
t1id int references tst_t1 on delete cascade, | |
name text | |
); | |
create table tst_c ( | |
id int not null primary key, | |
bid int references tst_b on delete cascade, | |
did int references tst_d on delete restrict, | |
name text | |
); | |
insert into tst_t1 (id, name) values (1, 'T1'); | |
insert into tst_a (id, t1id, name) values (1, 1, 'A'); | |
insert into tst_b (id, aid, name) values (1, 1, 'B'); | |
insert into tst_d (id, t1id, name) values (1, 1, 'D'); | |
insert into tst_c (id, bid, did, name) values (1, 1, 1, 'C'); | |
delete from tst_t1 where id = 1; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment