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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:57:46+00:00 2026-05-11T18:57:46+00:00

I am moving old project that used single table inheritance in to a new

  • 0

I am moving old project that used single table inheritance in to a new database, which is more structured. How would I write a SQL script to port this?

Old structure

I’ve simplified the SQL for legibility.

CREATE TABLE customers (
  id int(11),
  ...
  firstName varchar(50),
  surname varchar(50),

  address1 varchar(50),
  address2 varchar(50),
  town varchar(50),
  county varchar(50),
  postcode varchar(50),
  country varchar(50),

  delAddress1 varchar(50),
  delAddress2 varchar(50),
  delTown varchar(50),
  delCounty varchar(50),
  delPostcode varchar(50),
  delCountry varchar(50),

  tel varchar(50),
  mobile varchar(50),
  workTel varchar(50),
);

New structure

CREATE TABLE users (
  id int(11),
  firstName varchar(50),
  surname varchar(50),
  ...
);

CREATE TABLE addresses (
  id int(11),

  ForeignKey(user),
  street1 varchar(50),
  street2 varchar(50),
  town varchar(50),
  county varchar(50),
  postcode varchar(50),
  country varchar(50),
  type ...,
);

CREATE TABLE phone_numbers (
  id int(11),
  ForeignKey(user),
  number varchar(50),
  type ...,
);
  • 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-11T18:57:46+00:00Added an answer on May 11, 2026 at 6:57 pm

    With appropriate cross-database notations for table references if appropriate:

    INSERT INTO Users(id, firstname, surname, ...)
        SELECT id, firstname, surname, ...
            FROM Customers;
    INSERT INTO Addresses(id, street1, street2, ...)
        SELECT id, street1, street2, ...
            FROM Customers;
    INSERT INTO Phone_Numbers(id, number, type, ...)
        SELECT id, phone, type, ...
            FROM Customers;
    

    If you want both the new and the old address (del* version), then repeat the address operation on the two sets of source columns with appropriate tagging. Similarly, for the three phone numbers, repeat the phone number operation. Or use a UNION in each case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am moving data from an old table to a SQL server new version
When moving a file from old.package to new.package I want two things to happen:
I have an old asp app I am moving to a new server with
I'm moving my ASP.NET website to a new provider. Only problem is, old host
Before moving on to use SVN, I used to manage my project by simply
I am moving and old asmx webservice to a new server with IIS7. This
I am moving an old asp classic (sigh...) local website to a new IIS7.5
I am moving a SQL Server 2005 database to a new server using a
I'm having problem moving from mvc 1 to mvc 2. In my old project
I am moving the old server to archive.example.com, and the new server will continue

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.