Ko darīt, ja savajagās uzreiz izdzēst vairākas tabulas ar vienādiem prefiksiem, teiksim, "wp_icl_cms_nav_cache, wp_icl_content_status"?
Izrādās, ka uzreiz, vienā SQL pieprasījumā, to nemaz nevar paveikt. Ir nepieciešams to darīt divos soļos:
1. Izpildam pieprasījumu un saņemam visu tabulu nosaukumus:
SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = 'database_name' AND table_name LIKE 'myprefix_%';
2. Atpakaļ tiek atgriezts kaut kas šāds:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| statement |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| DROP TABLE wp_icl_cms_nav_cache,wp_icl_content_status,wp_icl_core_status,wp_icl_flags,wp_icl_languages,wp_icl_languages_translations,wp_icl_locale_map,wp_icl_message_status,wp_icl_node,wp_icl_reminders,wp_icl_string_positions,wp_icl_string_status,wp_icl_string_translations,wp_icl_strings,wp_icl_translate,wp_icl_translate_job,wp_icl_translation_status,wp_icl_translations; |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3. Šo, DROP TABLE pieprasījumu arī izpildam vēlreiz.