Auto-Generation SQL Queries for All Tables

根據符合條件的 table,自動產生 SQL command

ex:

Change tables' engine to InnoDB

use information_schema;
 
-- Create sql commands
 
select CONCAT("Alter Table `", TABLE_SCHEMA,"`.`", TABLE_NAME, "` engine=Innodb;") 
    as MySQLCMD from TABLES where TABLE_SCHEMA = "database_name";

Output

+----------------------------------------------------------------------------------+
| MySQLCMD   |
+----------------------------------------------------------------------------------+
| Alter Table `database_name`.`account` engine=Innodb;   |
| Alter Table `database_name`.`ncku` engine=Innodb;   |
| Alter Table `database_name`.`ncku_course_requ` engine=Innodb;   |
| Alter Table `database_name`.`ncku_domains` engine=Innodb;   |
| Alter Table `database_name`.`ncku_officers` engine=Innodb;   |
| Alter Table `database_name`.`ncku_teachers` engine=Innodb;   |
| Alter Table `database_name`.`record_account` engine=Innodb;   |
| Alter Table `database_name`.`record_ncku` engine=Innodb;   |
| Alter Table `database_name`.`record_ncku_course_requ` engine=Innodb; |
| Alter Table `database_name`.`record_ncku_domains` engine=Innodb;   |
| Alter Table `database_name`.`record_ncku_officers` engine=Innodb;   |
| Alter Table `database_name`.`record_ncku_teachers` engine=Innodb;   |
+----------------------------------------------------------------------------------+
+----------------------------------------------------------------------------------+
12 rows in set (0.09 sec)
db
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License