![]() |
SQL DROP DATABASE statement deletes an existing database from the system, and once deleted, users can not retrieve that database. The DROP DATABASE command in SQL deletes the database along with its data, like tables, views, indexes, constraints, and properties like permissions and schemas. SyntaxSQL DROP TABLE syntax is:
SQL DROP DATABASE ExamplesLet’s look at some examples of the DROP DATABASE statement in SQL. First, let’s create a database on which we will run the query. CREATE DATABASE GeeksForGeeks;
Now if we look at the list of databases in our system, we can find the “GeeksforGeeks” database. Query: SHOW DATABASES;
![]() List of Databases Now we will use the DROP DATABASE command, to delete the database ‘GeeksforGeeks’. QueryDROP DATABASE GeeksForGeeks;
Output![]() DROP DATABASE Verify DROP DATABASE StatementAfter the database has been deleted/dropped successfully we will now verify that whether the database exist in the system or not. So, we will once again use the SHOW DATABASES command and verify that the GeeksForGeeks database has been deleted or not. QuerySHOW DATABASES;
Output![]() Deleted Data SQL DROP DATABASE IF EXISTSTo avoid any error while running the DROP DATABASE command use the IF EXISTS clause, which will delete the database only if it exists in the system. Syntax
Important Points About SQL DROP DATABASE Statement
|
Reffered: https://www.geeksforgeeks.org
SQL |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |