1. mysql
http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html
INSERT ... ON DUPLICATE KEY UPDATE
2. postgrep
https://www.postgresql.org/docs/devel/static/sql-insert.html
http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql
PostgreSQL since version 9.5 has UPSERT syntax, with ON CONFLICT clause.