Is there a query (command) to truncate all the tables in a database in one operation? I want to know if I can do this with one single query.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
I am not sure but I think there is one command using which you can copy the schema of database into new database, once you have done this you can delete the old database and after this you can again copy the database schema to the old name.
Use phpMyAdmin in this way:
If you want to ignore foreign key checks, you can uncheck the box that says:
You'll need to be running atleast version 4.5.0 or higher to get this checkbox.
Its not MySQL CLI-fu, but hey, it works!
here for i know here
If cannot delete or update a parent row: a foreign key constraint fails
That happens if there are tables with foreign keys references to the table you are trying to drop/truncate.
Before truncating tables All you need to do is:
Truncate your tables and change it back to
user this php code
check detail here link
An idea could be to just drop and recreate the tables?
EDIT:
@Jonathan Leffler: True
Other Suggestion (or case you dont need to truncate ALL tables):
Why not just create a basic stored procedure to truncate specific tables
I found it most simple to just do something like the code below, just replace the table names with your own. important make sure the last line is always SET FOREIGN_KEY_CHECKS=1;