MySQL将某个数据库下的所有表的存储引擎修改为InnoDB类型语句

如何将mysql数据库中的MyISAM类型表更改为InnoDB类型的表

改单个表

ALTER TABLE TABLENAME ENGINE=InnoDB; ALTER TABLE TABLENAME ENGINE=MyISAM;

改多个表

#修改为InnoDB
SELECT CONCAT( 'ALTER TABLE ', TABLE_NAME, ' ENGINE=InnoDB;' ) FROM information_schema.tables WHERE table_schema = 'DBNAME' LIMIT 0 , 10000;

 #修改为MyISAM

SELECT CONCAT( 'ALTER TABLE ', TABLE_NAME, ' ENGINE=MyISAM;' ) FROM information_schema.tables WHERE table_schema = 'DBNAME' LIMIT 0 , 10000;

使用说明:

1. 将以上SQL语句中的 DBNAME 替换成需要修改的数据库名称。

2. 执行SQL,这个时候还没有修改,只是给了一个查询结果。

3. 将查询结果复制,去掉前后的引号,然后执行。

 

批量修改mysql数据库字符集

ALTER DATABASE DBNAME DEFAULT CHARACTER SET='utf8';

 mysql数据库表字段乱码,连接数据库时设置正确的编码即可

mysql_query('set names utf8');

 zencart示例

Mysql修改表、字段、库的字符集  ALTER DATABASE `zc139` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;  ALTER TABLE `news_articles` ENGINE=INNODB; ALTER TABLE `news_articles_text` ENGINE=INNODB; ALTER TABLE `news_authors` ENGINE=INNODB; ALTER TABLE `news_comments` ENGINE=INNODB; ALTER TABLE `news_comments_description` ENGINE=INNODB; ALTER TABLE `popular_searches` ENGINE=INNODB; ALTER TABLE `un_products_to_wishlists` ENGINE=INNODB; ALTER TABLE `un_wishlists` ENGINE=INNODB;   ALTER TABLE `news_articles` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `news_articles_text` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `news_authors` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `news_comments` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `news_comments_description` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `popular_searches` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `un_products_to_wishlists` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE `un_wishlists` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

 

注:以上内容来自网络

You may also like...

发表评论

电子邮件地址不会被公开。 必填项已用*标注