SQL Questions and Answers – SQL Drop DB

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Drop DB”.

1. Which of the following command is used to delete a database in SQL?
a) DELETE
b) DROP
c) ERASE
d) TRUNCATE
View Answer

Answer: b
Explanation: The DROP command is used to delete a database in SQL. The same command can be used to delete a table within the database. The DELETE command is used to delete the specific information present inside the table. The TRUNCATE command is used to delete complete data from the table. Be careful while using the DROP command for deleting the database as it will affect all the tables present inside the database.

2. Which of the following statement is used to delete a database in SQL?
a) DROP DATABASE
b) DROP database_name
c) DROP DATABASE database_name
d) DROP DATABASE (database_name)
View Answer

Answer: c
Explanation: The syntax which is used to delete a database in SQL is –

DROP DATABASE database_name

In this statement DROP and DATABASE are keywords that remain the same for every statement using the DROP command, while database_name is the specific name of the database which has to be dropped and varies from statement to statement. The same syntax is used when using DROP for deleting a table.

advertisement
advertisement

3. Can a database be dropped regardless of its state?
a) True
b) False
View Answer

Answer: a
Explanation: A database can be dropped regardless of its state i.e. offline, read-only, suspect, etc. To view the current state of a database we can use the sys.databases catalog view.

4. After dropping a database snapshot in SQL, it can be re-created by restoring a backup.
a) True
b) False
View Answer

Answer: b
Explanation: In SQL, a dropped database can only be re-created by restoring a backup of it. But the database snapshots cannot be backed up and, therefore, cannot be restored.

5. Which of the following statement can be used to drop multiple databases at once?
a) DROP DATABASE database_name1 and database_name2
b) DELETE DATABASE database_name1, database_name2
c) DROP database_name1, database_name2
d) DROP DATABASE database_name1, database_name2
View Answer

Answer: d
Explanation: By using the statement – DROP DATABASE database_name1, database_name2, we can drop each of the listed databases. In the statement, database names are just separated by a comma (,).
advertisement

6. In SQL, a database that is currently in use cannot be dropped.
a) True
b) False
View Answer

Answer: a
Explanation: You cannot drop a database currently being used i.e. open for reading or writing by any user. One way to remove users from the database is to use the ALTER DATABASE command to set the database to SINGLE_USER.

7. Which of the following statement is used to conditionally drop a database that already exists?
a) DROP DATABASE IF NOT EXISTS database_name
b) DROP DATABASE IF EXISTS database_name
c) DROP DATABASE EXISTS database_name
d) DROP DATABASE NOT EXISTS database_name
View Answer

Answer: b
Explanation: The IF EXISTS command is used with the DROP command to conditionally drop a database only if it already exists in the SQL Server. If we try to drop a database that is not present, SQL will give us an error. To prevent an error from occurring we can use the IF EXISTS option.
advertisement

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.