MySQL 字元集資訊:綜合指南
本指南示範如何檢索不同 MySQL 資料庫物件的字元集資訊。
資料庫級字元集
要尋找 MySQL 資料庫的預設字元集,請使用下列查詢:
<code class="language-sql">SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = 'your_database_name';</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 = 'your_database_name' AND T.table_name = 'your_table_name';</code>
列級字元集
要取得表格中特定列的字元集,請執行下列查詢:
<code class="language-sql">SELECT character_set_name FROM information_schema.COLUMNS WHERE table_schema = 'your_database_name' AND table_name = 'your_table_name' AND column_name = 'your_column_name';</code>
請記得將 your_database_name
、your_table_name
和 your_column_name
等佔位符替換為您的實際資料庫、表格和列名稱。
以上是如何檢索 MySQL 資料庫、表格和列的字元集資訊?的詳細內容。更多資訊請關注PHP中文網其他相關文章!