Skip to content

Instantly share code, notes, and snippets.

@jyotendra
Created May 25, 2021 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jyotendra/27191913df9b4cfdb9b4e6d5fb664539 to your computer and use it in GitHub Desktop.
Save jyotendra/27191913df9b4cfdb9b4e6d5fb664539 to your computer and use it in GitHub Desktop.
This sql script helps to drop entire scema from a database
SET FOREIGN_KEY_CHECKS = 0;
SET SESSION group_concat_max_len = 1000000;
SET @TABLES = NULL;
SELECT GROUP_CONCAT('`', table_schema, '`.`', table_name,'`') INTO @TABLES FROM information_schema.tables
WHERE table_schema = 'databaseName';
SET @TABLES = CONCAT('DROP TABLE IF EXISTS ', @TABLES);
PREPARE stmt FROM @TABLES;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET SESSION group_concat_max_len = 1024;
SET FOREIGN_KEY_CHECKS = 1
@jyotendra
Copy link
Author

Credits to original post.

Replace the "databaseName" with name of your DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment