You are on page 1of 3

analyze table temp_jp validate structure cascade; analyze table temp_jp validate structure cascade * ERROR at line 1: ORA-01499:

table/index cross reference failure - see trace file Rebuilding the candidate indexes on the table did not fix the problem. Rebuild index will ONLY create an index from the existing index. The existing index is having missing rowids. To fix the problem, the existing indexes are to be dropped and indexes are to be created. Based on the Oracle support article (ID 1499.1), the existing indexes are droppe d and created. Before dropping the indexes, the index creation ddls were captured. set long 10000 select dbms_metadata.get_ddl('INDEX','TEMP_JP_IDX','') from dual; After dropping and creating the indexes, analyze table .. succeeded. analyze table temp_jp validate structure cascade; Table analyzed. -------------------------------------------------------------------------------While debugging a recent issue with a query returning no rows, due to table/index row count mismatch error, I had created the following script. This script loops through every table and it's indexes and finds the table/index e with row count mismatch. I had tested this script on a 2 TB database. To cutdown the run time, I had used "rownum < 100001. If your database size is small or longer run times are ac ceptable, remove the condition "rownum < 100001". -------------------------------------------------------------------------------connect veeksha/veeksha set serverout on size 1000000 timing on declare /******************************************************************************* Author JP Vijaykumar, Oracle DBA Date Nov 22 2012 Reference: OERR: ORA-1499 table/Index Cross Reference Failure - see trace file [ID 1499.1] ORA-1499. Table/Index row count mismatch [ID 563070.1] CONVENTION: I modified the select queries to query the results with predicate "WHERE ROWNUM < 100001" is to cut the run time on very large databases. Once an object with Table/Index row count mismatch is identified, that table is analyzed. Re-verified for the row counts filtering the null values. *******************************************************************************/

v_cnt number; v_num number; begin execute immediate 'alter session set cursor_sharing=force'; for c1 in (select table_name from user_tables order by 1) loop begin execute immediate 'select /*+ full('||c1.table_name||') */ count(*) from '||c1.t able_name||' where rownum < 100001' into v_cnt; --dbms_output.put_line(c1.table_name||' '||v_num); for c2 in (select table_name,index_name,column_name from user_ind_columns where table_name = c1.table_name and column_position = 1 order by in dex_name) loop begin execute immediate 'select /*+ index('||c1.table_name||' '||c2.index_name||') */ count('||c2.column_name||') from '|| c1.table_name||' where rownum < 100001' into v_num; if ( v_cnt <> v_num) then --dbms_output.put_line('--'||c1.table_name||' '||c2.index_name||' '||c2.column_n ame||' '||v_cnt||' '||v_num); execute immediate 'select /*+ full('||c1.table_name||')*/ count(1) from '||c1.ta ble_name||' where '||c2.column_name||' is not null' into v_cnt; execute immediate 'select /*+ index('||c1.table_name||' '||c2.index_name||')*/ c ount('||c2.column_name||') from '||c1.table_name|| ' where '||c2.column_name||' is not null' into v_num; --dbms_output.put_line('--'||c1.table_name||' '||c2.index_name||' '||c2.column_n ame||' '||v_cnt||' '||v_num); --dbms_output.put_line('analyze table '||c1.table_name||' validate structure cas cade;'); if ( v_cnt <> v_num) then execute immediate 'analyze table '||c1.table_name||' validate structure cascade' ; execute immediate 'select /*+ full('||c1.table_name||')*/ count(1) from '||c1.ta ble_name||' where '||c2.column_name||' is not null' into v_cnt; execute immediate 'select /*+ index('||c1.table_name||' '||c2.index_name||')*/ c ount('||c2.column_name||') from '||c1.table_name|| ' where '||c2.column_name||' is not null' into v_num; dbms_output.put_line('--'||c1.table_name||' '||c2.index_name||' '||c2.column_nam e||' '||v_cnt||' '||v_num); end if; end if; exception when others then dbms_output.put_line(c1.table_name||' '||c2.index_name||' '||c2.column_name||' ' ||sqlerrm); end; end loop; exception when others then dbms_output.put_line(c1.table_name||' '||sqlerrm); end; end loop; end; / REFERENCES: ORA-1499. Table/Index row count mismatch [ID 563070.1]

http://jonathanlewis.wordpress.com/2007/09/16/index-rebuild/ --ORA-01410:Invalid rowid

You might also like