MySQL 数据库、表和列字符集确定方法
本文介绍了确定 MySQL 数据库不同级别字符集的方法,包括:
数据库字符集
要检索特定数据库的默认字符集,请使用以下查询:
<code class="language-sql">SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "mydatabasename";</code>
表字符集
要确定表的字符集,请执行以下查询:
<code class="language-sql">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 = "mydatabasename" AND T.table_name = "tablename";</code>
列字符集
最后,要检索特定列的字符集,请使用以下查询:
<code class="language-sql">SELECT character_set_name FROM information_schema.`COLUMNS` WHERE table_schema = "mydatabasename" AND table_name = "tablename" AND column_name = "columnname";</code>
以上是如何确定MySQL数据库、表、列级别的字符集?的详细内容。更多信息请关注PHP中文网其他相关文章!