Online Varchar Length Increase
Introduction
Varchar is a set of character data. The native MySQL only supports varchar whose length is no more than 256 bytes. To increase its length to more than 256 bytes, copy data to new tables and lock the tables to prevent data writes during the length increase. RDS for MySQL has no limitations on the varchar length and allows you to increase it online.
Constraints
This function is available only in RDS for MySQL 5.6 (kernel version 5.6.46 or later) and 5.7 (kernel version 5.7.27 or later).
Category
- Increase the varchar length to no more than 256 bytes.
create table t1(a varchar(10)); Query OK, 0 rows affected (0.03 sec)
alter table t1 modify a varchar(100),ALGORITHM=INPLACE, LOCK=NONE; Query OK, 0 rows affected (0.06 sec) Records: 0 Duplicates: 0 Warning: 0
- Increase the varchar length from less than 256 bytes to more than 256 bytes.
create table t1(a varchar(100)); Query OK, 0 rows affected (0.05 sec)
alter table t1 modify a varchar(300),ALGORITHM=INPLACE, LOCK=NONE; Query OK, 0 rows affected (0.11 sec) Records: 0 Duplicates: 0 Warning: 0
- Increase the varchar length beyond 256 bytes.
create table t1(a varchar(300)); Query OK, 0 rows affected (0.08 sec)
alter table t1 modify a varchar(500),ALGORITHM=INPLACE, LOCK=NONE; Query OK, 0 rows affected (0.06 sec) Records: 0 Duplicates: 0 Warning: 0
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.