Which of the following best explains why the DELETE command in SQL requires caution?
Think about what happens to data after DELETE runs.
DELETE removes rows permanently from a table. Without backups, the data is lost forever, so it must be used carefully.
Given a table Employees with 5 rows, what happens if you run DELETE FROM Employees; without a WHERE clause?
Consider what DELETE does when no filter is applied.
DELETE without WHERE removes all rows from the table but keeps the table structure intact.
Which DELETE statement will cause a syntax error?
DELETE Employees WHERE id = 10;
Check the required keywords in DELETE syntax.
The DELETE statement requires the keyword FROM before the table name. Omitting FROM causes a syntax error.
You need to delete 1 million rows from a large table. Which approach is best to avoid locking the entire table?
Think about how to reduce locking and transaction size.
Deleting in small batches reduces locks and transaction log size, improving performance and reducing impact.
Consider this query:
DELETE FROM Orders WHERE OrderDate = '2023-01-01';
After running it, more rows than expected were deleted. What is the most likely cause?
Think about how date and time values are stored and compared.
If OrderDate includes time, comparing to '2023-01-01' matches all times on that date, possibly more rows than intended.