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

前端 未结 6 2135
臣服心动
臣服心动 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:57

    Tables I've modelled always include:

    • CREATED_USER, VARCHAR2
    • CREATED_DATE, DATE
    • UPDATED_USER, VARCHAR2
    • UPDATED_DATE, DATE

    ...columns. Why implement a trigger when you can set the value at the same time as the INSERT/UPDATE?

    INSERT INTO TABLE (...CREATED_DATE, UPDATED_DATE) VALUES (...,SYSDATE, SYSDATE);
    
    UPDATE TABLE
       SET ...,
           UPDATED_DATE = SYSDATE
    

提交回复
热议问题