Oracle 无法在PL/SQL过程中禁用索引
我已经编写了一个PL/SQL过程,如果首先禁用索引,然后在完成后重新构建索引,那么该过程将受益匪浅。一位专家建议采用这种方法:Oracle 无法在PL/SQL过程中禁用索引,oracle,plsql,Oracle,Plsql,我已经编写了一个PL/SQL过程,如果首先禁用索引,然后在完成后重新构建索引,那么该过程将受益匪浅。一位专家建议采用这种方法: alter session set skip_unusable_indexes = true; alter index your_index unusable; [不进口] alter index your_index rebuild; 但是,我在第一条alterindex语句中遇到以下错误: SQL Error: ORA-14048: a partition m
alter session set skip_unusable_indexes = true;
alter index your_index unusable;
[不进口]
alter index your_index rebuild;
但是,我在第一条alterindex
语句中遇到以下错误:
SQL Error: ORA-14048: a partition maintenance operation may not be combined with other operations
ORA-06512: [...]
14048. 00000 - "a partition maintenance operation may not be combined with other operations"
*Cause: ALTER TABLE or ALTER INDEX statement attempted to combine
a partition maintenance operation (e.g. MOVE PARTITION) with some
other operation (e.g. ADD PARTITION or PCTFREE which is illegal
*Action: Ensure that a partition maintenance operation is the sole
operation specified in ALTER TABLE or ALTER INDEX statement;
operations other than those dealing with partitions,
default attributes of partitioned tables/indices or
specifying that a table be renamed (ALTER TABLE RENAME) may be
combined at will
问题索引的定义如下:
CREATE INDEX A11_IX1 ON STREETS ("SHAPE")
INDEXTYPE IS "SDE"."ST_SPATIAL_INDEX" PARAMETERS
('ST_GRIDS=890,8010,72090 ST_SRID=2');
这是第三方供应商提供的自定义索引类型,在大容量更新/插入/删除操作期间会导致性能长期下降
有没有关于如何解决这个错误的建议?顺便说一下,这个错误只发生在PL/SQL块中
编辑:以下是整个过程:
procedure disable_indexes (
tbl_name in varchar2
) as
stmt varchar2(200);
cursor curs(v_tbl_name in varchar2) is
select 'alter index ' || index_name || ' unusable;' as ddl_stmt
from user_indexes
where upper(table_owner) = upper(user)
and upper(table_name) = upper(v_tbl_name)
and ityp_name in ('CTXCAT', 'ST_SPATIAL_INDEX');
begin
for r_curs in curs(tbl_name) loop
dbms_output.put_line(r_curs.ddl_stmt);
execute immediate r_curs.ddl_stmt;
end loop;
end;
您是否尝试过在之前执行删除索引,然后在之后重新创建它?如果这确实是您的代码,而不是伪代码重写,请删除
代码>在stmt
变量中的语句末尾(否则在执行过程中会遇到ORA-00911:无效字符
)
现在,如果您的流程是手动工作的,那么您应该能够在过程中使用executeimmediate
。在手动执行命令之前,通过发出SET role NONE
确保这不是角色问题(请参见此)。从主题中,我猜您试图禁用PL/SQL过程中的索引,该过程是DDL,只能通过execute immediate'…'
实现。但是,由于您没有提到类似的内容,我想您应该在PL/SQL过程之外执行DDL。这是对的吗?这正是我想要避免的。接得好。您是否相信删除代码>解决了问题?我无法理解Oracle为什么给我关于ORA-14048
错误的消息。不幸的是,几乎所有与Oracle合作过的人都会认为收到的错误消息与实际问题无关。