Home >Database >Mysql Tutorial >How to query how many tables there are in mysql database

How to query how many tables there are in mysql database

青灯夜游
青灯夜游Original
2022-02-17 16:58:5911912browse

In mysql, you can query "information_schema.TABLES" information through the "SELECT" statement to obtain the metadata information of the data table in the specified database, and use the "COUNT(*)" function to count the number of metadata to calculate The number of tables in the database.

How to query how many tables there are in mysql database

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

In mysql, you can query the "information_schema.TABLES" information through the "SELECT" statement to calculate the number of tables in the database.

Grammar:

SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES   WHERE table_schema = 'dbname' GROUP BY table_schema;

Example:

SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES   WHERE table_schema = 'bwlbis' GROUP BY table_schema;

How to query how many tables there are in mysql database

Description:

The tables in the information_schema database are all read-only and cannot be updated, deleted, inserted, etc., nor can triggers be added, because they are actually just a view, not a basic table, and have no associated files.

information_schema.tables stores the metadata information of the data table. Commonly used fields are introduced below:

  • table_schema: Record database name ;

  • table_name: record data table name;

  • engine: storage engine;

  • table_rows : A rough row estimate about the table;

  • data_length : The size of the record table (in bytes);

  • index_length : The index of the record table The size of 】

The above is the detailed content of How to query how many tables there are in mysql database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:what is mysql slow queryNext article:what is mysql slow query