MySQL: Delete/Truncate Table Data with Foreign-Primary Key Pairs

Submitted by Peter Majmesku on Tue, 04/18/2017 - 15:41

Login into your database via command line (mysql -uuser -ppassword) and type the following commands.

use mytable;
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE table1;
SET FOREIGN_KEY_CHECKS = 1;
Tags