truncate all tables in SQL database code example
Example 1: sql truncate table
-- Quick, no possible rollback
TRUNCATE TABLE my_table;
-- With rollback
DELETE FROM my_table;
COMMIT;
Example 2: truncate all tables
SELECT Concat('TRUNCATE TABLE ',table_schema,'.',TABLE_NAME, ';')
FROM INFORMATION_SCHEMA.TABLES where table_schema in ('db1_name','db2_name');