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

  • Home
  • SEARCH
  • 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 8391993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:24:09+00:00 2026-06-09T19:24:09+00:00

I want to migrate the data from one table to another, besides the two

  • 0

I want to migrate the data from one table to another, besides the two tables with different table name they also have different schema.

For example, existing table are:

@Entity
public class Address {
     private String uuid;
     private String street;
     private String postcode;
}

@Entity
public class User {
     private String uuid;
     private String name;
     @One2One
     private Address address;
}

After the requirements changed, we refactor the two class to something like this:

@Entity
public class UserChanged {
     private String uuid;
     private String name;
     @Embedded
     @AttributeOverrides(.....)
     private Address address;
}
@Embeddable 
public class AddressChanged {
     private String street;
     private String postcode;
}

Which means, in the new, we have only one table “UserChanged”, we have all the columns contain the user information, like uuid, name, street, and postcode. However for the existing, we have two tables which are “User” and “Address”, in the “User” table, there is a foreign key “address” which reference the table “Address” using the primary key.

Address
------------------
uuid          varchar (primary key)
street        varchar
postcode      varchar


User
------------------
uuid          varchar (primary key)
name          varchar
address_id    varchar (foreign key)


UserChanged
------------------
uuid          varchar (primary key)
name          varchar
street        varchar
postcode      varchar

So what I want to do is migrate all the data information in “User” and “Address” tables to just one table “UserChanged”, i.e. User + Address -> UserChanged.

Anyone can tell me the sql scripts I should write for this migration requirement.

  • 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-09T19:24:11+00:00Added an answer on June 9, 2026 at 7:24 pm
    insert into UserChanged (uuid, name, street, postcode) select a.uuid, u.name, a.street, a.postcode from address a, user u where a.uuid = u.address_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to migrate data from one database to another. As preparation we have
I want to migrate data from one database to another database in Microsoft SQL
I want to migrate the data from one Plone instance to another. I am
The problem is: I have 3 mongo tables, and I want to migrate data
Suppose I have two distinct databases with identical schemas but different data. I want
i'm trying to migrate some data from two tables in an OLD database, to
I have a set of SQL scripts to migrate data from tables in SQL
I have two SQL Servers (both 2005 version). I want to migrate several tables
I want to migrate one of my database from myisam to innodb. The main
I am migrating data from one database schema to another. The old schema has

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.