How to drop a database in SQL?

A

Amit Tiwari

Drop a database in SQL is means that deleting a database in SQL. There is two way to drop a database in SQL.

  1. Using query
  2. Using manual ways

1 - Using Query

To drop a database in SQL we use below query

" drop database database_name "

In the above query, database_name is the name of the database which you want to delete.

Problem - 

Sometimes if database files being used then if we run above query to drop database then it gives some error, to solve this problem you can use below query.

ALTER database database_name set offline with ROLLBACK IMMEDIATE;

DROP database database_name;

Very Very Important - 

On dropping a database in SQL, you are going to delete the database and lose all your record available in the database. If once it is deleted you can't get those record back, so be careful.

2- Drop using the manual way

It is quite easy, open SQL server, to in Object Explorer and then in databases, now you will find all your database there now right-click on the database name which you want to delete and select the delete option and click ok, the database will be deleted. 

1 votes

Your Answer

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

LifeStyle & Fun

© 2024 GDATAMART.COM (All Rights Reserved)