Database Timelines
Contents
Database Timelines
What are Database Timelines?
Database timelines provide row versioning for Recital database applications. Whenever a change is made to a table that is timeline enabled then delta changes are automatically recorded for each transaction. Changes made to any tables that are timeline enabled can be undone much like you would undo changes to program code that you edit in a text editor.
Using Database Timelines
To enable database timelines all you need to do is issue the SET TIMELINE ON command in your Recital configuration file.
SET TIMELINE ON
Viewing a timeline
There are 2 ways to view a timeline.
- The LIST TIMELINE command
- The SELECT * FROM SYSTIMELINE command
LIST TIMELINE [RANGE begin [,end]] [FOR condition] [TO FILE filename]
To view a timeline for a particular table e.g.
LIST TIMELINE FOR table = "customers"
To view a timeline since a certain date use the RANGE keyword. Notice that the date range is encoded as a string in the format "YYYYMMDDHH:MM:SS:" e.g.
// list the timeline since 1st october 2009 LIST TIMELINE RANGE "20091001" // list the timeline between the 1st and 7th of october 2009 LIST TIMELINE RANGE "20091001","20091007"
SQL SELECT can be used with the Recital Data Object functions (rdo_xxx() functions) to traverse the timeline and generate html if required e.g.
results = rdo_query("SELECT * FROM systimeline WHERE between(timestamp, '20091001', '20091007')") foreach results as row echo "Table " + row["TABLE"] + " changed by " + row["USER"] + " on " + ROW["TIMESTAMP"] echo ", command was " + row["COMMAND"] + "<br>" endfor
Undoing database changes
You can undo database changes with the ROLLBACK TIMELINE command. The RANGE and FOR clauses can also be specified in the same way as the LIST TIMELINE command e.g.
ROLLBACK TIMELINE [RANGE begin [, end]] [FOR condition]
Clearing a timeline
The CLEAR TIMELINE command will reset a timeline.
CLEAR TIMELINE