Which of the following commands is used to remove all rows from a table without deleting the table itself?

Which of the following commands is used to remove all rows from a table without deleting the table itself?

a) DELETE
b) DROP
c) TRUNCATE
d) ALTER

Answer:

c) TRUNCATE

Explanation:

The TRUNCATE command is used to remove all rows from a table without deleting the table itself. Unlike DELETE, which removes rows one at a time and can have WHERE conditions, TRUNCATE is faster because it deallocates the table’s data pages directly.

TRUNCATE is often used when you want to quickly remove all data from a table but retain its structure for future use. It is generally faster than DELETE for large tables because it does not generate individual row-level delete operations.

Note that TRUNCATE cannot be rolled back in some database systems, making it a more permanent operation compared to DELETE.

Reference:

Database Management System MCQ (Multiple Choice Questions)

Scroll to Top