0
0
SQLquery~20 mins

INSERT INTO multiple rows in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Multi-Row Insert Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What rows are inserted by this query?
Given the table students with columns id and name, what rows will be inserted by this SQL statement?
SQL
INSERT INTO students (id, name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');
ATwo rows: (1, 'Alice'), (2, 'Bob')
BOne row: (1, 'Alice') only
CThree rows: (1, 'Alice'), (2, 'Bob'), (3, 'Charlie')
DNo rows inserted due to syntax error
Attempts:
2 left
💡 Hint
Look at how many sets of values are inside the VALUES clause.
📝 Syntax
intermediate
2:00remaining
Which option is a valid syntax for inserting multiple rows?
Choose the correct SQL syntax to insert multiple rows into a table named products with columns product_id and product_name.
AINSERT INTO products (product_id, product_name) VALUES (101, 'Pen'), (102, 'Pencil');
BINSERT INTO products VALUES (101, 'Pen'), (102, 'Pencil');
CINSERT INTO products (product_id, product_name) VALUES (101, 'Pen'); (102, 'Pencil');
DINSERT INTO products (product_id, product_name) VALUES (101, 'Pen' AND 102, 'Pencil');
Attempts:
2 left
💡 Hint
Multiple rows are inserted by separating value sets with commas inside one VALUES clause.
optimization
advanced
2:00remaining
Which method is more efficient for inserting 1000 rows?
You want to insert 1000 rows into a table orders. Which SQL approach is generally more efficient?
AInserting rows one by one inside a loop in application code
BOne INSERT statement with 1000 rows in VALUES clause
CUsing 10 INSERT statements with 100 rows each
D1000 separate INSERT statements, one per row
Attempts:
2 left
💡 Hint
Fewer statements reduce overhead and improve performance.
🔧 Debug
advanced
2:00remaining
Why does this multi-row INSERT fail?
Given the table employees with columns id (integer) and name (text), why does this query fail? INSERT INTO employees (id, name) VALUES (1, 'John'), (2);
ASecond row has missing value for 'name' column
BSyntax error due to missing comma between rows
CDuplicate id value causes constraint violation
DTable 'employees' does not exist
Attempts:
2 left
💡 Hint
Check if each row has the same number of values as columns listed.
🧠 Conceptual
expert
2:00remaining
What happens if you omit column names in multi-row INSERT?
Consider this query: INSERT INTO inventory VALUES (1, 'ItemA'), (2, 'ItemB'); What is true about this statement?
AIt inserts only the first row and ignores the second
BIt causes syntax error because column names are required
CIt inserts rows but sets all unspecified columns to NULL
DIt inserts rows assuming values match all columns in table order
Attempts:
2 left
💡 Hint
When column names are omitted, values must match all columns in order.