


Data table migration data consistency verification, migration data consistency verification_PHP tutorial
Data table migration data consistency verification, migration data consistency verification
It is still very useful to do some necessary verification when migrating the database, such as the data strips before and after migration Is the number consistent? Is the data consistent? What should I do at this time? It’s okay to verify the number of entries. What if I want to verify whether the data is consistent? Of course, for important data, every entry must be error-free. Random sampling verification is definitely not possible. If you omit it, you will be in trouble, and the two tables are no longer on the same server. What to do at this time? There is a way:
The above method was thought up at the same time and is not bad, but I think there is room for improvement:
- First of all, not all fields may appear different in non-main fields.
- The overall efficiency is relatively low
My thoughts are this:
The advantage of the second method is that the output file will be reduced within a certain range, making it easy to compare. However, it also has disadvantages. It cannot directly locate the location of different data through key fields like the first method.
The following is the specific code implementation of the effect of the second method:
'localhost',
'port' => '3306',
'user' => 'root',
'pswd' => '123456',
'charset' => 'utf8',
'tables' => array(
'lagou.pos',
'lagou.pos_innodb',
),
);
//Verify format
if(!$link = mysql_connect($dbinfos['host'].":".$dbinfos['port'],$dbinfos['user'], $dbinfos['pswd']))
{
die("connect to [{$host}@{$port}] failed!!");
}
if(!mysql_query("set names {$dbinfos['charset']}"))
{
die("set charset error : ".mysql_error());
}
foreach ($dbinfos['tables'] as $table)
{
if($is_count)
{
$sql = "select count(*) as nums from {$table}";
$ret = mysql_query($sql);
if(!$ret)
{
die("error : ".mysql_error());
}
$ret = mysql_fetch_array($ret, MYSQL_ASSOC);
echo "{$table} : {$ret['nums']}n";
}
if($is_md5)
{
$path = $is_md5.DIRECTORY_SEPARATOR.$table;
$sql = "select * from {$table}";
$ret = mysql_query($sql);
$flag = 0;
$fields = '';
while ($_ret = mysql_fetch_array($ret, MYSQL_NUM)) {
$flag;
while($_ret)
{
$fields .= array_pop($_ret);
}
if($flag % $conbine_num == 0)
{
file_put_contents($path, md5($fields)."n", FILE_APPEND);
$fields = '';
}
}
if($flag % $conbine_num != 0 && $flag > 0)
{
file_put_contents($path, md5($fields)."n", FILE_APPEND);
}
echo "save to file info : ".realpath($path)."n";
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Redis is an open source, high-performance NoSQL database. Due to its fast read and write speed and rich data structure, it is widely used in cache, queues, distributed locks, etc. However, its application in the field of distributed transactions still needs to be further studied. This article will start from the characteristics of Redis and explore how to use Redis to ensure the consistency and reliability of distributed transactions. 1. Data structure characteristics of Redis Redis supports a wide range of data structures, including strings, lists, hash tables, sets, etc. this

How to implement the consistency and fault-tolerance mechanism of distributed cache in Java. Distributed cache is a commonly used technology in high-concurrency Internet systems. It can improve the performance and scalability of the system. However, distributed caches face consistency and fault tolerance challenges. In this article, we will discuss how to implement distributed cache consistency and fault tolerance in Java and provide specific code examples. 1. Consistency mechanism In a distributed environment, cache consistency is very important. The consistency of distributed cache can be achieved through the following two mechanisms: cache update

How to deal with concurrent database data consistency issues in Go language? When multiple concurrent requests access the database at the same time, data consistency issues may arise. In Go language, we can use transactions and locks to deal with this problem. Below I will introduce in detail how to handle concurrent database data consistency issues in the Go language and give specific code examples. First, we need to use the transaction mechanism of the database. Database transactions provide a mechanism for treating a series of database operations as a whole, either all succeeding or all failing.

With the rapid development of Internet applications, distributed architecture has become an important choice for enterprise-level applications. As one of the common caching technologies, Redis also plays an important role. The reliability and consistency of distributed transactions are one of the inevitable topics in architecture design. This article will take Redis as an example to discuss its reliability and consistency comparison in distributed transactions. 1. Common problems with Redis Redis provides fast and efficient access by caching data in memory. But at the same time, it also faces problems such as data loss.

Master Distributed Cache Consistency Skills in Java Development With the rapid development of the Internet, most applications are facing the challenges of distributed systems. In order to improve performance and scalability, many applications use distributed cache to cache data. However, the consistency problem of distributed cache has always been a difficult problem faced by developers. This article will introduce some distributed cache consistency techniques in Java development to help developers solve these problems. 1. Background knowledge of distributed caching. Before introducing specific techniques, let us first understand distributed caching.

With the development of Internet technology, distributed application systems have become a challenge that programmers must face in their daily work. When dealing with distributed data, ensuring consistency is one of our biggest concerns. At this time, MySql is a favored solution because it can provide most of the functions required by distributed applications. This article will introduce how to use MySql to solve data consistency problems in a distributed environment. What is a distributed transaction? A distributed transaction means that the operation of a transaction involves multiple independent calculations.

Redis is a high-performance in-memory database that is widely used for large-scale data storage and processing. In addition to being used as an independent database, Redis can also be used as a cache layer to improve the access speed of the system. In distributed application scenarios, Redis plays an increasingly important role as a distributed cache. However, in a distributed environment, how to ensure the consistency of the Redis distributed cache is a difficult problem that developers need to face. This article will introduce the method and application examples of Redis to achieve distributed cache consistency. one

Redis is a high-performance, distributed memory database that is widely used in distributed systems. In distributed systems, how to achieve transaction consistency has always been a problem, and the transaction mechanism provided by Redis can help developers solve this problem. This article will introduce how Redis achieves the consistency of distributed transactions and show code examples. 1. Introduction to Redis transaction mechanism Redis provides a transaction mechanism in version 2.0, which uses MULTI, EXEC, WATCH, DISCA
