Basically, the query instructs MySQL to go to the information_schema table , which contains data on all tables in all databases, and to concatenate all tables in the database @schema ( classicmodels ) that matches the pattern @pattern ( test% ) with the prefix DROP TABLE . The GROUP_CONCAT function creates a comma-separated list of tables.
Then, we can display the dynamic SQL to verify if it works correctly: