如何检查特定数据库的 MySQL 引擎类型?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6829948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:37:32  来源:igfitidea点击:

How can I check MySQL engine type for a specific database?

mysql

提问by joe

How can I check MySQL engine type for a specific database via mysql query?

如何通过 mysql 查询检查特定数据库的 MySQL 引擎类型?

回答by Piskvor left the building

In MySQL, databases don't havean engine type; tableshave engine types. The Friendly Manualeven explicitly states:

在MySQL中,数据库不具有发动机类型; 具有引擎类型。友好手册甚至明确指出:

It is important to remember that you are not restricted to using the same storage engine for an entire server or schema: you can use a different storage engine for each table in your schema.

重要的是要记住,您不限于对整个服务器或模式使用相同的存储引擎:您可以为模式中的每个表使用不同的存储引擎。

You can query the information_schemadatabase (substitute your database name and table name in the example):

您可以查询information_schema数据库(在示例中替换您的数据库名称和表名称):

SELECT `ENGINE` FROM `information_schema`.`TABLES`
  WHERE `TABLE_SCHEMA`='your_database_name' AND `TABLE_NAME`='your_table_name';

You can also get the value of the global environment variable storage_engine- which is only used as a default when a table is created without an engine specified, it does not affect the server in any other way:

您还可以获取全局环境变量的值storage_engine- 仅在未指定引擎的情况下创建表时用作默认值,它不会以任何其他方式影响服务器:

SHOW GLOBAL VARIABLES LIKE 'storage_engine'

回答by álvaro González

Databases do not have engines. Tables have. You can run e.g. SHOW TABLE STATUS:

数据库没有引擎。表有。您可以运行例如SHOW TABLE STATUS

SHOW TABLE STATUS FROM mydatabase

Available engines can be found with SHOW ENGINES.

可用的引擎可以通过SHOW ENGINES找到。



Tip: if you are the using the official command-line client rather than GUI tools you might want to use the \Gcommand(not to be confused with lowercase \g):

提示:如果您使用的是官方命令行客户端而不是 GUI 工具,您可能想要使用该\G命令(不要与小写混淆\g):

Send the current statement to the server to be executed and display the result using vertical format.

将当前语句发送到服务器执行,并以垂直格式显示结果。

... which turns this:

...这变成了这个:

mysql> SHOW TABLE STATUS;
+----------------------------------+--------+---------+------------+------+----------------+-------------+-----------------+-----------
---+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+-----
------------------------------------------------------+
| Name                             | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_leng
th | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation         | Checksum | Create_options | Comm
ent                                                   |
+----------------------------------+--------+---------+------------+------+----------------+-------------+-----------------+-----------
---+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+-----
------------------------------------------------------+
| canal                            | InnoDB |      10 | Compact    |    0 |              0 |       16384 |               0 |
 0 |  27262976 |              1 | 2015-04-10 11:07:01 | NULL        | NULL       | utf8_general_ci   |     NULL |                |

… into this:

...进入这个:

mysql> SHOW TABLE STATUS\G
*************************** 1. row ***************************
           Name: canal
         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: 27262976
 Auto_increment: 1
    Create_time: 2015-04-10 11:07:01
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options:
        Comment:
*************************** 2. row ***************************
           Name: cliente
         Engine: InnoDB
[…]

回答by TC1

SHOW TABLE STATUSretrieves that kind of stuff, see the MySQL docs.

SHOW TABLE STATUS检索那种东西,请参阅MySQL 文档

回答by ab_wanyama

Use this command:

使用这个命令:

SHOW ENGINES\G;  

Your default engine will show as Support: DEFAULT

您的默认引擎将显示为Support: DEFAULT

回答by rrr

the list of engines used by databases:

数据库使用的引擎列表:

SELECT TABLE_SCHEMA, ENGINEFROM information_schema.TABLESgroup by TABLE_SCHEMA, ENGINEorder by TABLE_SCHEMA, ENGINE;

选择TABLE_SCHEMAENGINEinformation_schemaTABLESgroup by TABLE_SCHEMA, ENGINEorder by TABLE_SCHEMA, ENGINE;