Solved

Retrieve a dropped constraint

Posted on 2014-07-23
4
230 Views
Last Modified: 2014-10-03
A constraint with a system generated name (SYS_CXXXXXXX) was accidentally dropped. Is there a way to add it back. The script for the constraint is not saved and I am not even sure on what table the constraint was applied so that I could do a comparison with the datamodel

Thanks,
0
Comment
Question by:gs79
[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
4 Comments
 
LVL 35

Accepted Solution

by:
johnsone earned 250 total points
ID: 40216486
The only way I can think of that you might be able to retrieve it is with LogMiner.  You would have to have archive log mode turned on and know the timeframe when the drop occurred so that you could grab the correct archive(s).  It should give you the command to put back the constraint.

The documentation for LogMiner is here:

http://docs.oracle.com/cd/E11882_01/server.112/e22490/logminer.htm#SUTIL019
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 125 total points
ID: 40216539
You might also look at restoring a backup to a different server and see what it was.
0
 
LVL 29

Assisted Solution

by:MikeOM_DBA
MikeOM_DBA earned 125 total points
ID: 40219596
Constraints like "SYS_CXXXXXXX" are check constraints (99% of them "NOT NULL" constraints).
If you have a test or qa instance you could compare the schema's to production.
;)
0
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 40219752
They are not necessarily check constraints.  They can be any kind of unnamed constraint.  As long as you create it without a name, it will get a SYS_C prefix.

Take for example these 2 statements:

CREATE TABLE t 
  ( 
     x NUMBER PRIMARY KEY 
  ); 

CREATE TABLE u 
  ( 
     x NUMBER, 
     y NUMBER PRIMARY KEY, 
     FOREIGN KEY (x) REFERENCES t(x) 
  ); 

Open in new window


That will create 2 primary keys and one referential integrity constraint.  All of them will be prefixed with SYS_C.  At least they all were in the 11gR2 system I just ran those statements on.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Read XML values 8 67
Procedure syntax 5 63
Error in creating a view. 8 50
Reference datasets inside PL/SQL cursor and dumping queried datasets 3 51
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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…

737 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