Implementing PK and FK after creation

  • We have a new database that was created and has had data entered already. When this DB was created it was done so without PK's and FK's (the software designer felt these weren't necessary for some reason). We have now told them that these are essential. There DB guy is designing a script to implement all this and I was wondering what concerns we should have now that he is trying to do this. Any advice or comments are greatly appreciated!

    Marty

  • Can you post the script your DBA is going to implement?

    For FK constraint, there are option 'with check' and 'with nocheck', which are used to verify new CHECK or FOREIGN KEY constraints against existing data or not.

    For PK constraint, You may encounter duplication on existing data and would not be able to create PK constraint unless the duplication is cleared.

  • You could also check that you do not have duplicate rows before creating your PK with a count and a group by clause for example.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply