Search code examples
oracle

How can Time and Date be automatically updated when a data is inserted or updated in oracle?


Every time data is inserted in an oracle table, I want the date and time to be automatically updated in a column named 'CREATION_DATE'.


Solution

  • Setting default value of SYSDATE is more efficient than a trigger. As helpc mentioned, a default value can be overridden if NULL is explicitly provided in the INSERT. If you don't intend to pass date time thru application at all, you can define the column as NOT NULL with a default as sysdate .