Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2012
    Posts
    3

    append data question

    I have two databases on the same server: DatabaseA and DatabaseB both data bases have identical structures for example each have 2 tables with the exact table names, field names, and data types.

    I need to APPEND all of the data from DatabaseB to DatabaseA.

    How do I accomplish this?


    Thanks in advance!

  2. #2
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    Select or unload everything from one database.

    Insert or load into the other.

    Depending on which database system you are using, the specifics will be specific to that database system. You may need to pre-detemine the "rules" for handling duplicate keys etc.
    Last edited by papadi; 11-08-12 at 23:10.

  3. #3
    Join Date
    Nov 2012
    Posts
    3
    I'm using mySQL. Can you please be more specific your answer does not help me.

    Thanks,

  4. #4
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    When faced with a completely non-specific question, the most correct answers are often non-specific as well.

    Your topic would probably get far better "service" if you had posted in the MySQL part of the forum. If you "search" or visually scroll thru some of the topics, you may find what you are looking for.

    Possibly our friendly moderator will once again relocate this topic for you. If it has not been moved in 12 hours or so, you may be ahead to re-post and we can clean this one out then.

    Good luck.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    12,568
    within MySQL, providing both databases are on the same physical server you can directly address tables in another db and treat them as local tables

    so anything that you can do in SQL can be done on tables in different MySQL databases THAT are on the same server.

    to do this use the database name as part of the table/column defintion

    eg
    select my, column, list FROM MyTable as A
    join SecondDataBase.MyOtherTable as B on B.MyColumn = A.MyColumn

    select A.my, B.column, A.list FROM MyTable as A
    join SecondDataBase.MyOtherTable as B on B.MyColumn = A.MyColumn


    But then had you done a google search you'd have known that

    Connecting two mysql tables from different databases - PHP
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Nov 2012
    Posts
    3

    I figured out the solution

    The one seeking answers figured it out for himself.
    Here is a much simpler solution

    insert into databaseA.table1 select * from dataBaseB.table1;
    insert into databaseA.table2 select * from dataBaseB.table2;

    Oh, by the way, a quick note to Papadi: giving general answers is also a way to cover up the fact that a person has no clue

    Cheers,

  7. #7
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    giving general answers is also a way to cover up the fact that a person has no clue
    If you truly believe this, you have a very long, very ugly journey ahead . . .

    I cannot speak for anyone else but the reason i participate in these forums (and provide general answers is to possibly help someone learn - Not spoon-feed them.

    Your "solution" will only work for rather small volume. If you try this with a vew hundred million rows with multiple keys, you will most likely Not be satisfied with the performance.

Posting Permissions

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