oracle分区注意点,转 oracle 分区表删除的两个注意事项

本文介绍了在Oracle10g中对分区表进行操作时的两个重要注意事项:1) 执行`TRUNCATE`分区后,全局索引可能变得不可用,需要重建或在操作时更新全局索引;2) 对于已建立快速刷新的物化视图,`TRUNCATE`或`DROP`分区可能导致物化视图无法自动更新,需要手动刷新。同时,文章强调了在使用物化视图时考虑PCT特性的重要性,并建议参考Oracle官方文档进行分区表和物化视图的维护。
摘要由CSDN通过智能技术生成

原文:oracle分区表维护的两个注意事项

Oracle 10g分区表维护中的两个注意事项:

1.全局索引

SQL> alter table analyse_content truncate subpartition

DATA0712_DEYANG;

Table truncated

truncate分区后,修改或者插入数据报错:

ORA-01502: index 'phs.pk' or partition of such index is in

unusable state

这个时候只能rebuild index

SQL> alter index phs.pk rebuild;

Index altered

执行以后恢复正常,或者使用如下语句:

SQL> alter table analyse_content truncate subpartition

DATA0712_ZIGONG UPDATE

GLOBAL INDEXES;

Table truncated

这样它会自动恢复索引。

2.物化视图

对于已经建有fast refresh view的分区表来说,truncate和drop分区/表会导致物化视图出错。

SQL> alter table analyse_content drop subpartition

DATA0712_MIANYANG;

Table altered

SQL> alter table analyse_content truncate subpartition

DATA0712_LUZHOU;

Table truncated

再次查询物化视图,这个两个分区的数据仍然存在,说明物化视图不能对这种DDL语句进行更新。

尝试在基础表插入数据,报错:

ORA-32313: REFRESH FAST of " " unsupported after PMOPs

这时候必须手工刷新MV

SQL> exec dbms_mview.refresh('mv_analyse_content','f');

begin dbms_mview.refresh('mv_analyse_content','f');

end;来

ORA-32313: PMOP 之后不支持 "PHS"."MV_ANALYSE_CONTENT" 的 REFRESH

FAST

ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2255

ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2461

ORA-06512: 在 "SYS.DBMS_SNAPSHOT", line 2430

ORA-06512: 在 line 1

看来快速刷新'f'是不行,还是得完全刷新'c'

SQL> exec dbms_mview.refresh('mv_analyse_content','c');

PL/SQL procedure successfully completed

执行完后,MV里面的数据恢复正常,基表不再报错。

实际10g里面,truncate分区后,某些物化视图可以执行fast refresh,具体有很多限制,

要查询doc,反正select * from table这种视图肯定可以'f',不过却没有什么意义。

---2008 04 22 在doc上找到了PCT特性的限制,如下:

At least one of the detail tables referenced by the materialized

view must be

partitioned.

Partitioned tables must use either range, list or composite

partitioning.

The top level partition key must consist of only a single

column.

The materialized view must contain either the partition key

column or a partition

marker or ROWID or join dependent expression of the detail table.

See Oracle

Database PL/SQL Packages and Types Reference for details

regarding the DBMS_

MVIEW.PMARKER function.

If you use a GROUP BY clause, the partition key column or the

partition marker or

ROWID or join dependent expression must be present in the GROUP

BY clause.

If you use an analytic window function or the MODEL clause, the

partition key

column or the partition marker or ROWID or join dependent

expression must be

present in their respective PARTITION BY subclauses.

Data modifications can only occur on the partitioned table. If

PCT refresh is being

done for a table which has join dependent expression in the

materialized view,

then data modifications should not have occurred in any of the

join dependent

tables.

The COMPATIBILITY initialization parameter must be a minimum of

9.0.0.0.0.

PCT is not supported for a materialized view that refers to

views, remote tables, or

outer joins.

PCT-based refresh is not supported for UNION ALL materialized

views.

对于海量数据库,如果不能使用DROP分区,则delete相当慢。

如果使用了,又会导致完全刷新MV,同样慢。

在物化视图的时候要认真考虑PCT特性。

对于分区表 已经相关索引,快照的维护,建议还是参考Oracle的DOC,在admin guide和

dataware house guide里有非常完善描述。虽然没有涉及internal,但完全可以满足应用。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值