100 Days of SQL

sql

Day 29 – SQL DROP DATABASE

The SQL DROP DATABASE statement is used to delete an existing database in a SQL Server instance. The syntax for the DROP DATABASE statement is as follows:


DROP DATABASE database_name;

In this syntax, “database_name” is the name of the database that you want to delete.

Here’s an example of how to drop a database named “my_database”:


DROP DATABASE my_database;

When this statement is executed, SQL Server will delete the database named “my_database” and all its associated objects such as tables, views, stored procedures, and functions.

It’s important to note that dropping a database is a permanent action and cannot be undone. Therefore, it’s recommended to take a backup of the database before dropping it. Additionally, ensure that you have the required permissions to drop a database.