history rows management in database

后端 未结 10 1847
灰色年华
灰色年华 2021-02-03 11:48

As in many databases, i am designing a database that should keep record of previous versions of the rows changed in each table.

The standard solution to this problem is

10条回答
  •  长情又很酷
    2021-02-03 12:26

    I would use the IS_LAST=1 partition, and the IS_LAST=0 partition system. Because it is partitioned it will be fast (partition pruning) and you will never have to query a union of the normal table and the history table.

    I would use IS_LAST='Y'/'N' and not 1/0. 1 and 0 are meaningless.

    There is a special trick that can help guarrantee that there is max one row with IS_LAST='Y' per entity: You can create a unique function based index with a function that returns null when IS_LAST='N' and return the id when IS_LAST='Y'. It is explained here: http://www.akadia.com/services/ora_function_based_index_1.html

提交回复
热议问题