Home  >  Article  >  Database  >  How to query whether the database exists in mysql

How to query whether the database exists in mysql

青灯夜游
青灯夜游Original
2021-12-28 17:12:156771browse

Method: 1. Execute the "SELECT * FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'database name';" statement; 2. Execute the "show databases like 'database name';" statement.

How to query whether the database exists in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

mysql query whether the database exists

Method 1:

Execute the following statement in mysql

SELECT * FROM information_schema.SCHEMATA 
WHERE SCHEMA_NAME = '数据库名称';

Method 2:

Execute the following statement

show databases like '数据库名称';

Expand knowledge: Query whether the data table exists

show tables like 'table_name';

[Related recommendations: mysql video tutorial]

The above is the detailed content of How to query whether the database exists in mysql. For more information, please follow other related articles on the PHP Chinese website!

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