Home > Database > Mysql Tutorial > body text

How to query whether the database exists in mysql

青灯夜游
Release: 2021-12-28 17:12:15
Original
6824 people have browsed it

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 = '数据库名称';
Copy after login

Method 2:

Execute the following statement

show databases like '数据库名称';
Copy after login

Expand knowledge: Query whether the data table exists

show tables like 'table_name';
Copy after login

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

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