Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
Some maintenance operations leave indexes in UNUSABLE state without any error at the time. The error appears later, when a DML or query needs that index. Find them with SELECT index_name, status FROM user_indexes WHERE table_name = '…'.
In every case below, ALTER INDEX … REBUILD sets the status back to VALID and the failed statement works.
01ALTER TABLE MOVE (table reorganization) left the index UNUSABLE
ALTER TABLE emp MOVE rewrites the table and leaves its index UNUSABLE without any message. The next INSERT fails because the unique index EMP_UK must be maintained.
Setup
CREATE TABLE emp (empno NUMBER, ename VARCHAR2(20));
CREATE UNIQUE INDEX emp_uk ON emp (empno);
INSERT INTO emp VALUES (1, 'KIM');
COMMIT;
ALTER TABLE emp MOVE;Table created.
Index created.
1 row created.
Commit complete.
Table altered.INSERT INTO emp VALUES (2, 'LEE');INSERT INTO emp VALUES (2, 'LEE')
*
ERROR at line 1:
ORA-01502: index 'LAB_A.EMP_UK' or partition of such index is in unusable state
Help: https://docs.oracle.com/error-help/db/ora-01502/SELECT index_name, status FROM user_indexes WHERE table_name = 'EMP';INDEX_NAME STATUS
------------------------------ ------------------------------
EMP_UK UNUSABLE
1 row selected.SELECT * FROM emp; EMPNO ENAME
---------- --------------------
1 KIM
1 row selected.ALTER INDEX emp_uk REBUILD;Index altered.USER_INDEXES shows EMP_UK as UNUSABLE, while a plain SELECT * FROM emp still works. After ALTER INDEX emp_uk REBUILD the INSERT succeeds and the status is VALID.
INSERT INTO emp VALUES (2, 'LEE');
COMMIT;
SELECT index_name, status FROM user_indexes WHERE table_name = 'EMP';1 row created.
Commit complete.
INDEX_NAME STATUS
------------------------------ ------------------------------
EMP_UK VALID
1 row selected.02Index set UNUSABLE for a bulk load and not rebuilt
Indexes are often made UNUSABLE to speed up a large load. If the rebuild step is forgotten, a query that uses the index (here forced with an INDEX hint) fails.
Setup
CREATE TABLE sales (id NUMBER, amount NUMBER);
CREATE INDEX sales_ix ON sales (id);
INSERT INTO sales VALUES (1, 100);
COMMIT;
ALTER INDEX sales_ix UNUSABLE;Table created.
Index created.
1 row created.
Commit complete.
Index altered.SELECT /*+ INDEX(sales sales_ix) */ * FROM sales WHERE id = 1;SELECT /*+ INDEX(sales sales_ix) */ * FROM sales WHERE id = 1
*
ERROR at line 1:
ORA-01502: index 'LAB_A.SALES_IX' or partition of such index is in unusable state
Help: https://docs.oracle.com/error-help/db/ora-01502/ALTER INDEX sales_ix REBUILD;Index altered.Run ALTER INDEX sales_ix REBUILD at the end of the load. The same query then returns the row.
SELECT /*+ INDEX(sales sales_ix) */ * FROM sales WHERE id = 1; ID AMOUNT
---------- ----------
1 100
1 row selected.03TRUNCATE PARTITION made a global index UNUSABLE
sales_p_uk is a global unique index on a partitioned table. ALTER TABLE … TRUNCATE PARTITION p2025 without index maintenance marks it UNUSABLE, so an INSERT into a different partition fails too.
Setup
CREATE TABLE sales_p (id NUMBER, sale_date DATE)
PARTITION BY RANGE (sale_date) (
PARTITION p2025 VALUES LESS THAN (DATE '2026-01-01'),
PARTITION p2026 VALUES LESS THAN (DATE '2027-01-01')
);
CREATE UNIQUE INDEX sales_p_uk ON sales_p (id);
INSERT INTO sales_p VALUES (1, DATE '2025-06-01');
INSERT INTO sales_p VALUES (2, DATE '2026-06-01');
COMMIT;
ALTER TABLE sales_p TRUNCATE PARTITION p2025;Table created.
Index created.
1 row created.
1 row created.
Commit complete.
Table truncated.INSERT INTO sales_p VALUES (3, DATE '2026-07-01');INSERT INTO sales_p VALUES (3, DATE '2026-07-01')
*
ERROR at line 1:
ORA-01502: index 'LAB_A.SALES_P_UK' or partition of such index is in unusable state
Help: https://docs.oracle.com/error-help/db/ora-01502/ALTER INDEX sales_p_uk REBUILD;Index altered.ALTER INDEX sales_p_uk REBUILD makes it VALID again and the INSERT works.
INSERT INTO sales_p VALUES (3, DATE '2026-07-01');
COMMIT;
SELECT index_name, status FROM user_indexes WHERE index_name = 'SALES_P_UK';1 row created.
Commit complete.
INDEX_NAME STATUS
------------------------------ ------------------------------
SALES_P_UK VALID
1 row selected.FAQ
How do I fix ORA-01502?
Find the UNUSABLE index in USER_INDEXES (or USER_IND_PARTITIONS for a partitioned index) and run ALTER INDEX <name> REBUILD.
How do I find unusable indexes in Oracle?
SELECT index_name, status FROM user_indexes WHERE status = 'UNUSABLE';
Does ALTER TABLE MOVE make indexes unusable?
Yes, without any warning. Check USER_INDEXES after the move and rebuild the indexes.
Why does INSERT fail but SELECT works?
In the test, SELECT * FROM emp worked while the index was UNUSABLE, but the INSERT had to maintain the unique index and failed until it was rebuilt.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0