# Upsert in SQL: What is an upsert, and when should you use one?

DevFeed: [Upsert in SQL: What is an upsert, and when should you use one?](<https://devfeed.tech/articles/upsert-in-sql-what-is-an-upsert-and-when-should-you-use-one-23817.md>)

Original publisher: [Read original article](<https://cockroachlabs.com/blog/sql-upsert>)

Author: Charlie Custer

Published: 2023-05-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [Cockroach Labs](<https://devfeed.tech/sources/cockroach-labs.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [CockroachDB](<https://devfeed.tech/topics/cockroachdb.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>)

Tags: [cockroachdb](<https://devfeed.tech/tags/cockroachdb.md>), [database](<https://devfeed.tech/tags/database.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [rdbms](<https://devfeed.tech/tags/rdbms.md>), [relational-databases](<https://devfeed.tech/tags/relational-databases.md>), [sql](<https://devfeed.tech/tags/sql.md>), [update](<https://devfeed.tech/tags/update.md>)

## AI overview

This tutorial explains SQL upserts, an operation that updates an existing row when a specified value is present and inserts a new row when it is not. It discusses why the term may be absent from database documentation and introduces implementation approaches for CockroachDB, MySQL, and PostgreSQL.

## Source excerpt

Upserts are useful for anyone who works with a database to know, but the term "upsert" might not even appear in your DBMS's documentation! So what is an upsert, anyway? And why might it not be mentioned in your docs?