Last answered:

03 Jul 2023

Posted on:

02 Jul 2023

0

Resolved: What is the explanation for not truncate the table?

1 answers ( 1 marked as helpful)
Instructor
Posted on:

03 Jul 2023

0

Hi Mohamed!
Thanks for reaching out.


You cannot TRUNCATE a table that has FK constraints applied on it (TRUNCATE is not the same as DELETE). Please, use the following code:

SET FOREIGN_KEY_CHECKS = 0; 
TRUNCATE table departments; 
SET FOREIGN_KEY_CHECKS = 1;


Hope this helps.
Best,
Tsvetelin

Submit an answer