Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Posts
    88

    Unanswered: Foreign key relationship

    Hi All,

    I have a very basic doubt. I have two tables with data and want to put foreign key from tab1 to tab2.but as the data exists in the both the tables it is not allowing me to put foreign key constraint saying that the table has values which is not there in the parent table.

    Is there something in alter table command which can say it to delete the data from the child table which is not in the parent table . or either I have to do it manually .

    Thanks in advance

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You will have to do it manually.

    Andy

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Another option would be to export and truncate the child table, then create the RI constraint, then LOAD the data into the child table again. LOAD can put all RI violators in exception tables. (But I would only go through this trouble if you still need those RI violators and if the child table is rather big.)
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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