How to insert multiple rows with a single query?
See original GitHub issueI have n
number of items. I would like to add them all with a single insert query.
insert into testtable(id,name) values (1,"jack"),(2,"john"),(3,"jill");
I have an array for my rows, and I like to add them all in. So, if I provide pg
the correct string (after manually forming it in a variable) it works perfectly fine, but this all seemed a bit pointless to me. I expect pg to handle arrays for me as well, but I’m unable to find the option for that. So I’m asking, is this possible?
How can I insert multiple rows from an array of rows, with a single insert query with this library?
Would love to know. Thank you.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:21
- Comments:13 (4 by maintainers)
Top Results From Across the Web
SQL Server INSERT Multiple Rows Into a Table Using One ...
To insert multiple rows returned from a SELECT statement, you use the INSERT INTO SELECT statement. SQL Server INSERT multiple rows – examples....
Read more >Inserting multiple rows in a single SQL query? - Stack Overflow
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists ...
Read more >SQL Query to Insert Multiple Rows - GeeksforGeeks
In this article, we see how to insert individual as well as multiple rows in a database using the INSERT statement in the...
Read more >How to INSERT Multiple Records in SQL - DigitalOcean
SQL INSERT query inserts data into the columns of a particular table. The normal SQL INSERT query inputs the data values in a...
Read more >SQL INSERT Multiple Rows - Javatpoint
SQL INSERT Multiple Rows · mysql> USE dbs; · mysql> CREATE TABLE student(ID INT, Name VARCHAR(20), Percentage INT, Location VARCHAR(20), DateOfBirth DATE);.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using pg-format with a nested array:
Disclaimer: I wrote pg-format.
@x0days That’s for MySQL, not PostgreSQL.
@zettam: