Challenge - 5 Problems
DML Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding INSERT statement behavior
What will happen if you execute the following SQL statement on a table Employees with columns id (primary key) and name where id 101 already exists?
INSERT INTO Employees (id, name) VALUES (101, 'Alice');
Attempts:
2 left
💡 Hint
Primary keys must be unique in a table.
✗ Incorrect
An INSERT statement tries to add a new row. Since id 101 already exists and is a primary key, the database will reject the insert to prevent duplicate keys, causing an error.
🔍 Analysis
intermediate2:00remaining
Effect of UPDATE with WHERE clause
Consider a table Products with columns product_id, price, and stock. What will be the effect of this SQL statement?
UPDATE Products SET price = price * 1.1 WHERE stock = 0;
Attempts:
2 left
💡 Hint
The WHERE clause filters which rows are updated.
✗ Incorrect
The UPDATE statement changes the price only for rows where stock equals zero. Other rows remain unchanged.
📋 Factual
advanced2:00remaining
DELETE statement without WHERE clause
What is the result of executing the following SQL command?
DELETE FROM Orders;
Attempts:
2 left
💡 Hint
Think about what happens when no filter is applied in DELETE.
✗ Incorrect
Without a WHERE clause, DELETE removes all rows from the table but keeps the table structure intact.
❓ Comparison
advanced2:00remaining
Difference between DELETE and TRUNCATE
Which of the following statements correctly describes a key difference between DELETE and TRUNCATE commands in SQL?
Attempts:
2 left
💡 Hint
Consider how each command handles transaction logs and rollback.
✗ Incorrect
DELETE removes rows individually and logs each deletion, allowing rollback. TRUNCATE quickly removes all rows by deallocating data pages and usually cannot be rolled back.
❓ Reasoning
expert3:00remaining
Predicting the final state after multiple DML operations
Given a table Inventory with columns item_id and quantity, initially containing:
What will be the contents of the table after executing these statements in order?
item_id | quantity 1 | 10 2 | 5 3 | 0
What will be the contents of the table after executing these statements in order?
UPDATE Inventory SET quantity = quantity - 5 WHERE item_id = 1; DELETE FROM Inventory WHERE quantity <= 0; INSERT INTO Inventory (item_id, quantity) VALUES (3, 7);
Attempts:
2 left
💡 Hint
Apply each statement step-by-step and watch how rows change or get deleted.
✗ Incorrect
First, item 1 quantity reduces from 10 to 5. Then rows with quantity <= 0 are deleted, so item 3 (quantity 0) is removed. Finally, item 3 is reinserted with quantity 7.