Database design for audit logging

前端 未结 5 1551
孤独总比滥情好
孤独总比滥情好 2020-11-30 16:08

Every time I need to design a new database I spend quite some time thinking on how I should set up the database schema to keep an audit log of the changes.

Some ques

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 16:50

    I don't know of any reference, but I'm sure someone has written something.

    However, if the purpose is simply to have a record of what happened—the most typical use of an audit log—then why not simply keep everything:

    timestamp
    username
    ip_address
    procedureName (if called from a stored procedure)
    database
    table
    field
    accesstype (insert, delete, modify)
    oldvalue
    newvalue
    

    Presumably this is maintained by a trigger.

提交回复
热议问题