借助以下MySQL查询,我们可以检查特定数据库中所有表的字符集-
mysql> Select TABLE_NAME, CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.Columns Where TABLE_SCHEMA = 'db_name';
例如,下面的查询返回名为“ Alpha”的数据库中所有表的字符集。
mysql> Select TABLE_NAME, CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.Columns Where TABLE_SCHEMA = 'Alpha'; +------------+--------------------+ | TABLE_NAME | CHARACTER_SET_NAME | +------------+--------------------+ | employee | latin1 | | employee | latin1 | | student | latin1 | | student | NULL | | student | latin1 | +------------+--------------------+ 5 rows in set (0.06 sec)
输出显示5行,employee表包含2行,student表包含3行,因为table employee包含两列,而table student包含三列。