What is the difference between DELETE and DROP in SQL?

What is the difference between DELETE and DROP in SQL?

a) DELETE removes rows, DROP removes entire tables
b) DELETE is faster than DROP
c) DROP cannot be rolled back, DELETE can
d) DELETE works on indexes, DROP works on tables

Answer:

a) DELETE removes rows, DROP removes entire tables

Explanation:

The DELETE command removes rows from a table based on a condition, whereas the DROP command deletes the entire table and all its data. DELETE allows for selective removal of data, and the changes can be rolled back if wrapped in a transaction.

DROP, on the other hand, is used to remove the entire table structure from the database, and it cannot be undone in many database systems. DROP also removes all associated indexes, constraints, and triggers.

DELETE is useful for removing specific rows from a table, while DROP is used for completely removing database objects like tables, views, and indexes.

Reference:

Database Management System MCQ (Multiple Choice Questions)

Scroll to Top