Reader small image

You're reading from  jOOQ Masterclass

Product typeBook
Published inAug 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800566897
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Anghel Leonard
Anghel Leonard
author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard

Right arrow

Expressing MERGE statements

The MERGE statement is quite a powerful tool; it allows us to perform INSERT/UPDATE and even DELETE on a table known as the target table from a table known as the source table. I strongly suggest you read this article, especially if you need a quick reminder of the MERGE statement: https://blog.jooq.org/2020/04/10/the-many-flavours-of-the-arcane-sql-merge-statement/.

MySQL and PostgreSQL support a MERGE flavor known as UPSERT (INSERT or UPDATE) via ON DUPLICATE KEY UPDATE, respectively via ON CONFLICT DO UPDATE clauses. You can find examples of these statements next to the well-known INSERT IGNORE INTO (MySQL) and ON CONFLICT DO NOTHING (PostgreSQL) clauses in the code bundled with this book. By the way, we can use all these statements interchangeably (for example, we can use onConflictDoNothing() with MySQL and onDuplicateKeyIgnore() with PostgreSQL), since jOOQ will always emulate the correct syntax. We can even use them with SQL Server and Oracle,...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
jOOQ Masterclass
Published in: Aug 2022Publisher: PacktISBN-13: 9781800566897

Author (1)

author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard