需求描述:
mysql中,想要查看某个数据库的字符集.通过information_schma模式下的schemata表来查询
环境描述:
mysql版本:5.7.21-log
操作过程:
1.查看information_schema.schemata表的结构
mysql> desc information_schema.schemata; +----------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------+--------------+------+-----+---------+-------+ | CATALOG_NAME | varchar(512) | NO | | | | | SCHEMA_NAME | varchar(64) | NO | | | | | DEFAULT_CHARACTER_SET_NAME | varchar(32) | NO | | | | | DEFAULT_COLLATION_NAME | varchar(32) | NO | | | | | SQL_PATH | varchar(512) | YES | | NULL | | +----------------------------+--------------+------+-----+---------+-------+ 5 rows in set (0.00 sec)
2.查看实例中所有数据库的字符集
select schema_name,default_character_set_name from information_schema.schemata;
查询结果:
备注:字段default_character_set_name就是字段的名字.
3.查看某个特定库的字符集
mysql> select schema_name,default_character_set_name from information_schema.schemata where schema_name = 'test01'; +-------------+----------------------------+ | schema_name | default_character_set_name | +-------------+----------------------------+ | test01 | utf8 | +-------------+----------------------------+ 1 row in set (0.00 sec)
备注:以上语句查询的就是test01库的字符集.同时呢,在mysql实例中,schema与DB是等同的概念.
文档创建时间:2018年6月1日10:27:24