您的位置:首页 > 数据库 > MySQL

MySQL 如何查看表的存储引擎

2017-06-13 09:45 435 查看
MySQL如何查看表的存储引擎

在MySQL中如何查看单个表的存储引擎?如何查看整个数据库有那些表是某个特殊存储引擎,例如MyISAM存储引擎呢?下面简单的整理一下这方面的知识点。

如果要查看单个表的存储引擎,可以用showcreatetable命令查看该表的存储引擎,那么有下面一些方法:

方法1:

mysql>showcreatetabletest;
+-------+----------------------------------------------+
|Table|CreateTable|
+-------+----------------------------------------------+
|test|CREATETABLE`test`(
`id`int(11)DEFAULTNULL,
`name`varchar(12)DEFAULTNULL
)ENGINE=InnoDBDEFAULTCHARSET=utf8|
+-------+----------------------------------------------+
1rowinset(0.00sec)
mysql>






方法2:

mysql>showtablestatusfromMyDBwherename='test'\G
***************************1.row***************************
Name:test
Engine:InnoDB
Version:10
Row_format:Compact
Rows:0
Avg_row_length:0
Data_length:16384
Max_data_length:0
Index_length:0
Data_free:0
Auto_increment:NULL
Create_time:2017-06-0915:45:00
Update_time:NULL
Check_time:NULL
Collation:utf8_general_ci
Checksum:NULL
Create_options:
Comment:
1rowinset(0.01sec)






方法3:

mysql>
mysql>selecttable_catalog
->,table_schema
->,table_name
->,engine
->fromtables
->wheretable_schema='MyDB'andtable_name='test';
+---------------+--------------+------------+--------+
|table_catalog|table_schema|table_name|engine|
+---------------+--------------+------------+--------+
|def|MyDB|test|InnoDB|
+---------------+--------------+------------+--------+
1rowinset(0.00sec)
mysql>






如果要查询某个库或所有实例里面表使用的存储引擎,那么可以使用information_schema.tables来查询。下面是简单的几个例子。

查询整个MySQL实例里面存储引擎为MyISAM的表

selecttable_catalog
,table_schema
,table_name
,engine
frominformation_schema.tables
whereengine='MyISAM';


查询MyDB数据库里面存储引擎为MyISAM的表

selecttable_catalog
,table_schema
,table_name
,engine
frominformation_schema.tables
wheretable_schema='MyDB'andengine='MyISAM';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: