How to Compare Data Consistency between MySQL and PostgreSQL

Background Recently, I encountered a problem where a user wanted to synchronize data from PostgreSQL to TiDB (which uses the same protocol as MySQL) and wanted to know whether the data after synchronization is consistent. I hadn’t dealt with this kind of issue before, so I did a bit of research. Typically, to verify data consistency, you compute a checksum on both sides and compare them. TiDB (MySQL) Side For the verification of a specific table, the following SQL is used: ...

May 9, 2021 · 3 min · 461 words · Jack Yu

How to Practice Using SQL

The text provided is a detailed set of instructions and queries for practicing SQL using PostgreSQL 9.4 BETA 2, focusing on creating and querying tables related to students, courses, scores, and teachers. Here’s a summary: Database Structure The database consists of four tables: STUDENT: Contains student number (SNO), name (SNAME), gender (SSEX), birthday (SBIRTHDAY), and class (CLASS). COURSE: Includes course number (CNO), name (CNAME), and teacher number (TNO). SCORE: Records student number (SNO), course number (CNO), and degree (DEGREE). TEACHER: Holds teacher number (TNO), name (TNAME), gender (TSEX), birthday (TBIRTHDAY), professional title (PROF), and department (DEPART). Sample Data Students such as Zeng Hua, Kang Ming, and Wang Fang are stored with specific details, including their class and gender. Courses like “Introduction to Computers” and “Operating Systems” are associated with teacher numbers. Scores are recorded for students across various courses. Teachers are described with their professional roles and departments. Query Problems Several SQL queries are suggested for practice, such as: ...

June 5, 2014 · 3 min · 472 words · Jack Yu