When you insert a record without specifying a column, that column is set to its default value. Is it possible to update a column to its default value without specifying the value? I tried SET=DEFAULT (which works in MySQL and Oracle) and SET=NULL (which I hoped would work the same as not specifying the column value) but neither worked.
I don’t know of a way to do this directly.
One possible workaround is to first run the query:
select column_default from information_schema.columns where table_schema = 'db' and table_name = 't' and column_name = 'a'
to find the default value, and then run your UPDATE statement based on that.
1 Like
Thanks, jack, for the workaround. It’d still be nice to have this as a built-in feature in the future.