Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
Importing records
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A common use-case for importing records via jOOQ's Loader API is when data needs to be transferred between databases. For instance, when fetching the following data from database 1:
Result<Record3<Integer, Integer, String>> result = DSL.using(configuration1) .select(BOOK.ID, BOOK.AUTHOR_ID, BOOK.TITLE) .from(BOOK) .fetch();
Now, this result should be imported back into a database 2:
// Specify fields from the target table to be matched with fields from the source result by position.
create.loadInto(BOOK)
.loadRecords(result)
.fields(BOOK.ID, BOOK.AUTHOR_ID, BOOK.TITLE)
.execute();
// Use "null" field placeholders to ignore source columns by position.
create.loadInto(BOOK)
.loadRecords(result)
.fields(BOOK.ID, null, BOOK.TITLE)
.execute();
// Match target fields with source fields by "corresponding" name.
create.loadInto(BOOK)
.loadRecords(result)
.fieldsCorresponding()
.execute();
No other, Record-specific options are currently available.
Feedback
Do you have any feedback about this page? We'd love to hear it!