clear timeline
set timeline on open database southwind use orders // check if timelines are enabled for the current or specified cursor/table ? timeline() .T.
https://www.lianja.com/doc/index.php/TIMELINE()
list timeline range dtos(date()-10), dtos(date()) for table = "example"
https://www.lianja.com/doc/index.php/LIST_TIMELINE
display timeline range dtos(date()-10), dtos(date()) for table = "example"
https://www.lianja.com/doc/index.php/DISPLAY_TIMELINE
rollback timeline range dtos(date()-10), dtos(date()) for systimeline.table = "example"
To see how many transactions would be rolled back prefix the rollback timeline command with explain.
explain rollback timeline range dtos(date()-10), dtos(date()) for systimeline.table = "example"
https://www.lianja.com/doc/index.php/ROLLBACK_TIMELINE
set systimeline on set timeline on
https://www.lianja.com/doc/index.php/SET_SYSTIMELINE
set timeline on
https://www.lianja.com/doc/index.php/SET_TIMELINE
SELECT * FROM system!systimeline WHERE between(timestamp, '20171001', '20171007')
https://www.lianja.com/doc/index.php/SYSTIMELINE
Database timelines can be enabled for all the tables in a database:
alter database southwind metadata "timeline=on"
or for individual tables:
open database southwind alter table customers metadata "timeline=on" alter table orders metadata "timeline=on"
and to disable timelines:
alter database southwind metadata "timeline=off"
open database southwind alter table customers metadata "timeline=off" alter table orders metadata "timeline=off"
To view a timeline for a particular table e.g.
list timeline for table = "customers"
To view a timeline for a particular date or date range, use the range or since keywords. Notice that the dates are encoded as a string in the format “YYYYMMDDHH:MM:SS:”. This can be abbreviated e.g.
// list the timeline since 1st October 2017 list timeline since "20171001" // list the timeline for 1st October 2017 only list timeline range "20171001" // list the timeline between the 1st and 31st of October 2017 list timeline range "20171001","20171031" // send the listing to a text file list timeline range "20171001","20171031" to file thismomth.txt
SQL Select
SQL SELECT can be used to query the system systimeline table directly:
select * from system!systimeline
SQL SELECT can also be used with the Lianja Data Object functions (rdo_xxx() functions) to traverse the timeline and generate html to populate a WebView Section if required e.g.
<%@ Language=VFP %> <html> <head> <style> table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%;} td, th { border: 1px solid #dddddd; text-align: left; padding: 8px;} tr:nth-child(even) { background-color: #dddddd;} </style> </head> <body> <% results = rdo_query("SELECT * FROM system!systimeline WHERE between(timestamp, '20171001', '20171031')") ? "<h3>Timeline report</h3>" ? "<table>" ? "<tr><th>Table</th><th>User</th><th>Date</th><th>Command</th></tr>" foreach results as row ? "<tr><td>" + row["TABLE"] + "</td><td>" + row["USER"] + "</td><td>"; + left(row["TIMESTAMP"],8) + " " + right(row["TIMESTAMP"],8)+ "</td><td>" + row["COMMAND"] + "</td></tr>" endfor ? "</table>" results = null %> </body> </html>
Rollback Timeline
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 [, ]] [for ]
To see how many transactions would be rolled back prefix the rollback timeline command with explain.
explain rollback timeline [range [, ]] [for ]
Clearing a timeline
The clear timeline command will reset a timeline.
clear timeline