Truncate all tables (most of which have constraints). How to temoprarily drop them?

I think you can do the following: Disable the foreign key constraint check mysql> SET FOREIGN_KEY_CHECKS = 0 Truncate your tables mysql> TRUNCATE MY_TABLE Enable the foreign key constraint check mysql> SET FOREIGN_KEY_CHECKS = 1 I prefer disabling the foreign key constraints temporarily to dropping/recreating them.

I think you can do the following: Disable the foreign key constraint check mysql> SET FOREIGN_KEY_CHECKS = 0; Truncate your tables mysql> TRUNCATE MY_TABLE; Enable the foreign key constraint check mysql> SET FOREIGN_KEY_CHECKS = 1; I prefer disabling the foreign key constraints temporarily to dropping/recreating them.

If you want truncate REALLY all tables better way i'm think drop and create database with previously extracted database schema. Or you just can two copy of same database - test and empty. After filling your tables, just delete test db and copy empty to test.

TRUNCATE (TABLE) tbl_name will truncate a single table. You can stick that in a script and loop through it with all of your table names. dev.mysql.com/doc/refman/5.0/en/truncate... You may want to look into migrations, too, but I think Alexey has the right approach there.It's very similar to how RoR handles rebuilding the test database on each run.

I would like to delete the content of all tables. What is the best way, as automated as possible, to delete the content of all tables (including those that have foreign key constraints). Is there a truncate all/ drop all equivalent constraints?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions