User Tools

Site Tools


validtimetemporal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
validtimetemporal [2015/07/22 09:48] – created z0hpvkvalidtimetemporal [2025/03/08 22:24] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ===== Valid Time Temporal ===== ===== Valid Time Temporal =====
 +==== Create Tables ====
 Create a period using existing columns Create a period using existing columns
 <code>CREATE TABLE student_modules ( <code>CREATE TABLE student_modules (
Line 18: Line 19:
   PERIOD FOR student_module_period   PERIOD FOR student_module_period
   );</code>   );</code>
 +
 +==== Viewing Data ====
 +We can now create **AS OF PERIOD FOR** queries.\\
 +The below query finds all students on a currently active course.
 +<code>SELECT * FROM student_modules AS OF PERIOD FOR student_module_period SYSDATE sm;</code>
 +Can also create **VERSIONS PERIOD FOR ... BETWEEN** queries.\\
 +The below query finds all students that were active in the last week.
 +<code>SELECT * FROM student_modules VERSIONS PERIOD FOR 
 +              student_module_period BETWEEN TRUNC(SYSDATE)-7 AND TRUNC(SYSDATE);</code>
 +              
 +==== Using Flashback ====
 +You can also use the DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME procedure
 +<code>BEGIN
 +  DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME ('ASOF','20-JUL-15 12.00.01 PM');
 +END;
 +
 +BEGIN
 +  DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME ('CURRENT');
 +END;
 +
 +BEGIN
 +  DBMS_FLASHBACK_ARCHIVE.ENABLE_AT_VALID_TIME ('ALL');
 +END;</code>
validtimetemporal.1437558496.txt.gz · Last modified: 2025/03/08 22:23 (external edit)