on 04-24-2012 1:11 PM
First of all, I have read the SAP documentation. It simply says:
"<time_travel_clause> ::= AS OF [COMMIT ID|TIMESTAMP] [commit_id | timestamp]"
So I hoped I could manage that.
select count(*) from usr02
COUNT(*)
5675
select count(*) from usr02 as of timestamp '2012-04-23 12:00:00'
* 257: sql syntax error: incorrect syntax near "timestamp": line 1 col 34 (at pos 34) SQLSTATE: HY000
hdbsql T17=> select count(*) from usr02 as of timestamp to_timestamp('2012-04-23 12:00:00','YYYY-MM-DD HH24:MI:SS')
* 257: sql syntax error: incorrect syntax near "timestamp": line 1 col 34 (at pos 34) SQLSTATE: HY000
So what am I doing wrong? It looks like hdbsql or transaction ST04 don't like the "as of timestamp" clause. Is this feature already supported? Did anyone already manage to execute a time travel query? Any working examples would be highly welcome.
Looks like the syntax is more complicated than what the documentation says. So let's try it another way:
\a off
Auto commit mode switched OFF
hdbsql=> set history session to commit id 1695003
0 rows affected (28.776 msec)
select bname,trdat,ltime from from usr02 order by trdat,ltime
(The output indictes that no time travel has happened but current data is shown.)
The documentation says: "Non-history tables in restored sessions always show their current snapshot"
How can I find out what is a history table and what not?
Regards,
Mark
Hi Mark.
Try to create table as HISTORY first:
CREATE HISTORY COLUMN TABLE <table_name> etc
Regards,
-Vitaliy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vitaliy,
thanks for that hint! I didn't find that in the documentation. Somehow I hate to reverse engineer applications simply because the documentation is somewhat rudimentary, but looks like we have to live with that situation for a while.
My next question would be: How can I see whether a columnar table is a history table?
I elaborated this answer:
In table TABLES we see SESSION_TYPE='HISTORY'
Regards,
Mark
Hi
would I be able to mark a SLT replicated table as history table ..( from your above SQL , it does not seem so )
I have a thread open at http://scn.sap.com/thread/3216473 .. incase you care to answer in a new open thread .
Hi Mark,
While creating a table, you can choose to create it as one of the following types:
(http://help.sap.com/hana/html/sql_create_table.html#create_table_table_type)
So your question "How can I see whether a columnar table is a history table?" goes invalid, since a table can be either columnar, or a history table. You'll be able to run the time travel queries only when the table type is 'history column'.
Hope this helps.
Hi,
I have scribbled the details about time travel concept, with examples about running time travel queries in SAP HANA.
Actually this was the original discussion, where i got the idea about working something and then writing about Time Travel. So, thanks a lot, and do let me know your feedback about the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.