Practical introduction to relational databases

Inserting bulk data

With the insert statement we can insert multiple rows at once without needing to repeat the entire sequence. Consider the following situation: you have a bunch of data about different products to insert into the table. So far you've learned the following query will work:

INSERT INTO schema.table (col1, col2)
VALUES (value_for_col1, value_for_col2);

You might be thinking: "wait, do I need to repeat this for every row?"

separate queries for individual rows

This would be super inefficient. And there's a better way:

one query to insert multiple rows

We still start the insert statement, but when it comes to the values part, we keep one row's data within parens (()), and comma separate the data for each individual row.

This is important enoguh and common enough to get its own page. Once you're ready, move on to learning about inserting data from a different table.