1

我有一个特定的查询,一旦该查询创建了一个显示每天的特定总和数量的表,我每天都必须执行该查询,而不是我想在物化查询中执行它,以免每天都创建这里是查询:

create table close_qty
as
select item_code,item_conc_code,tran_bran_code,sum(tran_qty) bal_qty
from tranhist a,itemmast b
where a.tran_item_code = b.item_code
group by item_code,item_conc_code,tran_bran_code

我正在尝试创建物化视图,但出现以下错误

ERROR at line 1:
ORA-00901: invalid CREATE command

这是我的查询

CREATE MATERIALIZED VIEW vwCloseQty
AS
select item_code,item_conc_code,tran_bran_code,sum(tran_qty) bal_qty
from tranhist a,itemmast b
where a.tran_item_code = b.item_code
group by item_code,item_conc_code,tran_bran_code

如果它会影响性能以及如何解决错误,请提出建议

4

1 回答 1

1

也许

CREATE MATERIALIZED VIEW vwCloseQty(item_code,item_conc_code,tran_bran_code, bal_qty)
as
select item_code,item_conc_code,tran_bran_code,sum(tran_qty)
from tranhist a,itemmast b
where a.tran_item_code = b.item_code
group by item_code,item_conc_code,tran_bran_code;

不过,您仍然需要每天刷新它——因此,如果您每天只运行一次查询,那么物化视图将无济于事。

于 2012-09-24T10:06:14.700 回答