Challenge - 5 Problems
Master of Single Row Inserts
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the result of this INSERT statement?
Consider a table employees with columns
What will be the content of the table after running this query?
id (integer), name (text), and age (integer).What will be the content of the table after running this query?
INSERT INTO employees (id, name, age) VALUES (1, 'Alice', 30);
SQL
SELECT * FROM employees;
Attempts:
2 left
💡 Hint
The INSERT statement adds one row with the specified values.
✗ Incorrect
The INSERT INTO statement adds a single row with id=1, name='Alice', and age=30 to the employees table.
📝 Syntax
intermediate2:00remaining
Which INSERT statement is syntactically correct?
Given a table
products with columns product_id (int), product_name (text), and price (decimal), which of the following INSERT statements will run without syntax errors?Attempts:
2 left
💡 Hint
Check the order of keywords and commas between column names.
✗ Incorrect
Option D follows the correct syntax: INSERT INTO table VALUES (...). Options A, B, and D have syntax errors such as wrong keyword order, missing commas, or missing parentheses.
❓ optimization
advanced2:00remaining
Which INSERT statement is more efficient for adding a single row?
You want to insert a single row into the
orders table with columns order_id, customer, and total. Which option is more efficient and why?Attempts:
2 left
💡 Hint
If you provide values for all columns in order, you can omit column names.
✗ Incorrect
Option A is more efficient because it omits column names when all columns are provided in the correct order. Option A is correct but slightly longer. Option A unnecessarily uses SELECT. Option A is MySQL-specific and not standard.
🔧 Debug
advanced2:00remaining
What error does this INSERT statement produce?
Given a table
users with columns id (integer, primary key), username (text), and email (text), what error will this statement cause?INSERT INTO users (id, username) VALUES (1, 'bob');
Attempts:
2 left
💡 Hint
If a column is not specified and allows NULL, it defaults to NULL.
✗ Incorrect
Since email is not specified and assuming it allows NULL, the row inserts with email as NULL. No syntax error or duplicate key error occurs.
🧠 Conceptual
expert2:00remaining
What happens if you insert a row with a duplicate primary key?
Consider a table
inventory with item_id as the primary key. What is the result of this query?INSERT INTO inventory (item_id, name) VALUES (10, 'Widget');
INSERT INTO inventory (item_id, name) VALUES (10, 'Gadget');
Attempts:
2 left
💡 Hint
Primary keys must be unique in a table.
✗ Incorrect
The second INSERT fails because it tries to insert a row with an existing primary key value, violating uniqueness constraints.