Home >Database >Mysql Tutorial >How to query how many tables there are in mysql database
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.
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;
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!