Is there an automatic modification time stamp type for Oracle columns?

前端 未结 6 2141
臣服心动
臣服心动 2020-12-15 05:46

Is there a way to create a timestamp column in Oracle that automatically stores a timestamp of when the record has changed ?

6条回答
  •  余生分开走
    2020-12-15 05:59

    For oracle I usually use a trigger to update the timestamp field

    CREATE OR REPLACE TRIGGER update_timestamp 
      BEFORE INSERT OR UPDATE ON some_table
      FOR EACH ROW
    BEGIN
      :NEW.TS := systimestamp;
    END;
    

    Oracle does not seem to have a built-in attribute for updating the timestamp field to the current timestamp (unlike other DBs like MySQL).

提交回复
热议问题