DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Inserting data into one table from multiple tables

  1. #1
    Join Date
    Feb 2001
    Location
    Bangalore, India
    Posts
    109

    Inserting data into one table from multiple tables

    I’ve a requirement as follows.

    The data from 14 tables needs to be dumped into one table
    While inserting the data, the columns’ values are to be calculated based on calculations
    The calculations involve different columns from different tables.
    The number of rows in the each of the 14 tables could be around 50000

    Please suggest the best way to do this data transfer from 14 tables to one table.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166

    Re: Inserting data into one table from multiple tables

    Originally posted by sln81
    I’ve a requirement as follows.

    The data from 14 tables needs to be dumped into one table
    While inserting the data, the columns’ values are to be calculated based on calculations
    The calculations involve different columns from different tables.
    The number of rows in the each of the 14 tables could be around 50000

    Please suggest the best way to do this data transfer from 14 tables to one table.

    Thanks in advance.
    Like this?

    Code:
    CREATE TABLE blah AS 
             SELECT * 
               FROM 14_tables 
              WHERE ...;

  3. #3
    Join Date
    Feb 2001
    Location
    Bangalore, India
    Posts
    109
    What about the performance of joining 14 tables?

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Originally posted by sln81
    What about the performance of joining 14 tables?
    You can create the SELECT portion of the INSERT statement and then do an explain plan. You can grab the primary key and foriegn keys from the minimum tables to do the INSERT and then do updates from the remaining tables.

Posting Permissions

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


Click Here to Expand Forum to Full Width