Error ORA-14400: inserted partition key does not map to any

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Responder
cleberz
Rank: Analista Pleno
Rank: Analista Pleno
Mensagens: 107
Registrado em: Ter, 15 Nov 2011 8:42 am

Pessoal, eu criei umas subpartições em uma tabela e depois eu criei uma procedure que trunca essas subpartições.

Selecionar tudo

ALTER TABLE <tabela> TRUNCATE SUBPARTITION;

Logo após eu faço um INSERT nessa tabela, acontece que na hora de fazer o insert ele está me dando o seguinte erro:

Selecionar tudo

Error ORA-14400: inserted partition key does not map to any partition
Para resolver este erro eu dei um REBUILD nos index, mas a procedure ficou extremamente lenta.

Tem alguma forma de deletar a partição sem ter que reconstruir os indices?
Avatar do usuário
stcoutinho
Moderador
Moderador
Mensagens: 850
Registrado em: Qua, 11 Mai 2011 5:15 pm
Localização: são Paulo - SP

Cleberz,

Segundo o manual da ORACLE, que pode ser consultado em http://docs.oracle.com/cd/B10501_01/ser ... .htm#27573, ao se fazer truncate da partição, deve-se tomar alguns cuidados:

Selecionar tudo

Truncating Partitions

Use the ALTER TABLE ... TRUNCATE PARTITION statement to remove all rows from a table partition. Truncating a 
partition is similar to dropping a partition, except that the partition is emptied of its data, but not physically dropped.

You cannot truncate an index partition. However, if there are local indexes defined for the table, the 
ALTER TABLE TRUNCATE PARTITION statement truncates the matching partition in each local index. 
Unless you specify UPDATE GLOBAL INDEXES (cannot be specified for index-organized tables), any 
global indexes, or all partitions of partitioned global indexes, are marked UNUSABLE and must be rebuilt.
Resumindo, você pode executar o comando de ALTER TABLE .. TRUNCATE com a opção UPDATE GLOBAL INDEXES. Isso evitará que você precise fazer o comando de REUILD posterior. Entretanto, imagino que o comando de TRUNCATE demore para ser processado, pois ele estará em tempo real sincronizando os eventuais indices globais que existam.

Abraços,

Sergio Coutinho
cleberz
Rank: Analista Pleno
Rank: Analista Pleno
Mensagens: 107
Registrado em: Ter, 15 Nov 2011 8:42 am

Valeu Sergio, muito obrigado!
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 14 visitantes