Add option to Remove Foreign key checks on trucate
Would it be possible to add an option in the table menu that would remove foreign key checks, truncate the table and then add the foreign key checks again.
SET FOREIGN_KEY_CHECKS = 0;
SET FOREIGN_KEY_CHECKS = 1;
The options could be places after the menu option "Empty table(s)..."
Disable foreign key checks while truncating tables. See http://www.heidisql.com/forum.php?t=17587
I don't really care for the data at this point but I do need sometimes to truncate the table, without this option I always have to create a query to disable foreign key checks.
That is why I suggested adding an option under Empty Tables. So that the user knows that he is asking to disable foreign key checks before truncating. Maybe an option named Empty Tables (disable FKC) or something like that.
What I would find most useful is for the Empty Table action to run DELETE followed by TRUNCATE. This could be optional, since on very large tables this would take a lot of time. But anyway, I don't see any other (quick) way of deleting all rows without breaking data integrity so for me personally this could even be the default - Heidi could also intelligently check first if there any other tables in the db that have FKs pointing to the table and use DELETE only if there are any - but I don't know if this would be worth the trouble. Or at least use DELETE only for innodb tables. Or - if there is a large number of rows in the table (like >100 000) then give a warning before emptying so that the user has to accept the potential for slow operation.
Has this already been implemented?
Because an option that applies "SET FOREIGN_KEY_CHECKS = 0" would be very useful before running TRUNCATE through the "Empty table" on context menu option.
I think this feature should exist, perhaps an optional feature in the application settings, and the responsibility for incorrect / accidental use should be solely to the user.
Please login to leave a reply, or register at first.