H2数据库Postgres模式Upsert

Ton*_*phy 8 java postgresql h2

当H2数据库处于Postgres模式时,如何检查它是否支持以下语句(upsert/on conflict)

INSERT INTO event_log_poller_state(aggregate_type, consumer_group_id, value) VALUES (?, ?, ?) on conflict (aggregate_type, consumer_group_id) " +
                    " do update SET VALUE = ? WHERE event_log_poller_state.aggregate_type = ? AND event_log_poller_state.consumer_group_id = ?
Run Code Online (Sandbox Code Playgroud)

我得到语法错误42000

我写了以下程序来演示

https://github.com/tonymurphy/h2-postgres

Chr*_*ris 1

有合并应该做同样的事情:https ://www.tutorialspoint.com/h2_database/h2_database_merge.htm

MERGE INTO tableName [ ( columnName [,...] ) ] 
[ KEY ( columnName [,...] ) ] 
{ VALUES { ( { DEFAULT | expression } [,...] ) } [,...] | select } 
Run Code Online (Sandbox Code Playgroud)

另请参阅https://github.com/h2database/h2database/issues/2007#issuecomment-1152312049