BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

SQL DROP DATABASE Statement

Last Updated: August 15, 2022 by Chaitanya Singh | Filed Under: SQL

The SQL DROP database statement is used to delete the existing database from the database management system. This statement permanently deletes the specified database from the system which includes all the tables, schemas, views and all the data that is stored inside the specified database.

SQL DROP database syntax

DROP DATABASE databaseName;

There are two things that you need to remember while deleting a database:
1. Dropping a database is not frequently used as it can delete the important data which is not used now but maybe required later. This is why it is important to take a backup of the database before you delete it using DROP DATABASE statement. The backup ensures that if in case, you need the data, you can easily restore the database and get the required data.

2. If the database is already in use while you are deleting it then you will get the following error message: Let’s say you are dropping the database ‘Employee’ while other database user is currently working on the database ‘Employee’

"Cannot drop database "Employee" because it is currently in use".

Drop Multiple Databases using DROP DATABASE statement

DROP DATABASE db1, db2, db3;

This statement will drop three databases db1, db2 and db3 from the database system.

SQL DROP DATABASE statement Example

The following statement would delete the database named “Student”.

SQL> DROP DATABASE Student;

Note: By deleting a database, you are deleting all of its tables implicitly. For example, the above statement would delete all the tables that are stored inside “Student” database, along with the database.

After dropping a database you can check the database list to cross verify that the database has been successfully dropped or not. This is how you can do it.

Before deleting “Student” Database:

SQL> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| Abc                |
| Xyz                |
| Student            |
| Demo               |
| Test               |
+--------------------+
5 rows in set (0.00 sec)

After deleting “Student” Database:

SQL> DROP DATABASE Student;

List down the databases:

SQL> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| Abc                |
| Xyz                |
| Demo               |
| Test               |
+--------------------+
4 rows in set (0.00 sec)

Top Related Articles:

  1. Introduction to SQL
  2. SQL SELECT TOP Statement
  3. SQL CREATE DATABASE Statement
  4. SQL Rename Database using ALTER DATABASE Statement
  5. SQL UPDATE Statement

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

SQL Tutorial

  • SQL Tutorial
  • SQL Introduction
  • SQL Syntax
  • SQL Data Types

SQL Database

  • SQL CREATE DB
  • SQL DROP DB
  • SQL Rename DB
  • SQL USE DB

SQL Queries

  • SQL Select
  • SQL Select Distinct
  • SQL Select Count
  • SQL Select Top
  • SQL Where
  • SQL AND, OR & NOT
  • SQL Order By
  • SQL Insert Into
  • SQL Insert Into SELECT
  • SQL Select Random
  • SQL Alias
  • SQL NULL Check
  • SQL Update
  • SQL Delete
  • SQL MIN, MAX
  • SQL SUM
  • SQL AVG

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap