库的字符集:
SELECT default_character_set_name FROM information_schema.SCHEMATA S
WHERE schema_name = 'test';
表的字符集:
SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
AND T.table_schema = 'test'
AND T.table_name = 't1';
列的字符集:
SELECT character_set_name FROM information_schema.`COLUMNS` C
WHERE table_schema = 'test'
AND table_name = 't1'
AND column_name = 'name';