DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Orphan records with foreign key enable and validate

  1. #1
    Join Date
    Nov 2000
    Posts
    164

    Orphan records with foreign key enable and validate

    Dear all,

    I have a table that recently I found it has orphan records with the foreign key is enable and validate. I am not sure how could that happen? I tried to delete and recreate the foreign key, and I was able to do so, I also tried to validate the constraint and was able to do that too. I am not sure if there is anything that would allow the foreign key to be ignored?

    Any help is appreciate.


    Thanks,
    Unna

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    12 years ago I worked on an application that disabled foreign keys in order
    to make a change to a primary key that existed in more than one table.
    I did not create the design. We had a customer that tried changing a primary
    key in some tables and that caused orphaned keys. In the mean time I enabled
    the foreign keys novalidate, and then I worked on fixing the data. I suspect that
    someone enabled a foreign key with novalidate after rows were orphaned.
    But I can only speculate to exactly what happened.

  3. #3
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by Unna View Post
    I have a table that recently I found it has orphan records with the foreign key is enable and validate.
    Quote Originally Posted by Unna View Post
    I tried to delete and recreate the foreign key, and I was able to do so, I also tried to validate the constraint and was able to do that too.
    The two statemets above contradict each other.
    You cannot have orphans and at the same time being able to successfully drop/create the FK with validate option.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by PAVB View Post
    The two statemets above contradict each other.
    You cannot have orphans and at the same time being able to successfully drop/create the FK with validate option.
    I read "I tried to delete and recreate the foreign key" as he fixed the bad keys
    and enabled the foreign keys. Perhaps I read to much into what he said.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width