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 6791837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:53:41+00:00 2026-05-26T17:53:41+00:00

I have 2 databases that I would like to combine. They both have the

  • 0

I have 2 databases that I would like to combine. They both have the same schema.
The second database started with the same data as the first, but they diverged on a specific date.

The problem is that the ids for some of the tables continued to auto-increment from the same point so that both tables use the same ids for different data. I should also mention that the ids are used as foreign keys in other tables.

I was thinking that I could just add a value to every id in the second database to remove the conflicts. Is this an acceptable way to do this. If so, what is the best way to do that. If not, what would be a better way.

  • 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-05-26T17:53:41+00:00Added an answer on May 26, 2026 at 5:53 pm

    You can add an offset to all the tables’ primary and foreign key values, taking care that

    1. the database is offline and not accepting changes
    2. you do not miss any primary or foreign key fields
    3. you obviously add the same offset everywhere.

    Example updates statements:

    UPDATE parent_tbl SET primary_key_col = primary_key_col + 5000;
    UPDATE child_tbl SET foreign_key_col = foreign_key_col + 5000;
    ...
    ...
    UPDATE parent_tbl_99 SET primary_key_col = primary_key_col + 5000;
    UPDATE child_tbl SET_99 foreign_key_col = foreign_key_col + 5000;
    

    This is an instance where creating your foreign keys with the ON UPDATE CASCADE option would have been very helpful. You would only have had to modify the primary key columns, and changes would propagate to tables referencing them as foreign keys.

    FOREIGN KEY (localcol) REFERENCES parent_tbl (parent_col) ON UPDATE CASCADE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database that I would like class files generated from, and also
I have a database that I would like to leverage with Zend_Search_Lucene . However,
I have a SQL2005 Express database that I would like to create a copy
I have a MySQL user added to a database that I would like to
I have a large database and would like to select table names that have
I have access to an Oracle server that has some databases that I would
I have a database that is on a SQL 2000 server, and I would
I have a few .Net projects that would benefit from using a document/object database
I have a one-to-one relationship in my database, and I'd like to just combine
I have some html content stored in a database field. I would like trusted

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.