Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:29:31+00:00 2026-06-10T02:29:31+00:00

I’m currently having issue going through a test backup and restore of database table

  • 0

I’m currently having issue going through a test backup and restore of database table on my development machine for db2. Was never entirely successful. Although I was able to restore all data after a drop and re-create of the table, I wasn’t able to reset the foreign key constraint as I got SQL error complaining that keys don’t match. Here’s my exact steps, I’m sure not entirely the right way to do it, but it does eventually restore the 5423 rows of data:

The process

  1. export to /export/home/dale/comments.ixf of ixf messages /export/home/dale/msg.txt select * from .comments

    Note: step 1 exports 5423 rows of data to a location

  2. drop table .comments

  3. import from /export/home/dale/comments.ixf of ixf create into .comments

    Note: step 3 here creates the table but does not insert any data rows

  4. load client from /export/home/dale/comments.ixf of ixf modified by identityoverride replace into .comments

    Note: up until this step, I’m able to insert the 5423 rows of data in the recreated db table

  5. alter table .comments add FOREIGN KEY (comments_id) REFERENCES .news (article_key)

    Note: here alter table fails as db2 complaints that some comments_id does not match article_key

Could anyone help with my problem here? Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:29:32+00:00Added an answer on June 10, 2026 at 2:29 am

    The error means that some of the rows you IMPORT into the Comments table refer to rows that do not exist in the News table.

    You might not be forming the constraint correctly. The column name “comment_id” sounds like the primary key to the Comments table. You want the foreign key, which matches the primary key of the News table. It might also be called “article_key” or “article_id”.

        ALTER TABLE Comments
          ADD FOREIGN KEY( article_key)
            REFERENCES News( article_key);
    

    If “comment_id” is really not the primary key of the “Comments” table, then the problem comes from not backing up and restoring both the News and Comments table at the same time.

    You can either EXPORT and IMPORT the News table along with the Comments table, or remove the Comments that refer to missing News rows with something like this

        DELETE FROM Comments
          WHERE comments_id NOT IN (
            SELECT article_key
              FROM News
          )
    

    Before you do this, you might want to try listing the Comments which would be deleted by the above query

        SELECT * 
          FROM Comments
          WHERE comments_id NOT IN (
            SELECT article_key
              FROM News
          )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a reasonable size flat file database of text documents mostly saved in
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.