How can I empty the contents of all tables in my database in phpMyAdmin without dropping any of the tables in the database?
Since I do this several times an hour while i
You can delete all data from phpmyadmin function easily. Maybe this feature didn't exists during 2010 when this question was posted, but I feel all beginners can refer to this.
Delete all data from database
Actually, went deeper and wrote this:
SET @command:='';
SELECT @command:=CONCAT(@command, 'TRUNCATE TABLE ',T.TABLE_NAME,';')
FROM INFORMATION_SCHEMA.tables T
WHERE T.table_type = 'BASE TABLE' AND T.table_schema='YOUR_TABLE_SCHEMA';
PREPARE bye_world FROM @command;
EXECUTE bye_world;
DEALLOCATE PREPARE bye_world;
It selects all table names from provided schema YOUR_TABLE_SCHEMA
and puts them into a @command
user variable, forming a query for each one like this: TRUNCATE TABLE TABLE_NAME;
Then i just prepare selected statement and execute it. Note, that you must declare user variable before query, or it will be 0
and mess up our statement.
Tutorial
Using MySQL DROP TABLE To Remove Existing Tables
IMHO the easiest solution is:
We can truncate all tables data by phpMyAdmin actually!
In phpMyAdmin, you can do it as following steps:
1) select u DB and do Export operation as this way:
select Custom Export method
By this step, phpMyAdmin helps us create one sql script of full list of all tables
3) do Import operation to delete and create each blank table one by one by this script