database:mysql:set-character-set-collation
Table of Contents
MySQL Set Character Set and Collation
For existing tables
To use utf8 character set and utf8_general_ci collation:
ALTER TABLE my_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Repeat this for all tables for which you need to adjust the character set and collation.
For the future tables
The newly created tables will use the default database character set and collation.
To change it:
ALTER DATABASE my_database CHARACTER SET = utf8 COLLATE = utf8_general_ci
View existing character set and collation for a specific table
SHOW FULL COLUMNS FROM my_table
Collation refers to a set of rules that determine how characters in character sets are compared and sorted.
These rules affect the results of data retrieval when the ORDER BY, GROUP BY, LIKE, and other SQL clauses are used. Collations also affect operations like string comparison ( =, <>, <, ⇐, >, >= )
These rules affect the results of data retrieval when the ORDER BY, GROUP BY, LIKE, and other SQL clauses are used. Collations also affect operations like string comparison ( =, <>, <, ⇐, >, >= )
A character set is a set of symbols and encodings (for example, utf8, latin1).
A collation is a set of rules for comparing characters in a character set.
A collation is a set of rules for comparing characters in a character set.
Some collations are case-sensitive (utf8_bin), while others are case-insensitive (utf8_general_ci).
database/mysql/set-character-set-collation.txt · Last modified: 2023/08/31 23:56 by odefta