1.使用CONCAT函数连接组成删除语句
MariaDB [wiki_db]> select concat('drop table if exists ',table_name,';') from information_schema.tables where table_schema='wiki_db';
+--------------------------------------------------+
| concat('drop table if exists ',table_name,';') |
+--------------------------------------------------+
| drop table if exists wiki_user; |
| drop table if exists wiki_actor; |
| drop table if exists wiki_user_groups; |
| drop table if exists wiki_user_former_groups; |
| drop table if exists wiki_user_newtalk; |
| drop table if exists wiki_user_properties; |
| drop table if exists wiki_bot_passwords; |
| drop table if exists wiki_page; |
| drop table if exists wiki_revision; |
| drop table if exists wiki_revision_comment_temp; |
| drop table if exists wiki_revision_actor_temp; |
| drop table if exists wiki_ip_changes; |
| drop

本文介绍了如何使用CONCAT函数在MySQL中构建并执行删除所有表的SQL语句,执行后将清空数据库中的所有表格。
最低0.47元/天 解锁文章
1142

被折叠的 条评论
为什么被折叠?



