473,809 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merging databases

Ike
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA, but
with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?

Thanks, Ike
Jul 20 '05 #1
15 2938
Ike spilled the following:
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA,
but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


This kinda suggests that you didn't normalize your database.

To answer your question....

1) do you need to ....
(
SELECT 'A' AS Branch, BranchA.* FROM BranchA WHERE $criteria
) UNION (
SELECT 'B' AS Branch, BranchB.* FROM BranchB WHERE $creiteria
)
2) if you really have to then...
DELETE FROM BranchToT;
INSERT INTO BranchToT SELECT * FROM BranchA WHERE $criteria
REPLACE INTO BranchToT SELECT * FROM BranchB WHERE $criteria
I'll leave you to work out why the third statement in the above might work
better with a REPLACE instead of an INSERT.

C.

Jul 20 '05 #2
Ike spilled the following:
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA,
but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


This kinda suggests that you didn't normalize your database.

To answer your question....

1) do you need to ....
(
SELECT 'A' AS Branch, BranchA.* FROM BranchA WHERE $criteria
) UNION (
SELECT 'B' AS Branch, BranchB.* FROM BranchB WHERE $creiteria
)
2) if you really have to then...
DELETE FROM BranchToT;
INSERT INTO BranchToT SELECT * FROM BranchA WHERE $criteria
REPLACE INTO BranchToT SELECT * FROM BranchB WHERE $criteria
I'll leave you to work out why the third statement in the above might work
better with a REPLACE instead of an INSERT.

C.

Jul 20 '05 #3
Ike spilled the following:
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA,
but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


This kinda suggests that you didn't normalize your database.

To answer your question....

1) do you need to ....
(
SELECT 'A' AS Branch, BranchA.* FROM BranchA WHERE $criteria
) UNION (
SELECT 'B' AS Branch, BranchB.* FROM BranchB WHERE $creiteria
)
2) if you really have to then...
DELETE FROM BranchToT;
INSERT INTO BranchToT SELECT * FROM BranchA WHERE $criteria
REPLACE INTO BranchToT SELECT * FROM BranchB WHERE $criteria
I'll leave you to work out why the third statement in the above might work
better with a REPLACE instead of an INSERT.

C.

Jul 20 '05 #4

"Ike" <rx*@hotmail.co m> wrote in message
news:LZ******** ********@newsre ad2.news.pas.ea rthlink.net...
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA, but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


Yes, several tables can be merged into a summary table, and you can still
keep
BranchA, and BranchB...

See below or reference (TIP 8) at the following url:
http://osdn.dl.sourceforge.net/sourc...ADME_mysql.txt

CREATE TABLE BranchA (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchB (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchSUMMARY_s ummary (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;
insert into BranchA (a,b) values (1,'log1');
insert into BranchB (a,b) values (1,'log2');

To get combined results

select * from BranchSUMMARY;
Hope this helps.

Regards,

Mike Chirico
Jul 20 '05 #5

"Ike" <rx*@hotmail.co m> wrote in message
news:LZ******** ********@newsre ad2.news.pas.ea rthlink.net...
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA, but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


Yes, several tables can be merged into a summary table, and you can still
keep
BranchA, and BranchB...

See below or reference (TIP 8) at the following url:
http://osdn.dl.sourceforge.net/sourc...ADME_mysql.txt

CREATE TABLE BranchA (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchB (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchSUMMARY_s ummary (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;
insert into BranchA (a,b) values (1,'log1');
insert into BranchB (a,b) values (1,'log2');

To get combined results

select * from BranchSUMMARY;
Hope this helps.

Regards,

Mike Chirico
Jul 20 '05 #6

"Ike" <rx*@hotmail.co m> wrote in message
news:LZ******** ********@newsre ad2.news.pas.ea rthlink.net...
Suppose I have a relational database, called "BranchA."

I have a second relational database, of identical structure to BranchA, but with different data, and this one is called BranchB.

Can I merge the two, into, say, a BranchC somehow on occassion?


Yes, several tables can be merged into a summary table, and you can still
keep
BranchA, and BranchB...

See below or reference (TIP 8) at the following url:
http://osdn.dl.sourceforge.net/sourc...ADME_mysql.txt

CREATE TABLE BranchA (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchB (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MyISAM;

CREATE TABLE BranchSUMMARY_s ummary (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;
insert into BranchA (a,b) values (1,'log1');
insert into BranchB (a,b) values (1,'log2');

To get combined results

select * from BranchSUMMARY;
Hope this helps.

Regards,

Mike Chirico
Jul 20 '05 #7
> CREATE TABLE BranchSUMMARY_s ummary (

That's BranchSUMMARY without "_summary" which was a typo on my part.

CREATE TABLE BranchSUMMARY (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;

Regards,

Mike Chirico
Jul 20 '05 #8
> CREATE TABLE BranchSUMMARY_s ummary (

That's BranchSUMMARY without "_summary" which was a typo on my part.

CREATE TABLE BranchSUMMARY (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;

Regards,

Mike Chirico
Jul 20 '05 #9
> CREATE TABLE BranchSUMMARY_s ummary (

That's BranchSUMMARY without "_summary" which was a typo on my part.

CREATE TABLE BranchSUMMARY (
pkey int(11) NOT NULL auto_increment,
a int,
b varchar(12),
timeEnter timestamp(14),
PRIMARY KEY (pkey)
) type=MERGE UNION(log_01,lo g_02) INSERT_METHOD=L AST;

Regards,

Mike Chirico
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1891
by: Patrick | last post by:
I have got 2 XML documents, both of which conform to the same XSD Schema, which define possible optional elements. The 2 XML documents contain 2 disjoint set of XML elements. What is the best, easiest, most efficient way of merging the 2 XML Documents? Can I use DataSet.Merge() facility in ADO.NET?? Any pre-requisites? Any other suggestions?
3
1686
by: abprules | last post by:
If I wanted to merge 2 sample databases that are from the same Access version, such as an events management and a scheduling database, is this possible? And if so, can anyone give me directions or give me a page that has the directions?
1
3406
by: actimel01 | last post by:
I know this question has been asked many times before but I can't find an answer that fits my data! I have two Access databases. The tables in each have the exactly the same fields except for one (which was added into the tables in the second database). Thye do have different records. I want to merge the records from the tables from in the first database into the tables in the second. Other answers have suggested merging the tables in a...
31
2188
by: louishong | last post by:
3rd time posting this as the first two simply disappeared! Here's the issue: We currently run an Access application in the West Coast for tracking resource centric data. For those located in the West the program zips along fine but the folks in the East Coast are having a nightmarish performance issue. We've had our tech guys take a look and it's due to the network speed across a long distance and there's nothing much that can be done.
1
1252
by: Chandra | last post by:
I am storing data temporarily in a database... and periodically need to update that huge database, so just has to copy that temp DB to the original one. Using sql may take a few hours to finish this operation. I think you can do "export" from temp database into a file and "import" into the huge database. That will be binary data exort and import and hence will be faster. But, I am not sure if all databases will support that though.
3
3880
by: Ralph Smith | last post by:
I have two identical databases on two different servers and I need to add the data in tables from one server to the tables in the other server. Is there a way to do that in mysql? thanks, Ralph
9
2190
by: karenjfrancis | last post by:
I have 4 Access databases, all with the same data model but different data. I want to build a front end that brings all of the data in the 4 databases together into one. Assuming my table of interest is called Removals, if I create linked tables I end up with Removals1, Removals2, Removals3 and Removals4. I could easily write a query to base a form or report upon to concatenate all of these tables' data into one view. However, the...
6
4225
by: gaubun | last post by:
Hi All, Just joined this site....I am really stuck into one problem. Actually I am writing a code in VB6 to merge TWO ACCESS DATABASES. Wanted to know if I can use a single sql query to merge. Is MERGE or UNION effective in merging two DATABASES. Plz help. I am looking forward to get some positive replies. Thanx in advance. Gaurav
3
2976
by: ramab | last post by:
Hi, im trying to merge 2 databases having the same structure. How do i merge the two databases which have unique identifiers and auto numbers. e.g the first 10 records in table A , it will have auto numbers from 1 to 10 and table B will also have auto numbers from 1 to 10. So will i merged them into 1 table C whereby for e.g table C will have auto numbers from 1 to 20?? Thx in advance.
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.