In MySQL, view all base tables under the current database, excluding views

Source: Internet
Author: User
Tags mysql version

Environment Description :

    • MySQL version: 5.5.57-log
    • Operating system version: Red Hat Enterprise Linux Server Release 6.6 (Santiago)

Requirements Description :

View all tables in the currently used database, but do not query the view or show the view, that is, all the base tables are queried

the following SQL statements are implemented :

SELECT     table_name,    table_schema,    table_type,    ENGINEfrom    information_schema . TABLESWHERE= ' BASE TABLE ' and      =DATABASE ();

Description: the database () function will query out the "currently used DB test01" as the Table_schema filter value. Alternatively, you can put the test01 directly to the right of the Table_schema equals sign.

Query Result :

Note: The above query comes out of all test01 database tables or base tables, the results of the query does not include views.

If you use the following command to display all the tables, the view is included:

Show tables;

Query Result :

Note: In the 16 records that were queried, there were 2 views starting with V_, so the 14 base tables that were previously queried were correct, that is, all tables subtract the view, because the view is a virtual table, so it is displayed in the show Tables command.

Document creation Time: March 8, 2018 10:33:24

In MySQL, view all base tables under the current database, excluding views

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.