Questions: DELETE Statements: Removing Rows with Conditions

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer runs: DELETE FROM orders WHERE customer_id IN (SELECT id FROM customers WHERE status = 'inactive'). The orders table has a foreign key referencing the order_items table with ON DELETE CASCADE. What happens?

AThe statement fails because you cannot use a subquery in a DELETE WHERE clause
BOnly the orders rows are deleted; order_items rows must be deleted separately
CBoth the matching orders rows and all their associated order_items rows are deleted automatically
DThe foreign key constraint blocks the delete until order_items rows are removed first
Question 2 Multiple Choice

What does a bare DELETE FROM employees statement (no WHERE clause) do?

AIt prompts for confirmation before executing since no filter is provided
BIt deletes only the most recently inserted rows as a safety measure
CIt deletes every row in the table, leaving the table structure intact
DIt raises a syntax error because WHERE is required by the SQL standard
Question 3 True / False

Running SELECT first with the same WHERE clause you plan to use in DELETE is a best practice because it lets you preview exactly which rows will be removed before committing to the deletion.

TTrue
FFalse
Question 4 True / False

If a DELETE statement's WHERE clause matches zero rows, the database returns an error indicating no rows were affected.

TTrue
FFalse
Question 5 Short Answer

Why is batched deletion (deleting in chunks) preferred over a single large DELETE when removing millions of rows from a production table?

Think about your answer, then reveal below.