OERR: ORA-1499 table/Index Cross Reference Failure - see trace file (文档 ID 1499.1)
Error: ORA 1499 Text: table/Index Cross Reference Failure - see trace file ------------------------------------------------------------------------------- Cause: An error occurred when validating an index or a table using the ANALYZE command. One or more entries does not point to the appropriate cross-reference. Action: Check the trace file for more descriptive messages about the problem. Correct these errors.
"row not found in index" "Table/Index row count mismatch" "row mismatch in index dba" "Table row count/Bitmap index bit count mismatch" "kdavls: kdcchk returns %d when checking cluster dba 0x%08lx objn %d\n"
tsn: Tablespace Number表示的是索引存储的表空间编号。
rdba: 是索引段头相对于数据块的存储地址。
SQL> analyze table DEPT validate structure cascade; analyze table case7 validate structure cascade * ERROR at line 1: ORA-01499: table/index cross reference failure - see trace file
FROM DBA_SEGMENTS WHERE header_file = (SELECT file# FROM v$datafile WHERE rfile# = dbms_utility.data_block_address_file(to_number('&rdba','XXXXXXXX')) AND ts#= &tsn) AND header_block = dbms_utility.data_block_address_block(to_number('&rdba','XXXXXXXX'));
&rdba值应该是删除’0x‘的十六进制的rdba,tsn是表空间编号。
例如:
SELECT owner, segment_name, segment_type, partition_name FROM DBA_SEGMENTS WHERE header_file = (SELECT file# FROM v$datafile WHERE rfile# = dbms_utility.data_block_address_file(to_number('02c00061','XXXXXXXX')) AND ts#= 5) AND header_block = dbms_utility.data_block_address_block(to_number('02c00061','XXXXXXXX'));
明确受影响的键值:
如果需要明确所有受影响的键,需要运行一次全表扫描和索引扫描:
在表中但未在索引的行:
SELECT /*+ FULL(t1) */ rowid, FROM
t1 MINUS SELECT /*+ index(t ) */ rowid, FROM
t;
在索引中但未在表中的行:
SELECT /*+ index(t ) */ rowid,
FROM
t MINUS SELECT /*+ FULL(t1) */ rowid, FROM
t1;
实例:
表名 = DEPT,索引名 = I_DEPT1,在索引I_DEPT1中的索引列:DEPTNO,DNAME. SELECT /*+ FULL(t1) */ rowid, deptno, dname FROM dept t1 MINUS SELECT /*+ index(t I_DEPT1) */ rowid, deptno, dname FROM dept t;
确保查询语句的执行计划使用受影响的索引,例如I_DEPT1会展示在执行计划中。查询未使用索引的原因之一是因为索引列定义为允许NULL值。如果是这样,可以添加一个where子句,例如:where deptno is not null。