How do I see what character set a MySQL database / table / column is?
What is the (default) charset for:
MySQL database
MySQL table
MySQL column
Here's how I'd do it -
For Schemas:
SELECT default_character_set_name FROM information_schema.SCHEMATA
WHERE schema_name = "schemaname";
For Tables:
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 = "schemaname"
AND T.table_name = "tablename";
For Columns:
SELECT character_set_name FROM information_schema.`COLUMNS`
WHERE table_schema = "schemaname"
AND table_name = "tablename"
AND column_name = "columnname";
对于列 :
SHOW FULL COLUMNS FROM table_name;
For databases :
USE your_database_name;
show variables like "character_set_database";
-- or:
-- show variables like "collation_database";
Cf. this page. And check out the MySQL manual
链接地址: http://www.djcxy.com/p/25120.html上一篇: 在字符集之间转换文本文件的最佳方法?