H2 SQL database - INSERT if the record does not exist

后端 未结 4 1185
名媛妹妹
名媛妹妹 2020-12-19 04:29

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

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 05:09

    MERGE INTO ACCESSLEVELS 
      KEY(ID) 
    VALUES (0, 'admin'),
      (1, 'SEO'),
      (2, 'sales director'),
      (3, 'manager'),
      (4, 'REP');
    

    Updates existing rows, and insert rows that don't exist. If no key column is specified, the primary key columns are used to find the row.

提交回复
热议问题