If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > append data question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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!
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
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 22:10.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Nov 2012
Posts: 3
I'm using mySQL. Can you please be more specific your answer does not help me.

Thanks,
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
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.
Reply With Quote
  #5 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,092
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
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,
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
Join Date: Oct 2009
Location: 221B Baker St.
Posts: 487
Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On