CompTIA Tech+ (FC0-U71)Data and Database FundamentalsEasy
A database administrator needs to permanently remove all records from a Customers table where the Status field equals 'Inactive', without dropping the table itself. Which SQL statement should be used?
- ADROP TABLE Customers WHERE Status = 'Inactive';
- BSELECT * FROM Customers WHERE Status = 'Inactive';
- CDELETE FROM Customers WHERE Status = 'Inactive';
- DUPDATE Customers SET Status = 'Inactive';
Show answer & explanationAnswer & explanation
Correct answer: C. DELETE FROM Customers WHERE Status = 'Inactive';
The DELETE statement removes rows that match a WHERE condition while leaving the table structure intact. DROP TABLE removes the entire table, UPDATE changes values instead of removing rows, and SELECT only retrieves data.
Why the other options are wrong
- A. DROP TABLE deletes the entire table structure, not just rows.
- B. SELECT only retrieves data; it does not delete anything.
- D. UPDATE modifies existing data rather than removing records.
SQL DELETE Statement
A SQL command used to remove one or more rows from a table based on a specified condition.
- Syntax: DELETE FROM table WHERE condition;
- Omitting WHERE deletes all rows in the table
- Does not remove the table structure itself
Memory trick: DELETE digs out rows, DROP demolishes the whole table.