How to delete database in mysql

青灯夜游
Release: 2022-01-06 16:22:57
Original
32548 people have browsed it

In mysql, you can use the "DROP DATABASE" statement to delete the database. The specific syntax format is "DROP DATABASE [IF EXISTS] database name;"; the optional clause "IF EXISTS" is used to prevent An error occurred when the database does not exist.

How to delete database in mysql

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

Mysql method of deleting a database

Deleting a database means that all data and associated objects in the database will be permanently deleted and cannot be undone. Therefore, it is very important to perform this query with additional considerations.

To drop a database, use the DROP DATABASE statement as follows:

DROP DATABASE [IF EXISTS] 数据库名;
Copy after login

Follow DROP DATABASE is the name of the database to be dropped. Similar to the CREATE DATABASE statement,IF EXISTSis an optional part of the statement to prevent an error when you delete a database that does not exist in the database server.

If you want to practice using the DROP DATABASE statement, you can create a new database and then delete it. Let’s look at the following query:

CREATE DATABASE IF NOT EXISTS tempdb; SHOW DATABASES; DROP DATABASE IF EXISTS tempdb;
Copy after login

The description of the three statements is as follows:

  • First, use theCREATE DATABASEstatement to create a file named tempdb database.

  • Second, use theSHOW DATABASESstatement to display all databases.

  • Third, use theDROP DATABASEstatement to delete the database named tempdb.

[Related recommendations:mysql video tutorial]

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!

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