Oracle manually add an FK constraint

Posted by Oxymoron on Stack Overflow See other posts from Stack Overflow or by Oxymoron
Published on 2010-05-06T07:34:19Z Indexed on 2010/05/06 7:38 UTC
Read the original article Hit count: 255

Filed under:
|
|
|
|

Alright, since a client wants to automate a certain process, which includes creating a new key structure in a LIVE database, I need to create relations between tables.columns. Now I've found the tables ALL_CONS_COLS en USER_CONSTRAINTS to hold information about constraints. If I were to manually create constraints, by inserting into these tables, I should be able to recreate the original constraints. My question: are there any more tables I should look into? Do you have an alternate suggestions, as this sounds VERY dirty and error prone to begin with.

Current modus operandi:

  • Create a new column in each table for the PK;

  • Generate a guid for this PK;

  • Create a new column in each table for the FKs;

  • Fetch the guid associated with the
    FK;

....... done sofar......

  • Add new constraint based on the old
    one;

  • Remove old constraint;

  • Rename new columns;

This is kind of dodgy and I'd rather change my method, any ideas would be helpful.

To put it different, client wants to change key structure from int to guid on a live database. What's the best way to approach this

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about Constraint