Disabling constraints

To speed up input performance, I set a primary key index to unusable( and altered session to skip unusable indexes). When attempting to insert into the table, I received an error message of index 'index_name' or partition of such index is in unusable state. I think this is because there is a primary key constraint using this index that is still enabled. First question is "Is that the problem?" and the second question is "How do I disable the constraint?"
LVL 32
awking00Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tony_HaslerCommented:
As the Oracle documentation states:

ORA-01502 index 'string.string' or partition of such index is in unusable state

Cause: An attempt has been made to access an index or index partition that has been marked unusable by a direct load or by a DDL operation.

Action: DROP the specified index, or REBUILD the specified index, or REBUILD the unusable index partition.

Next time, just disable the primary key constraint.  This will drop the index.  When you enable the constraint again the index will be rebuilt.  For example:

ALTER TABLE xxx DISABLE PRIMARY KEY ;

ALTER TABLE xxx ENABLE PRIMARY KEY USING INDEX TABLESPACE USER_INDEX STORAGE (INITIAL 2M NEXt 2M) ;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Author Commented:
Thanks, Tony.
This works fine, but it should be noted that when the primary key is disabled, the index on which it was built is dropped. Also, syntax for enabling is a little different for partitioned indexes, but I figured it out.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.