Home > Database > Mysql Tutorial > MySQL - Query whether the specified database and table exist

MySQL - Query whether the specified database and table exist

黄舟
Release: 2017-03-14 14:50:39
Original
1696 people have browsed it

1. Check whether the specified database exists

SELECT information_schema.SCHEMATA.SCHEMA_NAME FROM information_schema.SCHEMATA where SCHEMA_NAME='databaseName';
Copy after login

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 = &#39;tableName&#39; AND n.SCHEMA_NAME = &#39;databaseName&#39;;</p>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template