menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Databases

>

Upsert a r...
source image

Dev

3w

read

274

img
dot

Image Credit: Dev

Upsert a row in a DB that doesn't use primary keys or unique constraints

  • To upsert a row in a DB that doesn't use primary keys or unique constraints, the process can be broken down into two parts.
  • First, update any existing rows with a matching slug using an UPDATE statement.
  • Then, create a new row if no rows with matching slugs exist using an INSERT statement with a WHERE NOT EXISTS clause.
  • This approach allows for updating or inserting a row without the need for stored procedures or application logic.

Read Full Article

like

16 Likes

For uninterrupted reading, download the app