MySQL 如何查看表的存儲引擎
在MySQL中如何查看單個表的存儲引擎? 如何查看整個數據庫有那些表是某個特殊存儲引擎,例如MyISAM存儲引擎呢?下面簡單的整理一下這方面的知識點。
如果要查看單個表的存儲引擎,可以用show create table命令查看該表的存儲引擎,那么有下面一些方法:
方法1:
mysql> show create table test;
+-------+----------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------+
| test | CREATE TABLE `test` (
`id` int(11) DEFAULT NULL,
`name` varchar(12) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------+
1 row in set (0.00 sec)
mysql>
方法2:
mysql> show table status from MyDB where name='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-09 15:45:00
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.01 sec)
方法3:
mysql>
mysql> select table_catalog
-> ,table_schema
-> ,table_name
-> ,engine
-> from tables
-> where table_schema='MyDB' and table_name='test';
+---------------+--------------+------------+--------+
| table_catalog | table_schema | table_name | engine |
+---------------+--------------+------------+--------+
| def | MyDB | test | InnoDB |
+---------------+--------------+------------+--------+
1 row in set (0.00 sec)
mysql>
如果要查詢某個庫或所有實例里面表使用的存儲引擎,那么可以使用information_schema.tables來查詢。下面是簡單的幾個例子。
查詢整個MySQL實例里面存儲引擎為MyISAM的表
select table_catalog
,table_schema
,table_name
,engine
from information_schema.tables
where engine='MyISAM';
查詢MyDB數據庫里面存儲引擎為MyISAM的表
select table_catalog
,table_schema
,table_name
,engine
from information_schema.tables
where table_schema='MyDB' and engine='MyISAM';