ORA-25191: cannot reference overflow table of an index-organized table

 在Oracle DB使用PL/SQL時,其中一段查詢DBA_TABLES的SQL,出現了一個很少見的錯誤:ORA-25191: cannot reference overflow table of an index-organized table

SQL:select * from dba_tables where …,這段SQL沒有什麼特殊的語法,但是就出現了ORA-25191,其發生錯誤的表是這個:SYS_IOT_OVER_403318。

在網路查找問題文章時,發現有人說這是一個Bug:

See [MOSC](http://support.oracle.com/), there is a bug in Oracle 11.2 that makes the automated task that gathers statistics raise the ORA-25191 error on some databases upgraded from 10.2 that contain IOT overflow tables.

If the bug does not apply to you, your query *where* clause should filter out all IOT_OVERFLOW Tables.  You need a WHERE clause to filter out index-organized table mapping segments & overflow segments.

而這個SYS_IOT_OVER_403318的IOT_TYPE的確是IOT_OVERFLOW,所以在SQL加上where  iot_type IS NULL  or   iot_type != 'IOT_OVERFLOW',果然就解決了。


資料來源:[ORA-25191:  Cannot reference overflow table of an index-organized table tips (dba-oracle.com)](https://www.dba-oracle.com/t_ora_25191_cannot_reference_overflow_of_an_iot.htm)