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

MySQL - Query whether the specified database and table exist

黄舟
黄舟Original
2017-01-21 13:13:471377browse

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';

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';


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)!


Statement:
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