Document MS SQL :useBulkCopyForBatchInsert

This commit is contained in:
Daniel Skarda 2022-08-15 17:50:08 +02:00
parent 4191311972
commit 8b9b6af023

View file

@ -120,6 +120,12 @@ MS SQL Server supports execution of multiple statements when surrounded by `begi
[{.. table2 row ..} {.. table2 row ..} {..}]] [{.. table2 row ..} {.. table2 row ..} {..}]]
``` ```
### Batch Statements
Even when using `next.jdbc/execute-batch!`, MySQL will still send multiple insert statements to the database unless you specify `:useBulkCopyForBatchInsert true` as part of the db-spec hash map or JDBC URL when the datasource is created.
To use this feature your Microsoft's JDBC driver should be at least version 9.2 and you can use only limited set of data types. For example if you use `inst` to bulk insert data driver will revert to old (slow) behavior. For more details see [Using bulk copy API for batch insert operation](https://docs.microsoft.com/en-us/sql/connect/jdbc/use-bulk-copy-api-batch-insert-operation?view=sql-server-ver16) and [Release notes for JDBC drivers](https://docs.microsoft.com/en-us/sql/connect/jdbc/release-notes-for-the-jdbc-driver?view=sql-server-ver16).
## MySQL & MariaDB ## MySQL & MariaDB
In MySQL, the generated key from an insert comes back as `:GENERATED_KEY`. In MariaDB, the generated key from an insert comes back as `:insert_id`. In MySQL, the generated key from an insert comes back as `:GENERATED_KEY`. In MariaDB, the generated key from an insert comes back as `:insert_id`.