©著作权归作者所有:来自51CTO博客作者运维之美的原创作品,如需转载,请注明出处,否则将追究法律责任
https://blog.51cto.com/wujianwei/2780116
## 一、修改MySQL表varchar类型 字段长度会锁表嘛? 凭借"经验"给出回答:如果字段长度超过256个字符就会锁表。 这样的回答错误 。看看MySQL 官方文档如何介绍: ``` Extending VARCHAR column size The number of length bytes(字节) required by a VARCHAR column must remain the same. For VARCHAR columns of 0 to 255 bytes in size, one length byte is required to encode the value. For VARCHAR columns of 256 bytes in size or more, two length bytes are required. As a result, in-place ALTER TABLE only supports increasing VARCHAR column size from 0 to 255 bytes, or from 256 bytes to a greater size. In-place ALTER TABLE does not support increasing the size of a VARCHAR column from less than 256 bytes to a size equal to or greater than 256 bytes. In this case, the number of required length bytes changes from 1 to 2, which is only supported by a table copy (ALGORITHM=COPY). ``` **