Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-01-13
5
Medium Priority
?
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 77

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 35

Accepted Solution

by:
johnsone earned 1000 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 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 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