

See below a script that would generate the script to carry out the above operations. Once data truncation is carried out, create the same foreign key constraints again on the same table.

Optionally, use the optimize table (in mysql, innodb engine esp) to reclaim the used data space/size to OS after data truncation.So, all foreign key constraints must be dropped initially followed by table truncation.To truncate a table, one must drop the foreign key constraints mapped to the columns in this table from other tables (in fact on all tables in the specific DB/Schema).
