Massive insert: problems with indexes (Version 10.2)
Hi, friends. I am a rookie in Oracle, so I ask us because I have a problem that I can't solve it,
(in fact it's a inherited problem)
I want to insert about 4.000.000 records in a table with around 10.000.000 records.
This table have many foreign keys, a primary key (on an index) and three indexes.
I try to insert the records with a cursor as this:
OPEN c_cursor;
FETCH c_cursor INTO c_record;
WHILE c_cursor%found LOOP
INSERT INTO table
(id,
...
VALUES (
...
);
FETCH c_cursorINTO INTO c_record;
END LOOP;
commit;
CLOSE c_cursor;
The operation takes very long time. So I want to disable/drop indexes at first of cursor and at the end,
unable-rebuild/create.
- But when I try disable the indexes with UNUSUABLES (alter index INDEX UNUSABLE), the database
said me:
ORA-01502: index 'INDEX' or partition of such index is in unusable state
It looks that I can't write while the INDEX (also is primary key) is unusable
- I can't remove the index DROP INDEX 'INDEX':
ORA-02429: cannot drop index used for enforcement of unique/primary key
- I can't disable the primary key:
ORA-02297: cannot disable constraint (INDEX) - dependencies exist
What would you want in this case?.
Thanks for all and regards.
Javi
Note: I can't do it with sqlldr because the insert requires a treatment (I do it with the cursor).
Thanks again.
Edited by: user12249099 on 12-abr-2010 7:04