¿Cómo puedo comprobar el tipo de motor MySQL para una tabla específica?


Mi base de datos MySQL contiene varias tablas usando diferentes motores de almacenamiento (específicamente myisam e innodb). ¿Cómo puedo averiguar qué mesas son ¿usando qué motor?

Author: djf, 2008-10-17

11 answers

SHOW TABLE STATUS WHERE Name = 'xxx'

Esto te dará (entre otras cosas) una columna Engine, que es lo que quieres.

 426
Author: Greg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-17 19:30:09

Para mostrar una lista de todas las tablas de una base de datos y sus motores, utilice esta consulta SQL:

SELECT TABLE_NAME,
       ENGINE
FROM   information_schema.TABLES
WHERE  TABLE_SCHEMA = 'dbname';

Reemplace dbname con el nombre de su base de datos.

 211
Author: Jocker,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-28 08:07:49
SHOW CREATE TABLE <tablename>;

Menos analizable pero más legible que SHOW TABLE STATUS.

 48
Author: Javier,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-12 13:08:52

O simplemente

show table status;

Solo que esto listará todas las tablas en su base de datos.

 38
Author: MArk Guadalupe,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-08-19 04:29:20

Un pequeño ajuste a la respuesta de Jocker (publicaría como un comentario, pero aún no tengo suficiente karma):

SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = 'database' AND ENGINE IS NOT NULL;

Esto excluye las vistas MySQL de la lista, que no tienen un motor.

 12
Author: Evan Donovan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-12 16:31:17
SHOW CREATE TABLE <tablename>\G

Lo formateará mucho mejor en comparación con la salida de

SHOW CREATE TABLE <tablename>;

El truco \G también es útil para recordar para muchas otras consultas/comandos.

 9
Author: Nicholas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-13 18:18:32
mysqlshow -i <database_name>

Mostrará la información de todas las tablas de una base de datos específica.

mysqlshow -i <database_name> <table_name> 

Lo hará solo para una tabla específica.

 4
Author: magic,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-13 13:44:33

Si está utilizando MySQL Workbench, puede hacer clic derecho en la tabla y seleccionar 'alter table'.

En esa ventana puede ver su motor de tabla y también cambiarlo.

 3
Author: T30,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-09-24 07:58:55

Si usted es un usuario de linux:

Para mostrar los motores para todas las tablas para todas las bases de datos en un servidor mysql, sin tablas information_schema, mysql, performance_schema:

less < <({ for i in $(mysql -e "show databases;" | cat | grep -v -e Database-e information_schema -e mysql -e performance_schema); do echo "--------------------$i--------------------";  mysql -e "use $i; show table status;"; done } | column -t)

Puede que te guste esto, si estás en Linux, al menos.

Abrirá toda la información para todas las tablas en less, presione -S para cortar líneas demasiado largas.

Ejemplo de salida:

--------------------information_schema--------------------
Name                                                        Engine              Version  Row_format  Rows   Avg_row_length  Data_length  Max_data_length     Index_length  Data_free  Auto_increment  Create_time  Update_time  Check_time  C
CHARACTER_SETS                                              MEMORY              10       Fixed       NULL   384             0            16434816            0             0          NULL            2015-07-13   15:48:45     NULL        N
COLLATIONS                                                  MEMORY              10       Fixed       NULL   231             0            16704765            0             0          NULL            2015-07-13   15:48:45     NULL        N
COLLATION_CHARACTER_SET_APPLICABILITY                       MEMORY              10       Fixed       NULL   195             0            16357770            0             0          NULL            2015-07-13   15:48:45     NULL        N
COLUMNS                                                     MyISAM              10       Dynamic     NULL   0               0            281474976710655     1024          0          NULL            2015-07-13   15:48:45     2015-07-13  1
COLUMN_PRIVILEGES                                           MEMORY              10       Fixed       NULL   2565            0            16757145            0             0          NULL            2015-07-13   15:48:45     NULL        N
ENGINES                                                     MEMORY              10       Fixed       NULL   490             0            16574250            0             0          NULL            2015-07-13   15:48:45     NULL        N
EVENTS                                                      MyISAM              10       Dynamic     NULL   0               0            281474976710655     1024          0          NULL            2015-07-13   15:48:45     2015-07-13  1
FILES                                                       MEMORY              10       Fixed       NULL   2677            0            16758020            0             0          NULL            2015-07-13   15:48:45     NULL        N
GLOBAL_STATUS                                               MEMORY              10       Fixed       NULL   3268            0            16755036            0             0          NULL            2015-07-13   15:48:45     NULL        N
GLOBAL_VARIABLES                                            MEMORY              10       Fixed       NULL   3268            0            16755036            0             0          NULL            2015-07-13   15:48:45     NULL        N
KEY_COLUMN_USAGE                                            MEMORY              10       Fixed       NULL   4637            0            16762755            0 

.
.
.
 2
Author: sjas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-13 13:52:16

Vaya a la base de datos information_schema allí encontrará la tabla' tables ' y luego selecciónela;

Mysql > use information_schema; Mysql> select table_name,motor de las tablas;

 0
Author: harsha vardhan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-08-01 08:28:44

Otra forma, tal vez la más corta para obtener el estado de un solo conjunto o emparejado de tablas:

SHOW TABLE STATUS LIKE 'table';

Luego puede usar operadores COMO, por ejemplo:

SHOW TABLE STATUS LIKE 'field_data_%';
 0
Author: David Thomas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-04 07:12:46