基于物化视图创建分区
物化视图是实际存在的物理表,支持触发器,因此堆表可以使用的方法,物化视图同样适用。有时候对于数据量大的物化视图而言,可以用分区的技术,减少读取数据的范围从而加速查询的速度
1:创建穿件源表插入数据
SQL> create table t3(id number,day_date date);
Table created.
create procedure p6 is
i number;
begin
for i in 1 .. 1000 loop
insert into t3 values(i,trunc(sysdate+i));
end loop;
commit;
SQL> exec p6();
PL/SQL procedure successfully completed.
2:创建物化视图日志
SQL> create MATERIALIZED VIEW log on t3;
create MATERIALIZED VIEW log on t3
*
ERROR at line 1:
ORA-12014: table 'T3' does not contain a primary key constraint
SQL> alter table t3 add constraint pk_id primary key(id);
Table al