DROP DATABASE Syntax

10 February 2012 By Praveen Macherla 599 views No Comment
1 Flares Twitter 0 Facebook 1 Google+ 0 1 Flares ×

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;