정리

'Replace'에 해당되는 글 1건

  1. SQLite - insert or replace (upsert)

SQLite - insert or replace (upsert)

저장소/VC++

데이터가 있으면 update 하고 없으면 insert 하는 방법을 찾다가 정리한다.

'insert or replace' 에 대한 내용은 아래 링크 참고.



INSERT OR REPLCAE example


SQLite Query Language: INSERT

SQLite Query Language: REPLACE

SQLite Query Language: ON CONFLICT clause


REPLACE


When a UNIQUE constraint violation occurs, the REPLACE algorithm deletes pre-existing rows that are causing the constraint violation prior to inserting or updating the current row and the command continues executing normally. If a NOT NULL constraint violation occurs, the REPLACE conflict resolution replaces the NULL value with the default value for that column, or if the column has no default value, then the ABORT algorithm is used. If a CHECK constraint violation occurs, the REPLACE conflict resolution algorithm always works like ABORT.


When the REPLACE conflict resolution strategy deletes rows in order to satisfy a constraint, delete triggers fire if and only if recursive triggers are enabled.


The update hook is not invoked for rows that are deleted by the REPLACE conflict resolution strategy. Nor does REPLACE increment the change counter. The exceptional behaviors defined in this paragraph might change in a future release.