Mysql change collation or character set

Database level

CREATE DATABASE czech_slovak_names CHARACTER SET = 'keybcs2' COLLATE = 'keybcs2_bin';
ALTER DATABASE czech_slovak_names COLLATE = 'keybcs2_general_ci';

Table level

CREATE TABLE english_names (id INT, name VARCHAR(40))
COLLATE 'utf8_icelandic_ci';

ALTER TABLE table_name
SET charset_name [COLLATE collation_name];

ALTER TABLE table_name MODIFY ascii_text_column TEXT CHARACTER SET utf8;
ALTER TABLE table_name MODIFY ascii_varchar_column VARCHAR(M) CHARACTER SET utf8;

Column level

CREATE TABLE european_names (
 croatian_names VARCHAR(40) COLLATE 'cp1250_croatian_ci',
 greek_names VARCHAR(40) CHARACTER SET 'greek');

To store emoji, or non utf8 character

 ALTER TABLE personals
 MODIFY self_introduction
 TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s