QUESTION 192- ValidTime Temporal

You create a table with the PERIOD FOR clause to enable the use of the Temporal Validity feature of Oracle Database 12c.
Examine the table employees:
create table employees
(empno number, salary number,
deptid number, name varchar2(100),
period for employee_time);
Which three statements are true concerning the use of the ValidTime Temporal feature for the EMPLOYEES table?


A. The valid time columns are not populated by the Oracle Server automatically.
B. A SQL statment may filter on both transaction time and valid temporal time by using the AS OF TIMESTAP and PERIOD FOR clauses.

C. The employee_time_end value for the same row.
D. The valid time columns employee_time_start and employee_time_end are automatically created.
E. The valid time columns are visible by default when the table is described.


Correct Answer: ABD

E:错误。 时间列如果没有在period for 里面指定的话,会自动创建,但是是属于隐藏列。
C:错误。end 必须大于 start,否则会报 ORA-2290 错误。

 

在应用程序开发中,有时会碰到这样一个场景:设置一条记录的生效时间范围,比如某个产品信息,在某个时间段内是有效的,一般设计表时会在表中增加valid_start和valid_end这两个字段来限制,并通过设置这两个字段来实现具体产品的生效范围,如果查看当前生效的记录,则需要通过时间进行过滤。

Oracle 12.1.0.1引入了Temporal Validity(时间有效性),通过这一特性,在不增加列的情况下可以实现时间有效性的的判断,下面将对这一特性进行演示。

 

创建有valid-time维度的表

(1)显式指定两个date-time列

SQL> create table emp(empno number,salary number,deptid number,name varchar2(20),user_time_start date,user_time_end date,period for user_time (user_time_start,user_time_end));

(2)隐式的vaild-time列

SQL> create table emp2(empno number,salary number,deptid number,name varchar2(20), period for user_time);

vaild-time维度使用关键字"period for"指定。
如果使用隐式的valid-time列,不需要指两个日期列,oracle会创建两个隐藏列,并自动加上valid-time维度的前缀名。例如上一个例子中的前缀名是:user_time

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值