A
A
Alexey2020-07-25 19:51:33
MySQL
Alexey, 2020-07-25 19:51:33

How to undo cascading deletion by foreign key?

Table creation:

CREATE TABLE book (
    book_id INT PRIMARY KEY AUTO_INCREMENT,    
    title VARCHAR(50),
    author_id INT,
    genre_id INT,
    price DECIMAL(8, 2),
    amount INT,
    FOREIGN KEY (author_id)  REFERENCES author (author_id) ON DELETE CASCADE,
    FOREIGN KEY (genre_id)  REFERENCES genre (genre_id) ON DELETE SET NULL
 );

How, with the help of another query, when deleting information from one table, cancel the cascading deletion in the related one?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2020-07-25
@6alexey9

Only change the link property to ON DELETE SET NULL.

K
Konstantin Tsvetkov, 2020-07-25
@tsklab

Delete and create again. Documentation .

L
Lazy @BojackHorseman MySQL, 2020-07-25
Tag

SET foreign_key_checks = 0;
but I won't say. google

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question