We have utf8_generail_ci on few varchar columns. Would like them to be utf8_unicode_ci. It looks like, the alter table only considers, collation change along with character set change (even if same character set).
alter table order_detail modify invoiced_sku varchar(50) collate utf8_unicode_ci;
This is a blocking operation. Is there a way to change collation only?
Thanks for your response. I realize I hadn’t stated my question clearly enough. The table is utf8 character set and utf8_unicode_ci collation for most columns. But for some varchar columns historically collation was set to utf8_general_ci. We want to convert those columns to utf8_unicode_ci. The alter table modify column works fine, but it considers that as column type change (though type and size are still same). Such change works in COPY mode and not INPLACE. That’s a blocking operation. Yes, we can indeed use percona online schema change tool etc. But my question was, whether only collation change is possible, without change to data type. The collation change is not a physical change and only sort order, so could be possible as a quicker non-blocking operation. We are using MySQL 5.7.
alter table order_detail modify column invoiced_sku varchar(50) collate utf8_unicode_ci, algorithm=inplace;
ERROR 1846 (0A000): ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
The INPLACE algorithm will not work because you are changing collation on a column, you need to specify COPY algorithm. INPLACE algorithm only works when metadata of table are changed.