Home > Database > Mysql Tutorial > body text

MySQL - Query whether the specified database and table exist

黄舟
Release: 2017-01-21 13:13:47
Original
1346 people have browsed it

MySQL——Query whether the specified database and table exist

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 the specified database exists Whether a certain table exists under the database

SELECT DISTINCT t.table_name, n.SCHEMA_NAME FROM information_schema.TABLES t, 
information_schema.SCHEMATA n WHERE t.table_name = 'tableName' AND n.SCHEMA_NAME = 'databaseName';
Copy after login


The above is the content of MySQL - query whether the specified database and table exist. For more related content, please pay attention to the PHP Chinese website ( www.php.cn)!


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!