How to insert multiple rows in a single PostgreSQL query? #730
-
Hi @kyleconroy, The first, I really like this repo. Thank for your effort, Now, I want inserting multiple rows in a single query like:
I don't know how to write in sqlc? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi,
However, with where clause like:
I don't know how to write in sqlc? |
Beta Was this translation helpful? Give feedback.
-
Sadly, this isn't currently supported. Your unnest solution is interesting, I wonder how well it performs for a large number of records. How many records are your trying to insert? PostgreSQL has a guide for inserting large amounts of data. If you aren't inserting many records, I'd just use a transaction. Sorry that there isn't a better answer. This has also been discussed in #216 and #218, which you may find helpful. |
Beta Was this translation helpful? Give feedback.
Sadly, this isn't currently supported. Your unnest solution is interesting, I wonder how well it performs for a large number of records. How many records are your trying to insert? PostgreSQL has a guide for inserting large amounts of data. If you aren't inserting many records, I'd just use a transaction. Sorry that there isn't a better answer.
This has also been discussed in #216 and #218, which you may find helpful.