In mysql, you can use the "select from" statement to query whether the specified data table exists, the syntax is "select*from information_schema.TABLES where TABLE_NAME = 'The name of the data table to be queried';".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
How to use SQL query statements to determine whether the database and data tables exist?
1. Determine whether the database exists
The query SQL is as follows:
select * from information_schema.SCHEMATA where SCHEMA_NAME = '需要查找的数据库名';
You can also fuzzy query, the SQL is as follows:
select * from information_schema.SCHEMATA where SCHEMA_NAME like '%需要查询的数据库名的部分名称%';
2. Determine whether the data table exists
The query SQL is as follows:
select * from information_schema.TABLES where TABLE_NAME = '需要查询的数据表名';
You can also fuzzy query, the SQL is as follows:
select * from information_schema.TABLES where TABLE_NAME like '%需要查询的数据表名的部分名称%';
[Related recommendations: mysql video tutorial]
The above is the detailed content of How to query whether a data table exists in mysql. For more information, please follow other related articles on the PHP Chinese website!