18

终端中是否有用于查找我的 MySQL 数据库正在使用的存储引擎的命令?

4

7 回答 7

27

这在一些地方可用。

SHOW CREATE TABLE输出。

mysql> SHOW CREATE TABLE guestbook.Guestbook;
+-----------+-------------------------------------------+
| Table     | Create Table                                                                                                                                                                   |
+-----------+-------------------------------------------+
| Guestbook | CREATE TABLE `Guestbook` (
  `NAME` varchar(128) NOT NULL DEFAULT '',
  `MESSAGE` text NOT NULL,
  `TIMESTAMP` varchar(24) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-----------+-------------------------------------------+
1 row in set (0.00 sec)

来自 information_schema

information_schema.TABLES如果您想查询多个表的引擎,您也可以在其中找到它。

SELECT ENGINE 
FROM information_schema.TABLES
WHERE
  TABLE_NAME='yourtable'
  AND TABLE_SCHEMA='yourdatabase';
于 2012-05-02T21:12:05.510 回答
12
SHOW ENGINES;

返回您的 MySQL 数据库支持的引擎,并告诉您如果在创建时未另行指定,则哪个是默认引擎。

于 2016-09-05T12:22:41.510 回答
10

MySQL 上的数据库可以使用多个存储引擎,因此您必须检查每个表。最简单的就是做

show create table yourtable;

并查看 DDL 语句末尾的“引擎”行是什么。例如engine=InnoDB, engine=MyISAM, 等等...

如果要检查数据库中的所有表:

select TABLE_NAME, ENGINE
from information_schema.TABLES
where TABLE_SCHEMA='yourdbname'
于 2012-05-02T21:15:35.657 回答
1

这是一个较长的解决方案,但如果您想了解一些关于information_schema

mysql> select table_name,engine from information_schema.tables where table_name
= 'table_name' and table_schema = 'db_name';
于 2012-05-02T21:15:42.060 回答
1

你可以使用这个命令:

mysql -u[user] -p -D[database] -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'
于 2012-05-02T21:15:58.003 回答
0

显示表状态名称 = 'user_tbl'

于 2016-06-29T10:55:41.103 回答
0
mysql -u[user] -p -D[database] -e "show table status\G" | egrep "(Engine|Name)"

This will list all the tables and their corresponding engine. Good to get an overview of everything!

It's a modified answer from @yago-riveiro where he showed how to get the size of the tables, rather than the engines in use. Also, it's better to have an explanation on what a command does.

于 2017-02-01T09:31:40.280 回答