共計 2568 個字符,預(yù)計需要花費 7 分鐘才能閱讀完成。
這篇文章主要介紹了 mysql 如何查詢表的字符集編碼的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇 mysql 如何查詢表的字符集編碼文章都會有所收獲,下面我們一起來看看吧。
mysql 查詢表字符集編碼的兩種方法:1、使用“show table status”語句查看指定數(shù)據(jù)庫中指定表的字符集編碼,語法“show table status from 庫名 like 表名;”。2、使用“show columns”語句配合 full 關(guān)鍵字查看當(dāng)前數(shù)據(jù)庫中指定表所有列的字符集編碼,語法“show full columns from 表名;”。
本教程操作環(huán)境:windows7 系統(tǒng)、mysql8 版本、Dell G3 電腦。
mysql 查詢表字符集編碼的兩種方法
1、使用 show table status 語句查看指定表的字符集編碼
SHOW TABLE STATUS 命令可以獲取指定數(shù)據(jù)庫中每個數(shù)據(jù)表的信息,包括字符集編碼。
show table status from 數(shù)據(jù)庫名;
但只想獲取指定表的信息,就可利用 like 進(jìn)行限制:
show table status from 庫名 like 表名;
示例:查看 class_7 數(shù)據(jù)庫中 test_info 表的字符集編碼
show table status from class_7 like test_info
mysql show table status from class_7 like test_info
+-----------+--------+---------+------------+------+----------------+-------------------------+-------------+------------+-----------------+----------+-
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_leate_time | Update_time | Check_time | Collation | Checksum |
+-----------+--------+---------+------------+------+----------------+-------------------------+-------------+------------+-----------------+----------+-
| test_info | InnoDB | 10 | Compact | 10 | 1638 | 17-12-05 19:01:55 | NULL | NULL | utf8_general_ci | NULL |
+-----------+--------+---------+------------+------+----------------+-------------------------+-------------+------------+-----------------+----------+-
1 row in set (0.00 sec)
2、使用 show columns 語句配合 full 關(guān)鍵字查看當(dāng)前數(shù)據(jù)庫中指定表中所有列的字符集編碼
在 mysql 中,SHOW COLUMNS 命令可以顯示表的列信息,而要獲取有關(guān)列的更多信息,請將 FULL 關(guān)鍵字添加到 SHOW COLUMNS 命令中:
show full columns from 表名;
該語句可以輸出指定表中所有列的字符集編碼
示例:查看 test_info 表中所有列的字符集編碼
show full columns from test_info;
mysql show full columns from test_info;
+-------+----------+-----------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+----------+-----------------+------+-----+---------+-------+---------------------------------+---------+
| id | int(3) | NULL | NO | PRI | NULL | | select,insert,update,references | |
| name | char(12) | utf8_general_ci | YES | | NULL | | select,insert,update,references | |
| dorm | char(10) | utf8_general_ci | YES | | NULL | | select,insert,update,references | |
| addr | char(12) | utf8_general_ci | YES | | 未知 | | select,insert,update,references | |
| score | int(3) | NULL | YES | | NULL | | select,insert,update,references | |
+-------+----------+-----------------+------+-----+---------+-------+---------------------------------+---------+
5 rows in set (0.00 sec)
關(guān)于“mysql 如何查詢表的字符集編碼”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“mysql 如何查詢表的字符集編碼”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道。