如何找到我的桌子是MyISAM还是Innodb

时间:2010-09-10 01:41:41

标签: mysql

  

可能重复:
  How can I check MySQL engine type for a specific table?

假设用户是一个跟随命令的表,则不会显示用户表是MyISAM还是Innodb。

desc users; 

如何找到用户表的类型?

3 个答案:

答案 0 :(得分:42)

您可以使用SHOW TABLE STATUS查看表信息。

SHOW TABLE STATUS WHERE `Name` = 'my_table';

只需检查返回数据集中Engine列的值,即可知道该表正在使用哪个引擎。

答案 1 :(得分:17)

SELECT ENGINE
FROM INFORMATION_SCHEMA.TABLES 

WHERE TABLE_NAME='your_table_name'
AND   TABLE_SCHEMA='your_database_name';
-- or use TABLE_SCHEMA=DATABASE() if you have a default one.

答案 2 :(得分:5)

您可以使用SHOW CREATE TABLE并在回复中查找ENGINE部分。

SHOW CREATE TABLE users;

示例:

CREATE TABLE innodb_table (id int, value int) ENGINE=INNODB;
CREATE TABLE myisam_table (id int, value int) ENGINE=MYISAM;
CREATE TABLE default_table (id int, value int);

innodb_table的结果:

SHOW CREATE TABLE innodb_table;
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| Table        | Create Table                                                                                                                     |
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| innodb_table | CREATE TABLE `innodb_table` (
  `id` int(11) DEFAULT NULL,
  `value` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

myisam_table的结果:

SHOW CREATE TABLE myisam_table;
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| Table        | Create Table                                                                                                                     |
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| myisam_table | CREATE TABLE `myisam_table` (
  `id` int(11) DEFAULT NULL,
  `value` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+--------------+----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

default_table的结果:

SHOW CREATE TABLE default_table;
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
| Table         | Create Table                                                                                                                      |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
| default_table | CREATE TABLE `default_table` (
  `id` int(11) DEFAULT NULL,
  `value` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)