在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資料庫、表格和欄位中的字元集。
以上是如何識別MySQL資料庫、表格和列中的字元集?的詳細內容。更多資訊請關注PHP中文網其他相關文章!