且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在mysql中合并两个数据库?

更新时间:2023-08-24 10:23:46

您有一些不同的问题,这是您可以采用的一种方式。



1.不同的主键

您可以创建一个新的主键并将旧键保存在一个单独的表中。 />
通过这样做,您仍然可以找到带有ol的项目d ID,但没有弄乱正在使用的桌子。



LegacyOperationLookup

You have some different issues and here is one way you can approach them.

1. Different primary keys
You can create a new primary key and keep the old keys in a separate table.
By doing this you can still find an item with an old ID, but without messing up the table in use.

LegacyOperationLookup
OperationID   LegacyOperationID   Source
1             00215               Database1
2             46                  Database2



这取决于您是否可以***更改设计。



2。不同的列

如果你需要类似的类似的表,但是一个表有一些额外的列,或者如果两个表都有一个列而另一个表缺少,那么你至少有两个选择。

a。您可以使用所有列的总和创建一个新表。

b。您可以创建一个包含附加列的额外表格作为遗产​​。



这里的技巧是知道额外的列是否在新组织中有用,以及是否列可以是NULL也可以不是。

如果没有人会使用附加列,***将它们保存在一个单独的表中。

如果附加列不能为NULL ,你必须决定插入什么作为空值。



3。 PHP管理员

查看此链接合并两个MySQL数据库 [ ^ ]或在Google中使用相同的词组。





4。 UML图

关于UML图我不会为你做那个,但只是给你一个指针,你可以开始学习它: TutorialsPoint:UML - 标准图 [ ^ ]



我希望这能给你至少一些帮助。


This depends on if you have the freedom to change the design.

2. Different columns
If you have to similar similar tables but one table has some extra columns, or if both tables have a column the other table is missing, you have at least two choices.
a. You can create a new table with the sum of all columns.
b. You can create an extra table containing the additional columns as legacy.

The trick here is to know if the extra columns are useful in the new organisation or not and also if the columns can be NULL or not.
If no one will use the additional columns it is better to keep them in a separate table.
If the additional columns cannot be NULL, you have to decide what to insert as empty values.

3. PHP Admin
See this link Merge two MySQL databases[^] or use the same phrase in Google.


4. UML Diagram
Regarding the UML diagram I will not do that for you, but just give you a pointer where you can start to learn it: TutorialsPoint: UML - Standard Diagrams[^]

I hope this gives you at least some help forward.