Withdata Software

Replace Update or Insert a row Into Sqlite Table

In Mysql, if you want to either updates or inserts a row in a table, depending if the table already has a row that matches the data, you can use “ON DUPLICATE KEY UPDATE”.

How to do it in Sqlite?

Use “INSERT OR REPLACE INTO” .

For example:

INSERT OR REPLACE INTO Employee (id, name, role) 
VALUES (1, 'John Foo', 'CEO');

You can see this page for more information: http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace

See also:

Upsert data from CSV to SQLite
Upsert data from TSV to SQLite
Upsert data from TXT to SQLite
Upsert data from Excel to SQLite
Upsert data from XML to SQLite
Upsert data from JSON to SQLite
Upsert data from SQL file to SQLite

Replace (Update/Insert) a row into other DB:

In SQL Server, http://www.withdata.com/ad/sql-server/replace-update-or-insert-a-row-into-sql-server-table.html

In Oracle, http://www.withdata.com/ad/oracle/replace-update-or-insert-a-row-into-oracle-table-merge-into.html

In DB2, http://www.withdata.com/ad/db2/replace-update-or-insert-a-row-into-db2-table-merge-into.html

In PostgreSQL, http://www.withdata.com/ad/postgresql/replace-update-or-insert-a-row-into-postgresql-table.html