The contents of the parent and child tables are:
The child table has the parent_id column that has a foreign key constraint to the id column of
the parent table with ON DELETE CASCADE clause.
Consider the command WHERE id =1;
What is the effect of the above command?
A.
It does not delete anything from any table but returns an error.
B.
It deletes one row from the parent table but does not affect the child table.
C.
It deletes one row from the parent table and two rows from the child table.
D.
It deletes one row from the parent table and sets the parent _id column to NULL in the
child.
C.
C.
create table parent
(
id int primary key
);
create table child
(
id int,
parent_id int,
foreign key (parent_id)
references parent (id)
on delete cascade
);
insert into parent values (1),(2),(3);
insert into child values (1,1),(2,1),(3,2),(4,2),(5,3),(6,3);
select * from parent;
select * from child;
delete from parent where parent.id = 1;
id
‘2’
‘3’
id, parent_id
‘3’, ‘2’
‘4’, ‘2’
‘5’, ‘3’
‘6’, ‘3’
C
http://stackoverflow.com/questions/12185811/mysql-on-delete-cascade-test-example
C
A
sorry , C because cascade in delete