I would like initialize a H2 database, but I am not sure if the records exist. If they exist I don\'t want to do anything, but if they don\'t exist I would like to write the
To do this you can use MySQL Compatibility Mode in H2 database. Starting from 1.4.197 version it supports the following syntax:
INSERT IGNORE INTO table_name VALUES ...
From this pull request:
INSERT IGNOREis not supported in Regular mode, you have to enable MySQL compatibility mode explicitly by appending;MODE=MySQLto your database URL or by executingSET MODE MySQLstatement.
From official site:
INSERT IGNOREis partially supported and may be used to skip rows with duplicate keys ifON DUPLICATE KEY UPDATEis not specified.