发布网友 发布时间:2022-04-20 21:09
共3个回答
懂视网 时间:2022-04-08 08:16
MySQL删除数据库中所有表的方法:
-- 切换到要删除表的数据库 USE REPLACE_WITH_DATABASE_NAME_YOU_WANT_TO_DELETE; -- 删除所有表 SET FOREIGN_KEY_CHECKS = 0; SET GROUP_CONCAT_MAX_LEN=32768; SET @tables = NULL; SELECT GROUP_CONCAT(‘`‘, table_name, ‘`‘) INTO @tables FROM information_schema.tables WHERE table_schema = (SELECT DATABASE()); SELECT IFNULL(@tables,‘dummy‘) INTO @tables; SET @tables = CONCAT(‘DROP TABLE IF EXISTS ‘, @tables); PREPARE stmt FROM @tables; EXECUTE stmt; DEALLOCATE PREPARE stmt; SET FOREIGN_KEY_CHECKS = 1; -- 删除所有视图 SET FOREIGN_KEY_CHECKS = 0; SET GROUP_CONCAT_MAX_LEN=32768; SET @views = NULL; SELECT GROUP_CONCAT(‘`‘, TABLE_NAME, ‘`‘) INTO @views FROM information_schema.views WHERE table_schema = (SELECT DATABASE()); SELECT IFNULL(@views,‘dummy‘) INTO @views; SET @views = CONCAT(‘DROP VIEW IF EXISTS ‘, @views); PREPARE stmt FROM @views; EXECUTE stmt; DEALLOCATE PREPARE stmt; SET FOREIGN_KEY_CHECKS = 1;
本文出自 “GONE WITH THE WIND” 博客,请务必保留此出处http://h2appy.blog.51cto.com/609721/1676871
MySQL中所有表的方法
标签:mysql 删除
热心网友 时间:2022-04-08 05:24
1、如果该表数据较少,可以执行sql语句:delete from tablename;热心网友 时间:2022-04-08 06:42
方法一:drop database 然后create database