1. Check whether the specified database exists
SELECT information_schema.SCHEMATA.SCHEMA_NAME FROM information_schema.SCHEMATA where SCHEMA_NAME='databaseName';
2. Check whether a certain table exists under the specified database
<p style="margin-bottom: 7px;">SELECT DISTINCT t.table_name, n.SCHEMA_NAME FROM information_schema.TABLES t, information_schema.SCHEMATA n WHERE t.<br/><br/>table_name = 'tableName' AND n.SCHEMA_NAME = 'databaseName';</p>
The above is the detailed content of MySQL - Query whether the specified database and table exist. For more information, please follow other related articles on the PHP Chinese website!