简体   繁体   English

如何仅使用SHOW TABLES获取表,而不获取视图?

[英]How to get only tables, not views using SHOW TABLES?

SHOW TABLES gives you tables+views. SHOW TABLES为您提供表和视图。

How do I retrieve only tables? 如何仅检索表?

show full tables where Table_Type = 'BASE TABLE'

verbatim. 逐字。

Or put another way; 或者换种说法;

show full tables where Table_Type != 'VIEW'

http://dev.mysql.com/doc/refman/5.0/en/show-tables.html http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

9 year old question but Google brought me here in 2019 for the same problem 9岁的问题,但Google于2019年将我带到了这里

The link at https://dev.mysql.com/doc/refman/8.0/en/show-tables.html tells us that we cannot use LIKE and WHERE together ( for mysql 5.5.x - 8.x ). https://dev.mysql.com/doc/refman/8.0/en/show-tables.html上的链接告诉我们,我们不能同时使用LIKE和WHERE(对于MySQL 5.5.x-8.x)。

So this statement WILL throw errors ( show tables which are NOT views and are further filtered by %name% ); 因此,该语句将引发错误(显示不是视图的表,并通过%name%进一步过滤);

  show full tables like "%sometablename%"  where Table_Type = 'BASE TABLE';

U will have to choose either LIKE or WHERE in one statement , not both simultaneously. U必须在一个语句中选择LIKE或WHERE,而不是同时选择两者。

::: Solution ( requires you know the database name ( say dbName) ) ::: :::解决方案(要求您知道数据库名称(例如dbName)):::

   show full tables where  Tables_in_dbName like "%main%" 
   and  Table_type = "Base Table";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM