Home > Database > Mysql Tutorial > MySQL5.7加强了在线DDL(varchar字符集)

MySQL5.7加强了在线DDL(varchar字符集)

WBOY
Release: 2016-06-07 14:53:03
Original
1490 people have browsed it

在MySQL5.6引入了在线DDL,添加字段和辅助索引不锁表,但修改字段属性是锁表的。请见:http://hcymysql.blog.51cto.com/5223301/1370546 如今在MySQL5.7,加强了修改varchar字段属性不锁表,例: 650) this.width=650;" src="http://www.68idc.cn/help/uploa

在MySQL5.6引入了在线DDL,添加字段和辅助索引不锁表,但修改字段属性是锁表的。请见:http://hcymysql.blog.51cto.com/5223301/1370546


如今在MySQL5.7,加强了修改varchar字段属性不锁表,例:

wKiom1RPWeKAI_hiAAK7Edk4nfs132.jpg


100万行的表,现在要把pad varchar(65)修改为pad varchar(80),可以看到,不用拷贝数据不锁表。

wKiom1RPWozBgsimAADG3ngstpM003.jpg

(注:ALGORITHM指定了创建或删除索引的算法,COPY表示按照MySQL 5.1版本之前的方法,即创建临时表。INPLACE表示创建索引或删除索引操作不需要创建临时表。DEFAULT表示根据参数old_alter_table来判断是通过INPLACE还是COPY的算法,改参数默认为OFF,表示采用INPLACE的方式。)


但如果是大于并等于varchar(256)或者把varchar(80)减少到varchar(40),仍旧是需要拷贝数据且锁表,见下图:

wKioL1RPW6XzYoWWAAEEOnV6HIg841.jpg

wKiom1RPXCqhVdI-AAEP5W8e2Pc967.jpg


参考:

wKiom1RPXGHw_vOAAAQrwxQQrc4177.jpg


BTW:

MySQL5.7还支持更改索引名,不过实用性不高,谁没事闲得改索引的名字?例:

wKioL1RPYh6D6x-jAAK-ZnVnN4A255.jpg

wKiom1RPYciRcsR-AAK5z6fs-bw004.jpg



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