Skip to content
Advertisement

Postgres on Conflict Update With Default Column Expression

In case a column has a default value expression

Is it possible for on conflict statement reset the column with the default expression without

  • copy-paste the expression it self
  • using default as a value while composing excluded record it self

I.e. just to refer the default exactly from the update statement. Something like

or even

Advertisement

Answer

Yes, you can use the DEFALT value in an upsert:

Demo: db<>fiddle

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement