在 MySQL 中按引擎显示表

发布于 2024-08-10 21:01:59 字数 58 浏览 7 评论 0原文

如何使用给定引擎(例如 InnoDB、MyISAM、FEDERATED)显示 MySQL 中的所有表?

How would I show all tables in MySQL with a given engine, e.g. InnoDB, MyISAM, FEDERATED?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

花开柳相依 2024-08-17 21:01:59

使用 INFORMATION_SCHEMA.TABLES桌子:

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE engine = 'InnoDB'

Use INFORMATION_SCHEMA.TABLES table:

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE engine = 'InnoDB'
↘人皮目录ツ 2024-08-17 21:01:59

如果您想要来自单个数据库的结果

SELECT TABLE_NAME FROM information_schema.TABLES
    WHERE TABLE_SCHEMA = 'dbname' AND engine = 'InnoDB';

If you want the results from a single database

SELECT TABLE_NAME FROM information_schema.TABLES
    WHERE TABLE_SCHEMA = 'dbname' AND engine = 'InnoDB';
哭泣的笑容 2024-08-17 21:01:59

其他例子在这里。

按引擎列出的所有表(系统表除外):

SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine 
FROM information_schema.TABLES 
WHERE ENGINE = 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');

除引擎外的所有表(系统表除外):

SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine 
FROM information_schema.TABLES 
WHERE ENGINE != 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');

Other examples here.

All tables by engine (except system tables):

SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine 
FROM information_schema.TABLES 
WHERE ENGINE = 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');

All tables except engine (except system tables):

SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine 
FROM information_schema.TABLES 
WHERE ENGINE != 'MyISAM' -- or InnoDB or whatever
AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');
贵在坚持 2024-08-17 21:01:59

如果有些人有问题并且想查看哪个数据库是具有特定引擎的表

SELECT 
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database1' 
            AND engine = 'MyIsam'
        ) as database1, 
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database2' 
            AND engine = 'MyIsam'
        ) as database2,
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database3' 
            AND engine = 'MyIsam'
         ) as database3;

问候。

If some has problem and want to see in which DB is tables with specific engine

SELECT 
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database1' 
            AND engine = 'MyIsam'
        ) as database1, 
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database2' 
            AND engine = 'MyIsam'
        ) as database2,
        (SELECT group_concat(TABLE_NAME) 
            FROM information_schema.TABLES
            WHERE TABLE_SCHEMA = 'database3' 
            AND engine = 'MyIsam'
         ) as database3;

Regards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文