2011-05-23 23 views
14

谷歌搜索只是找到從一種格式更改爲另一種格式的指示,但我似乎無法找到如何確切地確定哪些我第一次。如何檢查MySQL表是否爲UTF-8並具有storageEngine InnoDB?

我怎能:

1) Check what character encoding a table has? 
2) Check what storage engine a table uses? 
3) Check if all tables are certain encoding? 
4) Check if all tables have a certain storage engine? 

謝謝!

+1

這可能是有用的:http://stackoverflow.com/questions/4515490/how-do -i-know-if-a-mysql-table-is-using-myisam-or-innodb-engine/4515794#4515794 – sarnold 2011-05-23 22:10:35

回答

27

您可以使用information_schema來了解每個表的引擎。

select table_name,engine 
from information_schema.tables 
where table_schema = 'your_database' 

的編碼,您可以使用

show create table table_name 

,或者甚至更好

select 
c.character_set_name 
from information_schema.tables as t, 
    information_schema.collation_character_set_applicability as c 
where c.collation_name = t.table_collation 
and t.table_schema = "your_db" 
and t.table_name = "table_name"; 
+0

它是有道理的,但你確定這是語法嗎?我得到這個錯誤:'字段列表'中的未知列'用戶' – GeekedOut 2011-05-23 22:19:52

+0

嗨。是,我確定。這是對mysql> = 5.0的information_schema的簡單查詢。你在說什麼,我的第一個或第二個查詢? – 2011-05-23 22:22:08

+0

我正在嘗試第一個查詢。但我會繼續黑客 – GeekedOut 2011-05-23 22:32:43

相關問題