DROP DATABASE Syntax

DROP DATABASE drops all tables in the database and deletes the database. DROP SCHEMA is a synonym for DROP DATABASE. IF EXISTS is used to prevent an error from occurring if the database does not exist.

Removing database means you delete the database physically. All the data and related objects inside the database are permanently deleted and cannot be undone. So it is very important to execute this query with care. MySQL provides a standard SQL statement DROP DATABASE to allow you to delete a database:

DROP {DATABASE | SCHEMA} [IF EXISTS] db_name;

Eg:

CREATE DATABASE IF NOT EXISTS temp_database;
SHOW DATABASES;
DROP DATABASE IF EXISTS temp_database;
SHOW DATABASES;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.