Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Data table migration data consistency verification

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

It is very useful to do some necessary verification when migrating the database, for example, whether the number of data items before and after the migration is consistent, and whether the data are consistent? what should we do at this time? the number of verification items is OK. If you verify whether the data is consistent, of course, there will be no mistakes in every piece of important data. Random sampling verification is certainly not good. If you miss it, it will be troublesome. And the two tables are not on the same server. What should we do at this time? there is one way:

Select several important fields from the table, such as A, B, C, and use these fields as the yardstick for comparison. Export these three fields of each piece of data from the original table to a file F1. From these three fields of each piece of data in the destination table to file f2. Compare whether each piece of data in the files F1 and f2 is the same. come to conclusion

The above method was come up with at the same time, which is not bad, but I think there is still room for improvement:

First of all, not all fields, it is still possible to appear different in non-primary fields. The overall efficiency is relatively low

Here's what I think:

Splice every n pieces of data in the table (directly connected, n values depend on the size of each piece of data). Calculate the MD5 values of these n pieces of data and add them to file F1 until all data values are complete. The same is true for the destination table, in the recorded file f2. Compare the MD5 values of files F1 and f2, if consistent, ok, successful. If it is inconsistent, compare each MD5 value from the top down and find the m inconsistency. It is concluded that the inconsistent data can be located again when the inconsistent data is between m * (nmur1) + 1 ~ m\ n.

The advantage of the second method is that the output file will be reduced in a certain range, and it is convenient to compare, but it also has some disadvantages, like the first method, it can not directly locate different data through key fields.

The following is the specific code implementation of the second method effect sum:

? 12 34 56 78 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report