简体   繁体   中英

How to convert a column with “character set latin1 collate latin1_bin” into utf8 in Mysql?

Ok, in the existing table,

CREATE TABLE tb(id int, `text` varchar(255) character set latin1 collate latin1_bin default NULL)ENGINE=InnoDB DEFAULT CHARSET=latin1

I want to make the text column to be utf8 and it supports Case Sensitive for select query

Suppose there is " ã " & " Ã " which is utf8 in the text column

id - text
1  - ã
2  - Ã

, and when user select * from tb where text='Ã' it should show record with id=2 only

Is this query the correct one

alter table tb modify column text varchar(255) character set utf8 collate utf8_general_ci default NULL

I have no idea what utf8_general_ci means? am i doing cortrectly?

This can be done by using the Alter Command.

Like ALTER TABLE urtable MODIFY col1 VARCHAR(50) CHARACTER SET utf8;

See column charset conversion here

这是正确的

alter table tb modify text varchar(255) character set utf8 collate utf8_bin default NULL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM