WEB开发网
开发学院数据库DB2 DB2 基础: 物化查询表简介 阅读

DB2 基础: 物化查询表简介

 2009-11-20 00:00:00 来源:WEB开发网   
核心提示: 清单 4. 使用有关联总结表的 staging 表connecttosample...createtableemp_summaryas(selectworkdept,job,count(*)ascountfromemployeegroupbyworkdept,job)datainitiallyd


清单 4. 使用有关联总结表的 staging 表
connect to sample 
... 
 
create table emp_summary as (select workdept, job, count(*) as count 
 from employee group by workdept, job) 
 data initially deferred refresh deferred 
 
create table emp_summary_s for emp_summary propagate immediate 
 
set integrity for emp_summary materialized query immediate unchecked 
 
set integrity for emp_summary_s staging immediate unchecked 
 
select * from emp_summary 
 
WORKDEPT JOB   COUNT 
-------- -------- ----------- 
 
 0 record(s) selected. 
 
refresh table emp_summary 
SQL1594W Integrity of non-incremental data remains unverified by the 
database manager. SQLSTATE=01636 
 
select * from emp_summary 
 
WORKDEPT JOB   COUNT 
-------- -------- ----------- 
 
 0 record(s) selected. 
 
insert into employee 
 values ('006900', 'RUSS', 'L', 'DYERS', 'D44', '1234', '1960-05-05', 
 'FIELDREP', 5, 'M', '1940-04-02', 10000, 100, 1000) 
 
select * from emp_summary_s 
 
WORKDEPT JOB   COUNT    GLOBALTRANSID     GLOBALTRANSTIME 
-------- -------- ----------- -------------------... -----------------------------... 
D44   FIELDREP      1 x'00000000000000CD'  x'20050822201344536158000000' 
 
 1 record(s) selected. 
 
select * from emp_summary 
 
WORKDEPT JOB   COUNT 
-------- -------- ----------- 
 
 0 record(s) selected. 
 
refresh table emp_summary 
SQL1594W Integrity of non-incremental data remains unverified by the database 
manager. SQLSTATE=01636 
 
select * from emp_summary 
 
WORKDEPT JOB   COUNT 
-------- -------- ----------- 
D44   FIELDREP      1 
 
 1 record(s) selected. 
 
connect reset 

上一页  1 2 3 4 5 6 7  下一页

Tags:DB 基础 物化

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接