Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Stored procedure
- DELIMITER //
- CREATE PROCEDURE `drop_tables` ()
- LANGUAGE SQL
- DETERMINISTIC
- SQL SECURITY DEFINER
- COMMENT 'A procedure'
- BEGIN
- SET @db = NULL;
- SET FOREIGN_KEY_CHECKS = 0;
- SET @tables = NULL;
- SELECT DATABASE() INTO @db;
- SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
- FROM information_schema.tables
- WHERE table_schema = @db;
- SET @tables = CONCAT('DROP TABLE ', @tables);
- PREPARE stmt FROM @tables;
- EXECUTE stmt;
- DEALLOCATE PREPARE stmt;
- SET FOREIGN_KEY_CHECKS = 1;
- END//
- # Call procedure
- CALL drop_tables();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement