Skip to content
Advertisement

Default Value in a column when insert a new row

I have the table Photographies with the columns: Name, Author, Date, Updated date.

I would like to set Update date as default current_date when a new record is inserted or when a record is updated.

How should I proceed with this?

Advertisement

Answer

Welcome to SO. Take a look at triggers.

Basically you only need to create a function to perform the updated ..

.. and attach it to a BEFORE INSERT OR UPDATE trigger like this

After inserting a record ..

.. you have your updated column with the current date

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