Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to know the last commit value in a table?

Tags:

postgresql

I am using Postgres 9.5. If I update certain values of a row and commit, is there any way to fetch the old value afterwards? I am thinking is there something like a flashback? But this would be a selective flashback. I don't want to rollback the entire database. I just need to revert one row.

like image 358
codec Avatar asked Nov 09 '22 06:11

codec


1 Answers

Short answer - it is not possible.

But for future readers, you can create an array field with historical data that will look something like this:

     Column     |           Type           | 
----------------+--------------------------+------
 value          | integer                  | 
 value_history  | integer[]                |

For more info read the docs about arrays

like image 114
Or Duan Avatar answered Nov 15 '22 08:11

Or Duan