Solved

Oracle : How to identify columns involved in a Table for Unique Constraint Exception ?

Posted on 2015-01-13
5
457 Views
Last Modified: 2015-01-13
Oracle : How to identify columns involved in a Table for Unique Constraint Exception ?

While trying to Insert, I am getting Exception as

ORA-00001: unique constraint (Table) violated.

Without dropping the Unique Constraint, Is it possible to Insert ?

Is there any way to Turn ON or OFF the Constraint.
0
Comment
Question by:chokka
  • 2
  • 2
5 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40547340
>>Oracle : How to identify columns involved in a Table for Unique Constraint Exception ?

Look in user_cons_columns for the CONSTRAINT_NAME.

select * from user_cons_columns where constraint_name='SOME_NAME';

where SOME_NAME is the constraint name in question.

>>Without dropping the Unique Constraint, Is it possible to Insert ?

Not without resolving the violation.  Constraints can be deferrable in that they are not checked until COMMIT.

>>Is there any way to Turn ON or OFF the Constraint.

You can 'disable' it but see above:  You would need to resolve the conflict before it was enabled again.  AND once disabled, all sorts of other 'bad' data can sneak in!
0
 
LVL 34

Accepted Solution

by:
johnsone earned 250 total points
ID: 40547469
You actually can add a record to the table that violates the constraint.

I HIGHLY RECOMMEND THAT YOU DO NOT DO IT  But, it is possible.

Disable the constraint.  Add the invalid record, then re-enable the constraint with ENABLE NOVALIDATE.  This will put the constraint back for new rows, but not check old rows.

The bad...

Other bad data can get in withthe constraint is disabled.
If any row that violates the constraint is updated, you will get the ORA-00001 back.
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 40547479
>>I HIGHLY RECOMMEND THAT YOU DO NOT DO IT  

I would recommend that you FORGET this was even posted.

>>The bad...

In addition:
The constraint was put there for a reason.  Having data in a table that violates the constraint can have catastrophic implications for applications that rely on the constraint being there and VALID.
0
 

Author Comment

by:chokka
ID: 40547495
slightwv and Johnsonone , Thank you for your suggestion.

I will not disable or remove the constraint.


Thank you. This post is closed. Please dont comment further.

I have some issue with my browser and so, i am not able to Accept Solution option. I will do it later.
0
 

Author Closing Comment

by:chokka
ID: 40548171
Thank you !!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Latency in .net app using DB in .net 21 60
Set Warning Thresholds on Database mirroring 4 48
SQL query question 8 73
how to trim oracle sql sentence in unix 17 51
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This article describes some very basic things about SQL Server filegroups.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now