[MDEV-15041] Implement MERGE statement Created: 2018-01-23  Updated: 2023-09-25

Status: Open
Project: MariaDB Server
Component/s: Server
Fix Version/s: None

Type: Task Priority: Major
Reporter: Alexander Bienemann (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: Compatibility, SQL

Issue Links:
Blocks
is blocked by MDEV-13648 Add FULL OUTER JOIN to MariaDB Open
PartOf
is part of MDEV-10872 Providing compatibility Oracle database Open

 Description   

The MERGE statement as in https://en.wikipedia.org/wiki/Merge_(SQL) should be implemented.



 Comments   
Comment by Nicola Marangoni [ 2018-04-19 ]

It would be nice to have the MERGE implemented like in SQL Server 2008 and not like in Oracle or DB2:

MERGE
  targetTable
USING
  sourceTable
ON
  mergeCondition
WHEN MATCHED THEN
  updateStatement
WHEN NOT MATCHED BY TARGET THEN
  insertStatement
WHEN NOT MATCHED BY SOURCE THEN
  deleteStatement

This implementation allows for the switch WHEN NOT MATCHED, WHEN NOT MATCHED BY TARGET and WHEN NOT MATCHED BY SOURCE
Oracle and DB2 only allow WHEN NOT MATCHED.

https://www.essentialsql.com/introduction-merge-statement/

Comment by Alexander Bienemann (Inactive) [ 2019-03-29 ]

The MERGE statement can be complex to migrate if not implemented in MariaDB Server directly:
It is not just a REPLACE INTO, but can be - depending on the application case - a rather complex statement ("UPSERT").

Please implement.

Comment by Ian Gilfillan [ 2023-09-25 ]

This was recently covered on modern-sql.com: https://modern-sql.com/caniuse/merge

Generated at Thu Feb 08 08:18:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.