
You cannot TRUNCATE a table that has FK constraints applied on it. Becaue Truncate is not same as DELETE.
We can do that by a very simple sql commands.
SET FOREIGN_KEY_CHECKS = 0; TRUNCATE table $table_name; SET FOREIGN_KEY_CHECKS = 1;
So what does it do
- Remove constraints
- Perform TRUNCATE
- Create constraints
