Home > Database > Mysql Tutorial > body text

MySQL修改数据表存储引擎的3种方法介绍_MySQL

WBOY
Release: 2016-06-01 13:06:54
Original
1105 people have browsed it

MySQL作为最常用的数据库,经常遇到各种各样的问题。今天要说的就是表存储引擎的修改。有三种方式,列表如下。

1.真接修改。在数据多的时候比较慢,而且在修改时会影响读取性能。my_table是操作的表,innoDB是新的存储引擎。
复制代码 代码如下:ALTER TABLE my_table ENGINE=InnoDB

2.导出,导入。这个比较容易操作,直接把导出来的sql文件给改了,然后再导回去。用mysqldump ,枫哥常用的是navicate那样更容易上手。友情提醒风险较大。

3.创建,插入。这个比第一种速度快, 安全性比第二种高,推荐。分2步操作

a.创建表,先创建一个和要操作表一样的表,然后更改存储引擎为目标引擎。   
复制代码 代码如下:
CREATE TABLE my_tmp_table LIKE my_table;
ALTER TABLE my_tmp_table ENGINE=InnoDB;
b.插入。为了安全和速度,最好加上事务,并限制id(主键)范围。
复制代码 代码如下:
INSERT INTO my_tmp_table SELECT * FROM my_table;
就到这里,希望对需要的同学有帮助。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!