convert snippets

MySQL: How to change table and database collation

Tagged collation, mysql, convert  Languages sql

Listing table information including collation

show table status;

To show all table information use this command:

show full columns from xxx;

Convert existing columns in a table to a specific collation

alter table brands convert to character set utf8 collate utf8_swedish_ci;

This command converts all existing columns to the specified collation.

Change table collation

alter table posts collate utf8_swedish_ci;

Note that this doesn't change collation of existing columns.

Setting the collation manually

set session collation_database=utf8_swedish_ci;
set session collation_connection=utf8_swedish_ci;

Common collation values