什么是(默认的)字符集:

MySQL数据库 MySQL表 MySQL列


当前回答

SELECT TABLE_SCHEMA,
       TABLE_NAME,
       CCSA.CHARACTER_SET_NAME AS DEFAULT_CHAR_SET,
       COLUMN_NAME,
       COLUMN_TYPE,
       C.CHARACTER_SET_NAME
  FROM information_schema.TABLES AS T
  JOIN information_schema.COLUMNS AS C USING (TABLE_SCHEMA, TABLE_NAME)
  JOIN information_schema.COLLATION_CHARACTER_SET_APPLICABILITY AS CCSA
       ON (T.TABLE_COLLATION = CCSA.COLLATION_NAME)
 WHERE TABLE_SCHEMA=SCHEMA()
   AND C.DATA_TYPE IN ('enum', 'varchar', 'char', 'text', 'mediumtext', 'longtext')
 ORDER BY TABLE_SCHEMA,
          TABLE_NAME,
          COLUMN_NAME
;

其他回答

我总是看SHOW CREATE TABLE mydatabase。mytable。

对于数据库,似乎需要查看SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA。

表:

SHOW TABLE STATUS将列出所有的表。

使用过滤:

SHOW TABLE STATUS where name like 'table_123';

对于表和列:

show create table your_table_name

数据库: 使用db_name;选择@@character_set_database;

显示像'character_set_%'或'collation%'这样的变量