删除mysql库中所有表
SET FOREIGN_KEY_CHECKS = 0;
-- 生成删除所有表的语句
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = 'your_database_name';
-- 如果存在表,执行删除语句
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;
License:
CC BY 4.0