Reading time: < 1 minute
If we want to delete different tables that start with the same name or name index, for example:
- videos_1
- videos_2
- videos_3
We can use this script:
SELECT CONCAT('DROP TABLE ', table_name, ';') statement FROM information_schema.tables WHERE table_name LIKE 'videos_%';
This script will return the code that we need to execute:
DROP TABLE videos_1; DROP TABLE videos_2; DROP TABLE videos_3;
We copy all the returned commands and we successfully delete all the tables.