salamey
salamey

Reputation: 3811

ON DELETE CASCADE does not work

I have created two tables within a MySql database:

create table scope (
    name_scope varchar(50) not null primary key,
    description varchar(100)
);

create table value_scope (
    id_value int not null primary key AUTO_INCREMENT,
    name_scope    varchar(50) not null,
    value varchar(100) not null, 
    foreign key (name_scope) references scope(name_scope) ON DELETE CASCADE
);

A scope can have multiple values. When I delete a scope; I expect its respective values to be deleted as well, but nothing happens. I try to do it the opposite way, but the scope still exists.

What am I doing wrong?

Upvotes: 0

Views: 272

Answers (1)

Sajid
Sajid

Reputation: 11

MyISAM does not support referential integrity.Use InnoDB instead.

Upvotes: 1

Related Questions