;"."/> ;".">

Home  >  Article  >  Database  >  How to delete database in MySQL

How to delete database in MySQL

青灯夜游
青灯夜游Original
2021-01-18 15:51:4439524browse

Method: You can use the "DROP DATABASE" statement to delete the created database; the specific syntax is "DROP DATABASE [IF EXISTS] e5c249aa15ff4c64720f99bfaecf8a60;".

How to delete database in MySQL

The operating environment of this tutorial: Windows 7 system, mysql version 8.0.22, Dell G3 computer.

(Recommended tutorial: mysql video tutorial)

In MySQL, when you need to delete a created database, you can use the DROP DATABASE statement. The syntax format is:

DROP DATABASE [ IF EXISTS ] <数据库名>;

The syntax description is as follows:

  • 51ede4c6d43f3b2169203bd49746727d: Specify the name of the database to be deleted.

  • IF EXISTS: Used to prevent errors from occurring when the database does not exist.

  • DROP DATABASE: Delete all tables in the database and delete the database at the same time. Be very careful when using this statement to avoid mistaken deletions. If you want to use DROP DATABASE, you need to obtain database DROP permission.

Example:

Query the database list

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| test_db            |
| world              |
+--------------------+
7 rows in set (0.00 sec)

Delete the database test_db from the database list

mysql> DROP DATABASE test_db;
Query OK, 0 rows affected (0.57 sec)

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| world              |
+--------------------+
6 rows in set (0.00 sec)

For more programming-related knowledge, please visit: programming video! !

The above is the detailed content of How to delete database 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