How do I drop all empty tables from a MySQL database? -


How do I leave all the empty tables from a MySQL database, except at least those 1 tables that have the record?

This stored procedure should:

  DELIMITER $$ drop Process if exists' drop_empty_tables_from` $$ Process to create 'drop_time_tables_prom' (IN schema_trade VARCHAR (128)) summary table_list text; Total records VARCHAR (11); SELECT GROUP_CONCAT (`TABLE_NAME`), table (` TABLE_NAME` in the list), with the total `info_schema`.`tables`` where`TamilCAKMAA = 'schema_tag and`tab_ROS` = 0; If table_list is not fired, then set @drop_tables = CONCAT ("drop table", table_list); Prepare STMT with @drop_tables; EXTUTE STMT; Deluxe Prepare STMT; end if; Select Effective Tables Overall; END $$ DELIMITER;  

There may be a problem with that empty code with "GROUP_CONCAT" . It depends on the value of the system variable.

It is not possible to do this in a query, because the drop table can not get the argument from a SELECT query.

InnoDB note

Thanks to James for his comment it appears that the row count query will not return accurate results in the case of Inodbi tables, so The above process is not guaranteed to be fully functional, when there are INODABAI tables in that schema.

InnoDB tables for, line count is only a true estimate used in SQL optimization. (It is also true that the Inodibi table is divided.)

Source:


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -