且构网

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

将数据从一个数据库字段复制到另一数据库字段

更新时间:2022-06-03 03:21:17

如您所见,我需要在copydata函数中使用delete语句,因为否则我将收到违反唯一约束的错误。也不是唯一标识符。

"As you can see I needed delete statement in my copydata function because otherwise I will get the unique constraint violated error. There are also no unique identifiers"

唯一约束意味着存在一些唯一标识符。您是说没有单个列充当标识符吗?

A unique constraint implies that there is some unique identifier. Do you mean that there is no single column that acts as an identifier?

无论是通过UPDATE还是通过从每个数据库中提取某些列的INSERT进行操作,您都需要将DEV中的行与SAT中的行进行匹配的一些方法。如果匹配不是唯一的,您将得到不确定的结果或比开始时更多的行。

Whether you do it by UPDATE or by an INSERT that pulls some columns from each database, you need some method of matching rows in DEV to rows in SAT. If the match is not unique, you will get either nondeterministic results or more rows than you started with.

我唯一想到的替代方法是您有一些隐式行的排序,并且您想匹配该行-最终没有什么不同,您可以只根据排序生成唯一的标识符。

The only alternative that I can think of is that you have some implicit ordering of the rows and you want to match on that -- which is ultimately no different, you could just generate the unique identifier from the orderings.

在下面的示例中说您想将第2列从DEV复制到SAT。决定DEV中的哪个值进入SAT中的哪一行?

Say in the following example you wanted to copy column 2 from DEV to SAT. What decides which value in DEV goes into which row in SAT?

DEV data                  1   2
                          x   u
                          y   v
                          z   w


SAT data                  1  2
                          a  0
                          b  0
                          c  0

new SAT DATA(merge)       1  2
                          a  ?
                          b  ?
                          c  ?