In mysql, you can use "select table name from information_schema.tables where table_schema=database" to query all tables in the database, and "information_schema.tables" can access database metadata.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
Use the select command to query all table names
The writing method is as follows:
select 表名 from information_schema.tables where table_schema='当前数据库'
[INFORMATION_SCHEMA database] comes with MySQL, which provides a way to access database metadata. What is metadata? Metadata is data about the data, such as database name or table name, column data type, or access permissions, etc.
Other terms sometimes used to describe this information include "data dictionary" and "system catalog."
In MySQL, [INFORMATION_SCHEMA] is regarded as a database, or to be precise, an information database. It holds information about all other databases maintained by the MySQL server. Such as database name, database tables, data types and access rights of table columns, etc.
In [INFORMATION_SCHEMA], there are several read-only tables. They are actually views, not base tables, so you won't be able to see any files related to them.
Recommended learning: mysql video tutorial
The above is the detailed content of How to query all tables in the database with mysql. For more information, please follow other related articles on the PHP Chinese website!