数据迁移后,一定要做数据一致性验证。方法如下:
1.数据量验证,即表的行数一致,
select count(*) from tab1;
2.数据格式,列的一致性验证,在行数一致的前提下,验证每一列正确迁移,无乱码,无格式问题,迁移前后数据完全一致。
mysql> select `CountryCode`,concat(ifnull(ID,''),ifnull(Name,''),ifnull(CountryCode,''),ifnull(District,''),ifnull(Population,'')) fr
om city limit 10;
+-------------+--------------------------------------------------------------------------------------------------------+
| CountryCode | concat(ifnull(ID,''),ifnull(Name,''),ifnull(CountryCode,''),ifnull(District,''),ifnull(Population,'')) |
+-------------+--------------------------------------------------------------------------------------------------------+
| AFG | 1KabulAFGKabol1780000 |
| AFG | 2QandaharAFGQandahar237500 |
| AFG | 3HeratAFGHerat186800 |
| AFG | 4Mazar-e-SharifAFGBalkh127800 |
| NLD | 5AmsterdamNLDNoord-Holland731200 |
| NLD | 6RotterdamNLDZuid-Holland593321 |
| NLD | 7HaagNLDZuid-Holland440900 |
| NLD | 8UtrechtNLDUtrecht234323 |
| NLD | 9EindhovenNLDNoord-Brabant201843 |
| NLD | 10TilburgNLDNoord-Brabant193238 |
+-------------+--------------------------------------------------------------------------------------------------------+
10 rows in set (0.00 sec)
通过如上代码进行查询,那么最终只需要按主键对比即可。只要合并列的内容一致,即说明迁移是一致的,如不一致可迅速定位问题。
3.主键,约束等。不细述。