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

前端 未结 2 1945
别跟我提以往
别跟我提以往 2021-01-31 02:25

SHOW TABLES gives you tables+views.

How do I retrieve only tables?

相关标签:
2条回答
  • 2021-01-31 03:10
    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

    0 讨论(0)
  • 2021-01-31 03:30

    9 year old question but Google brought me here in 2019 for the same problem

    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 ).

    So this statement WILL throw errors ( show tables which are NOT views and are further filtered by %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.

    ::: Solution ( requires you know the database name ( say dbName) ) :::

       show full tables where  Tables_in_dbName like "%main%" 
       and  Table_type = "Base Table";
    
    0 讨论(0)
提交回复
热议问题