Table collation...
SHOW TABLE STATUS LIKE 'mytable'\G
Table character set...
SHOW CREATE TABLE mytable\G
Instance default character sets...
status
Database character set and collation...
USE mydatabase;
SELECT @@character_set_database,
@@collation_database;
SELECT default_character_set_name,
default_collation_name
FROM information_schema.schemata
WHERE schema_name = 'mydatabase';
To see available character sets and their default collation...
SHOW CHARACTER SET;
To see all available collations for a character set...
SELECT collation_name,
pad_attribute
FROM information_scheme.collations
WHERE character_set_name = 'utf8mb4';
SHOW COLLATION WHERE Charset = 'utf8mb4';
Unicode...
utf8mb4
utf8mb3
utf8
ucs2
utf16
utf16le
utf32
uses 1 to 4 bytes per character
uses 1 to 3 bytes per character (deprecated in MySQL 8.0)
alias for utf8mb3 (may eventually become an alias for utf8mb4)
uses 2 bytes per character (deprecated in MuSQL 8.0.28)
use 2 to 4 bytes per character
Little-endian version of utf16
uses 4 bytes per character
Some notes about collation in MySQL...
In collation names, you will see the following suffixes...
_ai
_as
_ci
_cs
_bin
Accent-insensitive
Accent-sensitive
Case-insensitive
Case-Sensitive
Binary
Default is utf8 in MySQL 5.7 (and utf8 is an alias for utf8mb3)
Default is utf8mb4 in MySQL 8.0 (and utf8mb3 is deprecated. utf8 is still an alias for utf8mb3 but is eventually expected to become an alias for utf8mb4)
These statements are equivalent...
SELECT N'mytext';
SELECT n'mytext';
SELECT _utf8'mytext';
ALTER DATABASE mydatabase CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE mytable CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE mytable CHANGE mycolumn VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;