有人知道为什么Oracle(使用12c)在编辑策略在分区表上然后 alter table ... truncate partion .. update global indexes 运行时会抛出错误? 事实上,更新全局索引正在抛出异常。
我可以通过添加异常处理程序并运行一个删除语句来轻松解决这个问题。它只是慢得多。
测试用例:
drop table test;
create table test (
f1 number,
f2 number,
constraint pk_test primary key (f1)
)
partition by list (f1) (
partition dim_0 values (0),
partition dim_1 values (1),
partition dim_2 values (2),
partition dim_3 values (3),
partition dim_4 values (4),
partition dim_5 values (5)
);
insert into test (f1, f2)
with r(f1, f2) as (
select 1, 2 from dual
union all
select f1+1, f2+2 from r
where f1<5
)
select f1, f2
from r;
-- select the data, without redaction
select *
from test;
-- add a redaction policy to the table
begin
dbms_redact.add_policy(
object_schema => 'HPF',
object_name => 'test',
column_name => 'f1',
policy_name => 'hide_f1',
function_type => dbms_redact.full,
function_parameters => dbms_redact.redact_us_ssn_f5,
expression => '1=1'
);
end;
/
-- select the data, with redaction
select *
from test;
-- trunacte test
alter table test truncate partition dim_5 update global indexes;
-- drop test
alter table test drop partition dim_5 update global indexes;
--============> OUTPUT:
table TEST created.
5 rows inserted.
F1 F2
---------------------- ----------------------
1 2
2 4
3 6
4 8
5 10
anonymous block completed
F1 F2
---------------------- ----------------------
0 2
0 4
0 6
0 8
0 10
Error starting at line 51 in command:
alter table test truncate partition dim_5 update global indexes
Error report:
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-28081: Insufficient privileges - the command references a redacted object.
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.
Error starting at line 53 in command:
alter table test drop partition dim_5 update global indexes
Error report:
SQL Error: ORA-00604: error occurred at recursive SQL level 1
ORA-28081: Insufficient privileges - the command references a redacted object.
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
can be corrected, do so; otherwise contact Oracle Support.