0
0
SQLquery~5 mins

INSERT INTO multiple rows in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL command INSERT INTO do?
It adds new rows (records) into a table in the database.
Click to reveal answer
beginner
How do you insert multiple rows in one SQL statement?
Use INSERT INTO table_name (columns) VALUES (row1), (row2), (row3); listing each row's values separated by commas.
Click to reveal answer
intermediate
Why is inserting multiple rows at once better than inserting one row at a time?
It is faster and uses fewer resources because the database processes one command instead of many.
Click to reveal answer
beginner
Write an example SQL query to insert two rows into a table named students with columns id and name.
INSERT INTO students (id, name) VALUES (1, 'Alice'), (2, 'Bob');
Click to reveal answer
intermediate
What happens if you try to insert rows with duplicate primary keys using INSERT INTO multiple rows?
The database will return an error and will not insert any of the rows unless you handle duplicates with special clauses.
Click to reveal answer
Which SQL syntax correctly inserts multiple rows into a table named products?
AINSERT INTO products (id, name) VALUES (1, 'Pen'), (2, 'Pencil');
BINSERT INTO products (id, name) VALUES (1, 'Pen'); INSERT INTO products (id, name) VALUES (2, 'Pencil');
CINSERT MULTIPLE INTO products VALUES (1, 'Pen'), (2, 'Pencil');
DINSERT INTO products VALUES (1, 'Pen') AND (2, 'Pencil');
What separates each row's values in a multi-row INSERT statement?
ASemicolon (;)
BComma (,)
CPeriod (.)
DColon (:)
If you want to insert three rows into a table, how many times do you write the column names in the INSERT statement?
AOnce
BZero times
CTwice
DThree times
What will happen if one row in a multi-row INSERT violates a constraint (like a duplicate primary key)?
AAll rows are inserted except the bad one
BThe database ignores the error and continues
COnly the first row is inserted
DNo rows are inserted and an error is returned
Which of these is a benefit of inserting multiple rows at once?
ASlower performance
BMore network traffic
CLess resource usage
DMore complex syntax
Explain how to insert multiple rows into a SQL table in one command.
Think about how you add many items to a list in one go.
You got /3 concepts.
    What are the advantages and possible errors when using multi-row INSERT statements?
    Consider speed and error handling.
    You got /3 concepts.