What is upsert?

Upsert is a database operation that combines both update and insert operations. If a record already exists in the database, it will be updated with the new values. If the record does not exist, a new record will be inserted. This operation is useful in scenarios where you want to update existing records and insert new ones in a single operation, without having to check for the existence of the record beforehand.

UPSERT is commonly used in database management systems like PostgreSQL, MySQL, and Oracle. It is a powerful feature that can simplify database operations and reduce the amount of code required to handle updates and inserts.