WO2020248375A1 - 数据库间数据同步方法、系统、计算机设备及存储介质 - Google Patents
数据库间数据同步方法、系统、计算机设备及存储介质 Download PDFInfo
- Publication number
- WO2020248375A1 WO2020248375A1 PCT/CN2019/102843 CN2019102843W WO2020248375A1 WO 2020248375 A1 WO2020248375 A1 WO 2020248375A1 CN 2019102843 W CN2019102843 W CN 2019102843W WO 2020248375 A1 WO2020248375 A1 WO 2020248375A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- synchronization
- operation instruction
- incremental
- sql statement
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F16/273—Asynchronous replication or reconciliation
Definitions
- the embodiments of the present application relate to the field of data processing technology, and in particular, to a method, system, computer device, and storage medium for data synchronization between databases.
- the purpose of the embodiments of the present application is to provide a data synchronization method, system, computer device, and non-volatile computer-readable storage medium between databases, which can increase the scalability of the system and reduce development costs.
- an embodiment of the present application provides a data synchronization method between databases, which includes the following steps:
- an embodiment of the present application also provides a computer device, including a memory, a processor, and computer-readable instructions stored in the memory and running on the processor, and the processor executes the computer-readable instructions.
- the steps of the method for data synchronization between databases as described above are implemented when instructed.
- the embodiments of the present application also provide a non-volatile computer-readable storage medium.
- the non-volatile computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions may Is executed by at least one processor, so that the at least one processor executes the steps of the method for data synchronization between databases as described above.
- the method, system, computer equipment, and non-volatile computer-readable storage medium for data synchronization between databases acquire data operation instructions and analyze the data operation instructions to obtain the data operation instructions.
- the table name of the included data table, the data operation instruction is an instruction based on the SQL statement; it is judged whether there is a data table matching the table name in the preset synchronization record table; if it exists, the record is based on the data
- the incremental data generated by the data processing service executed by the operation instruction; and the incremental data is periodically synchronized to the target database, so that the scalability of the system can be increased and the development cost can be reduced.
- FIG. 1 is a schematic diagram of the implementation process of the first embodiment of the data synchronization method between databases of this application.
- FIG. 2 is a detailed flow diagram of the steps of obtaining data operation instructions in this application and analyzing the data operation instructions to obtain the table names of the data tables included in the data operation instructions.
- FIG. 3 is a detailed flow diagram of the step of synchronizing the incremental data to the target database regularly in this application.
- FIG. 4 is a schematic diagram of the implementation process of the second embodiment of the method for data synchronization between databases of this application.
- FIG. 5 is a schematic diagram of program modules of a data synchronization system between databases according to an embodiment of this application.
- FIG. 6 is a schematic diagram of the hardware structure of a computer device according to an embodiment of the application.
- FIG. 1 shows a flowchart of a method for data synchronization between databases in the first embodiment of the present application. It can be understood that the flowchart in this method embodiment is not used to limit the order of execution of the steps.
- the following is an exemplary description with an inter-database data synchronization system (hereinafter referred to as “synchronization system” for short) as the execution subject, and the synchronization system can be applied to computer equipment. details as follows:
- Step S100 Obtain a data operation instruction, and parse the data operation instruction to obtain a table name of a data table included in the data operation instruction.
- the data operation instruction is an instruction based on a SQL statement.
- the synchronization system may obtain data operation instructions sent by the user equipment, and the data operation instructions may include data addition instructions, data deletion instructions, data modification instructions, and so on. After receiving the data operation instruction, the synchronization system may further execute data processing services according to the data operation instructions.
- the data processing services may include data addition services, data deletion services, data modification services, etc. to the database. For example, if the data operation instruction is a data modification instruction, the synchronization system modifies the corresponding data in the database according to the data modification instruction.
- the synchronization system can also parse the data operation instruction to obtain the data table information involved in the data operation instruction.
- the data table information includes the table name of the data table. .
- the data operation instruction in the embodiment of the present application is an instruction based on a SQL (Structured Query Language) statement, that is, the data operation instruction is an SQL statement.
- SQL Structured Query Language
- the step of obtaining a data operation instruction and analyzing the data operation instruction to obtain the table name of the data table included in the data operation instruction includes:
- Step S200 intercept the data operation instruction through the mybtis interceptor, and obtain the SQL statement in the data operation instruction;
- Step S202 parse the SQL statement to extract the table name of the data table included in the SQL statement.
- the synchronization system can call the mybtis interceptor to intercept the data operation instruction, thereby capturing the SQL statement in the data operation instruction. After the SQL statement is captured, the SQL statement can be further analyzed to extract the SQL statement
- the data table information includes the table name of the data table.
- the mybtis interceptor when the table name of the data table contained in the data operation instruction does not need to be obtained, the mybtis interceptor can be shielded.
- Step S102 Determine whether there is a data table matching the table name in the preset synchronization record table.
- the synchronization record table is a data table that needs to be synchronized in each data table of the source database.
- the synchronization record table can be set according to business requirements. For example, if the current business requirement is to synchronize the modified data in data table A and data table B in the source database, the synchronization record table can be set to include Data table A and data table B, that is, only the modified data in data table A and data table B need to be synchronized in the future, and the data in other data tables does not need to be synchronized; if the current business requirement is to synchronize the source database , You can set the synchronization record table to include all data tables in the source database, that is, as long as the data in the source database is modified subsequently, the modified data must be synchronized.
- the obtained table name and the table name of each data table contained in the synchronization record table can be compared with the obtained table name one by one to determine whether the synchronization record table exists and The data table whose table name matches.
- Step S104 if it exists, record the incremental data generated by the data processing service executed according to the data operation instruction.
- the incremental data includes the SQL statement corresponding to the data operation instruction and the data table information, database information, etc. involved in the SQL statement.
- Step S106 Synchronize the incremental data to the target database regularly.
- the synchronization system regularly synchronizes incremental data to the target database, for example, synchronizes all incremental data to the target database every 1 minute.
- the target database is the database to which the data in the source database is to be synchronized, and there may be multiple target databases, for example, database A, database B, database C, and so on.
- the SQL statement contained in the incremental data can be executed in the target database, thereby achieving data synchronization.
- the address of the target database needs to be maintained in the source database in advance.
- the method for data synchronization between databases proposed in this embodiment of the application obtains data operation instructions and parses the data operation instructions to obtain the table name of the data table included in the data operation instruction. It is an instruction based on SQL statement; it is determined whether there is a data table matching the table name in the preset synchronization record table; if it exists, it records the incremental data generated by the data processing service executed according to the data operation instruction ; And regularly synchronize the incremental data to the target database, which can increase the scalability of the system and reduce development costs.
- the step of periodically synchronizing the incremental data to the target database includes:
- Step S300 Determine the incremental data that currently needs to be synchronized.
- the incremental data recorded in this synchronization cycle is 15:12:10
- the time stamp of this synchronization cycle is 15:13:10, it is between 15:12:10 and 15:13:10
- the incremental data recorded in the time period is the incremental data that needs to be synchronized currently.
- Step S302 Obtain the first data table associated with each incremental data.
- each incremental data is associated with a first data table, and the first data table associated with different incremental data may be the same or different.
- Step S304 Determine the address information of the target database corresponding to each incremental data according to the first data table.
- each first data table may correspond to one target database, or may correspond to multiple target databases.
- data table a corresponds to target database B
- data table b corresponds to target database C and target database D, and so on.
- Step S306 Synchronize each incremental data to the corresponding target database according to the address information.
- the synchronization system can synchronize the incremental data to the corresponding target database through the address of the target server.
- the method further includes:
- the target database executes the SQL statement in the incremental data, thereby achieving data synchronization.
- the target database performs the data synchronization operation, it will feed back a data synchronization result to the synchronization system.
- the synchronization system parses the synchronization result, and then can determine that the target database is checking the data according to the parsed synchronization result Whether the data synchronization was successfully completed during synchronization.
- identification information for the incremental data that has been synchronized, such as setting the “complete” flag or the “1” flag to Indicates that the incremental data has completed data synchronization.
- the target database after the target database receives the incremental data, it continuously executes the SQL statement in the incremental data several times (for example, 3 times), and the data synchronization is still not achieved, then the synchronization can be fed back
- the failed synchronization result is sent to the synchronization system.
- the synchronization system After receiving the synchronization result, the synchronization system parses the synchronization result, and then can determine whether the target database successfully completes the data synchronization when synchronizing the data according to the parsed synchronization result.
- a notification message is sent to the preset user.
- the notification message can be sent by email or by SMS.
- the preset user is preferably a maintenance person of the target server.
- the synchronized incremental data when the data synchronization of the incremental data is successfully completed, the synchronized incremental data may be stored in the historical data table as a record. In this embodiment, by storing the successfully synchronized incremental data in the historical data table, it is convenient to troubleshoot the problem based on the data in the historical data table when a problem occurs later.
- FIG. 4 is a schematic diagram of the implementation process of the second embodiment of the data synchronization method between databases of the present application.
- the execution order of the steps in the flowchart shown in FIG. 4 can be changed, and some steps can be omitted.
- the following exemplarily describes an inter-database data synchronization system (hereinafter referred to as “synchronization system” for short) as the execution subject, and the synchronization system can be applied to a server. details as follows:
- Step S400 Set a data record range corresponding to the data processing service, and add the data record range to the synchronization record table.
- the data record range corresponding to the data processing service can be set according to business requirements, and the data record range is specifically which data tables in the source database need to be synchronized.
- the data recording range can be set in advance, or can be set later based on user input information. For example, if the user needs to synchronize the data table a in the source database, the user can input the information corresponding to the data table a to the synchronization system. After receiving the input information, the synchronization system sets the data table a according to the input information. Data logging range.
- Step S402 Obtain a data operation instruction, and parse the data operation instruction to obtain a table name of a data table included in the data operation instruction.
- the data operation instruction is an instruction based on a SQL statement.
- Step S404 Determine whether there is a data table matching the table name in the preset synchronization record table
- Step S406 if it exists, record the incremental data generated by the data processing service executed according to the data operation instruction.
- Step S408 Synchronize the incremental data to the target database regularly.
- steps S402-S408 are similar to steps S100-S106, and will not be repeated in this embodiment.
- the system has good scalability.
- FIG. 5 shows a schematic diagram of program modules of an inter-database data synchronization system 500 (hereinafter referred to as "synchronization system” 500) according to an embodiment of the present application.
- the synchronization system 500 may include or be divided into one or more program modules, and the one or more program modules are stored in a storage medium and executed by one or more processors to complete the application , And can realize the above-mentioned data synchronization method between databases.
- the program module referred to in the embodiments of the present application refers to an instruction segment of a series of computer-readable instructions capable of completing specific functions, and is more suitable for describing the execution process of the data synchronization method between databases in the storage medium than the program itself. The following description will specifically introduce the functions of each program module in this embodiment:
- the obtaining module 501 is configured to obtain a data operation instruction, and parse the data operation instruction to obtain a table name of a data table included in the data operation instruction, and the data operation instruction is an instruction based on a SQL statement.
- the obtaining module 501 may obtain a data operation instruction sent by a user equipment, and the data operation instruction may include a data addition instruction, a data deletion instruction, a data modification instruction, and so on. After receiving the data operation instruction, the acquisition module 501 may further execute data processing services according to the data operation instructions.
- the data processing services may include data addition services, data deletion services, data modification services, etc., to the database. For example, if the data operation instruction is a data modification instruction, the acquisition module 501 modifies the corresponding data in the database according to the data modification instruction.
- the acquisition module 501 can also parse the data operation instruction to obtain the data table information involved in the data operation instruction.
- the data table information includes the table of the data table. name.
- the data operation instruction in the embodiment of the present application is an instruction based on a SQL (Structured Query Language) statement, that is, the data operation instruction is an SQL statement.
- SQL Structured Query Language
- the step of obtaining the data operation instruction and analyzing the data operation instruction to obtain the table name of the data table included in the data operation instruction includes: checking all the data through the mybtis interceptor. The data operation instruction is intercepted, and the SQL statement in the data operation instruction is obtained; and used to parse the SQL statement to extract the table name of the data table contained in the SQL statement.
- the acquisition module 501 can call the mybtis interceptor to intercept the data operation instruction, thereby capturing the SQL statement in the data operation instruction. After the SQL statement is captured, the SQL statement can be further parsed to extract the SQL statement The data table information in the data table information contains the table name of the data table.
- the mybtis interceptor when the table name of the data table contained in the data operation instruction does not need to be obtained, the mybtis interceptor can be shielded.
- the judging module 502 is configured to judge whether there is a data table matching the table name in the preset synchronization record table.
- the synchronization record table is a data table that needs to be synchronized in each data table of the source database.
- the synchronization record table can be set according to business requirements. For example, if the current business requirement is to synchronize the modified data in data table A and data table B in the source database, the synchronization record table can be set to include Data table A and data table B, that is, only the modified data in data table A and data table B need to be synchronized in the future, and the data in other data tables does not need to be synchronized; if the current business requirement is to synchronize the source database , You can set the synchronization record table to include all data tables in the source database, that is, as long as the data in the source database is modified subsequently, the modified data must be synchronized.
- the obtained table name and the table name of each data table contained in the synchronization record table can be compared with the obtained table name one by one to determine whether the synchronization record table exists and The data table whose table name matches.
- the recording module 503 is configured to record the incremental data generated by the data processing service executed according to the data operation instruction when there is a data table matching the table name.
- the recording module 503 needs to record the incremental data generated by the data processing service executed according to the data operation instruction.
- the incremental data includes the SQL statement corresponding to the data operation instruction and the data table information, database information, etc. involved in the SQL statement.
- the synchronization module 504 is configured to periodically synchronize the incremental data to the target database.
- the synchronization module 504 periodically synchronizes the incremental data to the target database, for example, synchronizes all the incremental data to the target database every 1 minute.
- the target database is the database to which the data in the source database is to be synchronized, and there may be multiple target databases, for example, database A, database B, database C, etc.
- the SQL statement contained in the incremental data can be executed in the target database, thereby achieving data synchronization.
- the address of the target database needs to be maintained in the source database in advance.
- the data synchronization system between databases proposed in this embodiment of the application obtains the data operation instruction and parses the data operation instruction to obtain the table name of the data table included in the data operation instruction. It is an instruction based on SQL statement; it is determined whether there is a data table matching the table name in the preset synchronization record table; if it exists, it records the incremental data generated by the data processing service executed according to the data operation instruction ; And regularly synchronize the incremental data to the target database, which can increase the scalability of the system and reduce development costs.
- the step of periodically synchronizing the incremental data to the target database includes:
- Step 1 Determine the incremental data that currently needs to be synchronized.
- the incremental data recorded in this synchronization cycle is 15:12:10
- the time stamp of this synchronization cycle is 15:13:10, it is between 15:12:10 and 15:13:10
- the incremental data recorded in the time period is the incremental data that needs to be synchronized currently.
- Step 2 Obtain the first data table associated with each incremental data.
- each incremental data is associated with a first data table, and the first data table associated with different incremental data may be the same or different.
- Step 3 Determine the address information of the target database corresponding to each incremental data according to the first data table.
- each first data table may correspond to one target database, or may correspond to multiple target databases.
- data table a corresponds to target database B
- data table b corresponds to target database C and target database D, and so on.
- Step 4 Synchronize each incremental data to the corresponding target database according to the address information.
- the synchronization system can synchronize the incremental data to the corresponding target database through the address of the target server.
- the method further includes:
- the target database executes the SQL statement in the incremental data, thereby achieving data synchronization.
- the target database performs the data synchronization operation, it will feed back a data synchronization result to the synchronization system.
- the synchronization system parses the synchronization result, and then can determine that the target database is checking the data according to the parsed synchronization result Whether the data synchronization was successfully completed during synchronization.
- identification information for the incremental data that has been synchronized, such as setting the “complete” flag or the “1” flag to Indicates that the incremental data has completed data synchronization.
- the target database after the target database receives the incremental data, it continuously executes the SQL statement in the incremental data several times (for example, 3 times), and the data synchronization is still not achieved, then the synchronization can be fed back
- the failed synchronization result is sent to the synchronization system.
- the synchronization system After receiving the synchronization result, the synchronization system parses the synchronization result, and then can determine whether the target database successfully completes the data synchronization when synchronizing the data according to the parsed synchronization result.
- a notification message is sent to the preset user.
- the notification message can be sent by email or by SMS.
- the preset user is preferably a maintenance person of the target server.
- the synchronized incremental data when the data synchronization of the incremental data is successfully completed, the synchronized incremental data may be stored in the historical data table as a record. In this embodiment, by storing the successfully synchronized incremental data in the historical data table, it is convenient to troubleshoot the problem based on the data in the historical data table when a problem occurs later.
- the synchronization system 500 further includes:
- the setting module is used to set the data record range corresponding to the data processing service, and add the data record range to the synchronization record table.
- the data record range corresponding to the data processing service can be set according to business requirements, and the data record range is specifically which data tables in the source database need to be synchronized.
- the data recording range can be set in advance, or can be set later based on user input information. For example, if the user needs to synchronize the data table a in the source database, the user can input the information corresponding to the data table a into the setting module of the synchronization system. After receiving the input information, the setting module will use the input information Set the data recording range.
- FIG. 6 is a schematic diagram of the hardware architecture of a computer device 600 according to an embodiment of the present application.
- the computer device 600 is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions.
- the computer device 600 at least includes, but is not limited to, a memory 601, a processor 602, a network interface 603, and a data synchronization system 604 between databases that can communicate with each other through a system bus. among them:
- the memory 601 includes at least one type of non-volatile computer-readable storage medium.
- the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), Random access memory (RAM), static random access memory (SRAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), programmable read only memory (PROM), magnetic memory, magnetic disk, optical disk Wait.
- the memory 601 may be an internal storage unit of the computer device 600, such as a hard disk or memory of the computer device 600.
- the memory 601 may also be an external storage device of the computer device 600, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), and a secure digital (Secure Digital, SD) card, flash card (Flash Card), etc.
- the memory 601 may also include both the internal storage unit of the computer device 600 and its external storage device.
- the memory 601 is generally used to store the operating system and various application software installed in the computer device 600, such as the program code of the data synchronization system 604 between databases.
- the memory 601 can also be used to temporarily store various types of data that have been output or will be output.
- the processor 602 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments.
- the processor 602 is generally used to control the overall operation of the computer device 600.
- the processor 602 is configured to run the program code or process data stored in the memory 601, for example, to run the inter-database data synchronization system 604 to implement the inter-database data synchronization method in each of the foregoing embodiments.
- the network interface 603 may include a wireless network interface or a wired network interface, and the network interface 603 is generally used to establish a communication connection between the computer device 600 and other electronic devices.
- the network interface 603 is used to connect the computer device 600 to an external terminal through a network, and to establish a data transmission channel and a communication connection between the computer device 600 and the external terminal.
- the network may be an intranet (Intranet), the Internet (Internet), a global system of mobile communications (Global System of Mobile) communication, GSM), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), 4G network, 5G network, Bluetooth (Bluetooth), Wi-Fi and other wireless or wired networks.
- FIG. 6 only shows a computer device 600 with components 601-604, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
- the inter-database data synchronization system 604 stored in the memory 601 can also be divided into one or more program modules, and the one or more program modules are stored in the memory 601 and consist of one Or executed by multiple processors (processor 602 in this embodiment) to complete the data synchronization method between databases of this application.
- This embodiment also provides a non-volatile computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory ( SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, server, App application mall, etc., on which storage There are computer-readable instructions, and the corresponding functions are realized when the program is executed by the processor.
- the non-volatile computer-readable storage medium of this embodiment is used to store the inter-database data synchronization system 500 or 604, so as to implement the following steps when executed by a processor:
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请实施例提供了一种数据库间数据同步方法,包括以下步骤:通过获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库。本申请实施例还提供了数据库间数据同步系统、计算机设备和非易失性计算机可存储介质。本申请实施例能够增加系统的可扩展性,降低开发成本。
Description
本申请要求于2019年6月14日提交中国专利局、申请号为201910513290.2、发明名称为“数据库间数据同步方法、系统、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请实施例涉及数据处理技术领域,尤其涉及一种数据库间数据同步方法、系统、计算机设备及存储介质。
现有技术中,在实现各个系统之间数据同步时,一般是通过定制开发系统间要同步的表的来实现系统之间的同步。然而,发明人意识到当某个系统需要同多个其他系统进行数据同步时,则需要定制开发多个系统间要同步的表来实现该系统与多个系统之间的数据同步,该实现方法繁琐,灵活度不够。
发明内容
有鉴于此,本申请实施例的目的是提供一种数据库间数据同步方法、系统、计算机设备及非易失性计算机可读存储介质,能够增加系统的可扩展性,降低开发成本。
为实现上述目的,本申请实施例提供了一种数据库间数据同步方法,包括以下步骤:
获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;
判断预设的同步记录表中是否存在与所述表名相匹配的数据表;
若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及
定时将所述增量数据同步至目标数据库。
为实现上述目的,本申请实施例还提供了一种计算机设备,包括存储器、处理器以及存储在存储器上并可在处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如上所述数据库间数据同步方法的步骤。
为实现上述目的,本申请实施例还提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质内存储有计算机可读指令,所述计算机可读指令可被至少一个处理器所执行,以使所述至少一个处理器执行如上所述的数据库间数据同步方法的步骤。
本申请实施例提供的数据库间数据同步方法、系统、计算机设备及非易失性计算机可读存储介质,通过获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库,从而能够增加系统的可扩展性,降低开发成本。
图1为本申请数据库间数据同步方法第一实施例的实施流程示意图。
图2为本申请中获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名的步骤细化流程示意图。
图3为本申请中定时将所述增量数据同步至目标数据库的步骤的细化流程示意图。
图4为本申请数据库间数据同步方法第二实施例的实施流程示意图。
图5为本申请一实施方式的数据库间数据同步系统的程序模块示意图。
图6为本申请一实施方式的计算机设备的硬件结构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
参阅图1,示出了本申请实施例一之数据库间数据同步方法的流程图。可以理解,本方法实施例中的流程图不用于对执行步骤的顺序进行限定。下面以数据库间数据同步系统(下文以“同步系统”简称)为执行主体进行示例性描述,所述同步系统可以应用于计算机设备中。具体如下:
步骤S100,获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令。
具体地,同步系统可以获取用户设备发送的数据操作指令,所述数据操作指令可以包括数据新增指令、数据删除指令、数据修改指令等等。同步系统在接收到数据操作指令之后,可进一步根据所述数据操作指令执行数据处理业务,所述数据处理业务可以包括对数据库进行数据新增业务、数据删除业务、数据修改业务等。例如,若所述数据操作指令为数据修改指令,则所述同步系统根据所述数据修改指令对数据库中的相应是数据进行修改。
在本实施例中,同步系统在接收到数据操作指令之后,也可以对数据操作指令进行解析,从而得到该数据操作指令中所涉及的数据表信息,所述数据表信息包括数据表的表名。
需要说明的是,本申请实施例中的数据操作指令是基于SQL(Structured Query Language,结构化查询语言)语句的指令,即所述数据操作指令是一条SQL语句。
进一步地,参阅图2,在一实施例中,所述获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名的步骤包括:
步骤S200,通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及
步骤S202,对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
具体地,同步系统可以调用mybtis拦截器对数据操作指令进行拦截,从而捕获数据操作指令中的SQL语句,在捕获到SQL语句后,可以进一步对该SQL语句进行解析,从而提取出该SQL语句中所的数据表信息,该数据表信息中包含有数据表的表名。
在发明实施中,当不需要获取数据操作指令中包含的数据表的表名时,可以将该mybtis拦截器进行屏蔽。
步骤S102,判断预设的同步记录表中是否存在与所述表名相匹配的数据表。
具体地,所述同步记录表为源数据库的各个数据表中需要同步的数据表。该同步记录表可以根据业务需求进行设定,例如,当前业务需求为需要对源数据库中的数据表A与数据表B中被修改的数据进行同步,则可以设定所述同步记录表中包括数据表A与数据表B,即后续只需要对数据表A与数据表B中被修改的数据进行同步,对于其他数据表中的数据不需要同步;若当前业务需求为需要对源数据库进行同步,则可以设定所述同步记录表中包括源数据库中的所有数据表,即后续只要源数据库中的数据被修改,都要对修改的数据进行同步。
在具体地判断过程中,可以将获得到的表名与同步记录表中所包含的各个数据表的表名一一与该获得到的表名进行比较,以确定该同步记录表中是否存在与所述表名相匹配的数据表。
步骤S104,若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据。
具体地,当存在与所述表名相匹配的数据表时,表明需要对该数据操作指令所执行的数据处理业务进行同步。因而,在当存在与所述表名相匹配的数据表时,同步系统需要记录根据所述数据操作指令执行的数据处理业务所生成的增量数据。所述增量数据包括所述数据操作指令所对应的SQL语句以及该SQL语句所涉及到的数据表信息、数据库信息等。
步骤S106,定时将所述增量数据同步至目标数据库。
具体地,同步系统定时会将增量数据同步至目标数据库,比如,每隔1分钟将所有的增量数据同步至目标数据库中。所述目标数据库为要将源数据库中的数据同步至其中的数据库,该目标数据库可以有多个,比如,数据库A、数据库B,数据库C等。
在本实施例中,在对增量数据进行同步时,可以在目标数据库中执行该增量数据中所包含的SQL语句,从而实现数据的同步。
可以理解的是,为了将源数据中的增量数据同步至目标数据库中,需要预先将目标数据库的地址维护到源数据库中。
本申请本实施例所提出的数据库间数据同步方法,通过获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库,从而能够增加系统的可扩展性,降低开发成本。
进一步地,参照图3,在一实施例中,所述定时将所述增量数据同步至目标数据库的步骤包括:
步骤S300,确定当前需要同步的增量数据。
具体地,由于在对增量数据进行同步时,是定时执行的,因此,在进行数据同步之前,需要确定本次同步周期中所记录的增量数据,本次同步周期所记录的增量数据为在上一个同步周期的时间戳到本次同步周期的时间戳之间所记录的增量数据。比如,上一个同步周期的时间戳为15时12分10秒,本次同步周期的时间戳为15时13分10秒,则在15时12分10秒以及15时13分10秒这之间的时间段所记录的增量数据即为当前需要同步的增量数据。
步骤S302,获取每个增量数据所关联的第一数据表。
具体地,每个增量数据中都关联有一个第一数据表,不同的增量数据关联的第一数据表可能相同,也可能不同。
步骤S304,根据所述第一数据表确定所述每个增量数据对应的目标数据库的地址信息。
具体地,在同步系统中预存有各个第一数据表与目标数据库的映射表,该映射表中包括各个第一数据表与目标数据库的对应关系,以及各个目标数据库的地址信息,所述地址信息包括所述目标服务器的IP地址、端口号等。在本实施例中,每个第一数据表可以和一个目标数据库相对应,也可以与多个目标数据库相对应。例如,数据表a与目标数据库B相对应,数据表b与目标数据库C与目标数据库D相对应等。
步骤S306,根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中。
具体地,同步系统在获取到该地址信息后,即可通过该目标服务器的地址将增量数据同步至对应的所述目标数据库中。
进一步地,在一实施方式中,所述根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中的步骤之后,还包括:
接收对应的所述目标数据库返回的数据同步结果;及
若所述数据同步结果为同步成功,则对已同步的增量数据设置对应的标识。
具体地,目标数据库在接收到增量数据之后,执行该增量数据中的SQL语句,从而实现数据的同步。目标数据库在执行数据同步操作之后,会给同步系统反馈一个数据同步结果,同步系统在接收到该同步结果之后,对该同步结果进行解析,进而可以根据解析后的同步结果确定目标数据库在对数据进行同步时是否成功的完成数据的同步,在确定该数据同步结果为同步成功时,可以对已完成同步的增量数据设置标识信息,比如设置“完成”标识,或者设置“1”标识,以表明该增量数据已完成数据的同步。在本实施例中,通过设置对应的标识,从而可以避免对同一个曾量数据进行多次重复的同步操作。
在本申请另一实施方式中,当目标数据库在接收到增量数据之后,连续执行该增量数据中的SQL语句若干次(比如3次)后,仍未实现数据的同步,则可以反馈同步失败的同步结果给同步系统,同步系统在接收到该同步结果之后,对该同步结果进行解析,进而可以根据解析后的同步结果确定目标数据库在对数据进行同步时是否成功的完成数据的同步,在确定该数据同步结果为同步失败时,发送通知消息至预设用户。该通知消息可以通过邮件的方式发送,也可以通过短信的方式发送等。该预设用户优选为目标服务器的维护人员。
进一步地,在另一实施方式中,在对增量数据成功完成数据同步时,可以将同步的增量数据存储至历史数据表中,以作为记录。在本实施例中,通过将同步成功的增量数据存储至历史数据表中,可以方便后续出现问题时,根据该历史数据表中的数据对问题进行排查。
参阅图4,是本申请数据库间数据同步方法第二实施例的实施流程示意图。在本实施例中,根据不同的需求,图4所示的流程图中的步骤的执行顺序可以改变,某些步骤可以省略。下面以数据库间数据同步系统(下文以“同步系统”简称)为执行主体进行示例性描述,所述同步系统可以应用于服务器中。具体如下:
步骤S400,设置与所述数据处理业务对应的数据记录范围,并将所述数据记录范围添加至所述同步记录表中。
具体地,可以根据业务需求设置数据处理业务对应的数据记录范围,所述数据记录范围为具体需对该源数据库中的哪些数据表进行同步。该数据记录范围可以预先设定,也可以在后期根据用户的输入信息进行设定。例如,若用户需要对源数据库中的数据表a进行同步,则用户可以将所述数据表a对应的信息输入至同步系统,同步系统在接收到该输入信息后,根据该输入信息设置所述数据记录范围。
在设置好该数据记录范围之后,将即该数据记录范围添加至同步记录表中。
步骤S402,获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令。
步骤S404,判断预设的同步记录表中是否存在与所述表名相匹配的数据表;
步骤S406,若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据。
步骤S408,定时将所述增量数据同步至目标数据库。
上述步骤S402-S408与步骤S100-S106类似,在本实施方式中不再赘述。
本申请实施例所提出的数据库间数据同步方法,通过设置与所述数据处理业务对应的数据记录范围,从而使得系统具有很好的扩展性。
请参阅图5,示出了本申请实施例之数据库间数据同步系统500(以下简称为“同步系统”500)的程序模块示意图。在本实施例中,同步系统500可以包括或被分割成一个或多个程序模块,一个或者多个程序模块被存储于存储介质中,并由一个或多个处理器所执行,以完成本申请,并可实现上述数据库间数据同步方法。本申请实施例所称的程序模块是指能够完成特定功能的一系列计算机可读指令的指令段,比程序本身更适合于描述数据库间数据同步方法在存储介质中的执行过程。以下描述将具体介绍本实施例各程序模块的功能:
获取模块501,用于获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令。
具体地,获取模块501可以获取用户设备发送的数据操作指令,所述数据操作指令可以包括数据新增指令、数据删除指令、数据修改指令等等。获取模块501在接收到数据操作指令之后,可进一步根据所述数据操作指令执行数据处理业务,所述数据处理业务可以包括对数据库进行数据新增业务、数据删除业务、数据修改业务等。例如,若所述数据操作指令为数据修改指令,则所述获取模块501根据所述数据修改指令对数据库中的相应是数据进行修改。
在本实施例中,获取模块501在接收到数据操作指令之后,也可以对数据操作指令进行解析,从而得到该数据操作指令中所涉及的数据表信息,所述数据表信息包括数据表的表名。
需要说明的是,本申请实施例中的数据操作指令是基于SQL(Structured Query Language,结构化查询语言)语句的指令,即所述数据操作指令是一条SQL语句。
进一步地,在一实施例中,所述获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名的步骤包括:通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及用于对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
具体地,获取模块501可以调用mybtis拦截器对数据操作指令进行拦截,从而捕获数据操作指令中的SQL语句,在捕获到SQL语句后,可以进一步对该SQL语句进行解析,从而提取出该SQL语句中所的数据表信息,该数据表信息中包含有数据表的表名。
在发明实施中,当不需要获取数据操作指令中包含的数据表的表名时,可以将该mybtis拦截器进行屏蔽。
判断模块502,用于判断预设的同步记录表中是否存在与所述表名相匹配的数据表。
具体地,所述同步记录表为源数据库的各个数据表中需要同步的数据表。该同步记录表可以根据业务需求进行设定,例如,当前业务需求为需要对源数据库中的数据表A与数据表B中被修改的数据进行同步,则可以设定所述同步记录表中包括数据表A与数据表B,即后续只需要对数据表A与数据表B中被修改的数据进行同步,对于其他数据表中的数据不需要同步;若当前业务需求为需要对源数据库进行同步,则可以设定所述同步记录表中包括源数据库中的所有数据表,即后续只要源数据库中的数据被修改,都要对修改的数据进行同步。
在具体地判断过程中,可以将获得到的表名与同步记录表中所包含的各个数据表的表名一一与该获得到的表名进行比较,以确定该同步记录表中是否存在与所述表名相匹配的数据表。
记录模块503,用于当存在与所述表名相匹配的数据表时,记录根据所述数据操作指令执行的数据处理业务所生成的增量数据。
具体地,当存在与所述表名相匹配的数据表时,表明需要对该数据操作指令所执行的数据处理业务进行同步。因而,在当存在与所述表名相匹配的数据表时,记录模块503需要记录根据所述数据操作指令执行的数据处理业务所生成的增量数据。所述增量数据包括所述数据操作指令所对应的SQL语句以及该SQL语句所涉及到的数据表信息、数据库信息等。
同步模块504,用于定时将所述增量数据同步至目标数据库。
具体地,同步模块504定时会将增量数据同步至目标数据库,比如,每隔1分钟将所有的增量数据同步至目标数据库中。所述目标数据库为要将源数据库中的数据同步至其中的数据库,该目标数据库可以有多个,比如,数据库A、数据库B,数据库C等。
在本实施例中,在对增量数据进行同步时,可以在目标数据库中执行该增量数据中所包含的SQL语句,从而实现数据的同步。
可以理解的是,为了将源数据中的增量数据同步至目标数据库中,需要预先将目标数据库的地址维护到源数据库中。
本申请本实施例所提出的数据库间数据同步系统,通过获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库,从而能够增加系统的可扩展性,降低开发成本。
进一步地,在一实施方式中,所述定时将所述增量数据同步至目标数据库的步骤包括:
步骤1,确定当前需要同步的增量数据。
具体地,由于在对增量数据进行同步时,是定时执行的,因此,在进行数据同步之前,需要确定本次同步周期中所记录的增量数据,本次同步周期所记录的增量数据为在上一个同步周期的时间戳到本次同步周期的时间戳之间所记录的增量数据。比如,上一个同步周期的时间戳为15时12分10秒,本次同步周期的时间戳为15时13分10秒,则在15时12分10秒以及15时13分10秒这之间的时间段所记录的增量数据即为当前需要同步的增量数据。
步骤2,获取每个增量数据所关联的第一数据表。
具体地,每个增量数据中都关联有一个第一数据表,不同的增量数据关联的第一数据表可能相同,也可能不同。
步骤3,根据所述第一数据表确定所述每个增量数据对应的目标数据库的地址信息。
具体地,在同步系统中预存有各个第一数据表与目标数据库的映射表,该映射表中包括各个第一数据表与目标数据库的对应关系,以及各个目标数据库的地址信息,所述地址信息包括所述目标服务器的IP地址、端口号等。在本实施例中,每个第一数据表可以和一个目标数据库相对应,也可以与多个目标数据库相对应。例如,数据表a与目标数据库B相对应,数据表b与目标数据库C与目标数据库D相对应等。
步骤4,根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中。
具体地,同步系统在获取到该地址信息后,即可通过该目标服务器的地址将增量数据同步至对应的所述目标数据库中。
进一步地,在一实施方式中,所述根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中的步骤之后,还包括:
接收对应的所述目标数据库返回的数据同步结果;及
若所述数据同步结果为同步成功,则对已同步的增量数据设置对应的标识。
具体地,目标数据库在接收到增量数据之后,执行该增量数据中的SQL语句,从而实现数据的同步。目标数据库在执行数据同步操作之后,会给同步系统反馈一个数据同步结果,同步系统在接收到该同步结果之后,对该同步结果进行解析,进而可以根据解析后的同步结果确定目标数据库在对数据进行同步时是否成功的完成数据的同步,在确定该数据同步结果为同步成功时,可以对已完成同步的增量数据设置标识信息,比如设置“完成”标识,或者设置“1”标识,以表明该增量数据已完成数据的同步。在本实施例中,通过设置对应的标识,从而可以避免对同一个曾量数据进行多次重复的同步操作。
在本申请另一实施方式中,当目标数据库在接收到增量数据之后,连续执行该增量数据中的SQL语句若干次(比如3次)后,仍未实现数据的同步,则可以反馈同步失败的同步结果给同步系统,同步系统在接收到该同步结果之后,对该同步结果进行解析,进而可以根据解析后的同步结果确定目标数据库在对数据进行同步时是否成功的完成数据的同步,在确定该数据同步结果为同步失败时,发送通知消息至预设用户。该通知消息可以通过邮件的方式发送,也可以通过短信的方式发送等。该预设用户优选为目标服务器的维护人员。
进一步地,在另一实施方式中,在对增量数据成功完成数据同步时,可以将同步的增量数据存储至历史数据表中,以作为记录。在本实施例中,通过将同步成功的增量数据存储至历史数据表中,可以方便后续出现问题时,根据该历史数据表中的数据对问题进行排查。
在本申请另一实施方式中,所述同步系统500还包括:
设置模块,用于设置与所述数据处理业务对应的数据记录范围,并将所述数据记录范围添加至所述同步记录表中。
具体地,可以根据业务需求设置数据处理业务对应的数据记录范围,所述数据记录范围为具体需对该源数据库中的哪些数据表进行同步。该数据记录范围可以预先设定,也可以在后期根据用户的输入信息进行设定。例如,若用户需要对源数据库中的数据表a进行同步,则用户可以将所述数据表a对应的信息输入至同步系统的设置模块,设置模块在接收到该输入信息后,根据该输入信息设置所述数据记录范围。
在设置好该数据记录范围之后,将即该数据记录范围添加至同步记录表中。
参阅图6,是本申请实施例之计算机设备600的硬件架构示意图。在本实施例中,所述计算机设备600是一种能够按照事先设定或者存储的指令,自动进行数值计算和/或信息处理的设备。如图所示,所述计算机设备600至少包括,但不限于,可通过系统总线相互通信连接存储器601、处理器602、网络接口603、以及数据库间数据同步系统604。其中:
本实施例中,存储器601至少包括一种类型的非易失性计算机可读存储介质,所述可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等。在一些实施例中,存储器601可以是计算机设备600的内部存储单元,例如该计算机设备600的硬盘或内存。在另一些实施例中,存储器601也可以是计算机设备600的外部存储设备,例如该计算机设备600上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。当然,存储器601还可以既包括计算机设备600的内部存储单元也包括其外部存储设备。本实施例中,存储器601通常用于存储安装于计算机设备600的操作系统和各类应用软件,例如数据库间数据同步系统604的程序代码等。此外,存储器601还可以用于暂时地存储已经输出或者将要输出的各类数据。
处理器602在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器602通常用于控制计算机设备600的总体操作。本实施例中,处理器602用于运行存储器601中存储的程序代码或者处理数据,例如运行数据库间数据同步系统604,以实现上述各个实施例中的数据库间数据同步方法。
所述网络接口603可包括无线网络接口或有线网络接口,该网络接口603通常用于在所述计算机设备600与其他电子装置之间建立通信连接。例如,所述网络接口603用于通过网络将所述计算机设备600与外部终端相连,在所述计算机设备600与外部终端之间的建立数据传输通道和通信连接等。所述网络可以是企业内部网(Intranet)、互联网(Internet)、全球移动通讯系统(Global System of Mobile
communication,GSM)、宽带码分多址(Wideband Code Division Multiple
Access,WCDMA)、4G网络、5G网络、蓝牙(Bluetooth)、Wi-Fi等无线或有线网络。
需要指出的是,图6仅示出了具有部件601-604的计算机设备600,但是应理解的是,并不要求实施所有示出的部件,可以替代的实施更多或者更少的部件。
在本实施例中,存储于存储器601中的所述数据库间数据同步系统604还可以被分割为一个或者多个程序模块,所述一个或者多个程序模块被存储于存储器601中,并由一个或多个处理器(本实施例为处理器602)所执行,以完成本申请之数据库间数据同步方法。
本实施例还提供一种非易失性计算机可读存储介质,如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘、服务器、App应用商城等等,其上存储有计算机可读指令,程序被处理器执行时实现相应功能。本实施例的非易失性计算机可读存储介质用于存储数据库间数据同步系统500或604,以被处理器执行时实现如下步骤:
获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;
判断预设的同步记录表中是否存在与所述表名相匹配的数据表;
若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及
定时将所述增量数据同步至目标数据库。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。
Claims (20)
- 一种数据库间数据同步方法,包括以下步骤:获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库。
- 如权利要求1所述的数据库间数据同步方法,所述数据库间数据同步方法还包括:设置与所述数据处理业务对应的数据记录范围,并将所述数据记录范围添加至所述同步记录表中。
- 如权利要求 1所述的数据库间数据同步方法,所述获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名的步骤包括:通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
- 如权利要求 2所述的数据库间数据同步方法,所述获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名的步骤包括:通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
- 如权利要求1所述的数据库间数据同步方法,所述定时将所述增量数据同步至目标数据库的步骤包括:确定当前需要同步的增量数据;获取每个增量数据所关联的第一数据表;根据所述第一数据表确定所述每个增量数据对应的目标数据库的地址信息;及根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中。
- 如权利要求2所述的数据库间数据同步方法,所述定时将所述增量数据同步至目标数据库的步骤包括:确定当前需要同步的增量数据;获取每个增量数据所关联的第一数据表;根据所述第一数据表确定所述每个增量数据对应的目标数据库的地址信息;及根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中。
- 如权利要求5所述的数据库间数据同步方法,所述根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中的步骤之后,还包括:接收对应的所述目标数据库返回的数据同步结果;及若所述数据同步结果为同步成功,则对已同步的增量数据设置对应的标识。
- 如权利要求6所述的数据库间数据同步方法,所述根据所述地址信息将所述每个增量数据同步至对应的所述目标数据库中的步骤之后,还包括:接收对应的所述目标数据库返回的数据同步结果;及若所述数据同步结果为同步成功,则对已同步的增量数据设置对应的标识。
- 如权利要求7所述的数据库间数据同步方法,所述接收对应的所述目标数据库返回的数据同步结果的步骤之后,还包括:若所述数据同步结果为同步失败,则发送通知消息至预设用户。
- 如权利要求8所述的数据库间数据同步方法,所述接收对应的所述目标数据库返回的数据同步结果的步骤之后,还包括:若所述数据同步结果为同步失败,则发送通知消息至预设用户。
- 如权利要求7所述的数据库间数据同步方法,所述数据库间数据同步方法还包括:将已同步的增量数据存储至历史数据表中。
- 如权利要求8所述的数据库间数据同步方法,所述数据库间数据同步方法还包括:将已同步的增量数据存储至历史数据表中。
- 一种数据库间数据同步系统,包括:获取模块,用于获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断模块,用于判断预设的同步记录表中是否存在与所述表名相匹配的数据表;记录模块,用于若存在与所述表名相匹配的数据表,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及同步模块,用于定时将所述增量数据同步至目标数据库。
- 如权利要求13所述的数据库间数据同步系统,所述数据库间数据同步系统还包括:设置模块,用于设置与所述数据处理业务对应的数据记录范围,并将所述数据记录范围添加至所述同步记录表中。
- 如权利要求13所述的数据库间数据同步系统,所述获取模块,还用于通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及用于对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
- 如权利要求14所述的数据库间数据同步系统,所述获取模块,还用于通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及用于对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
- 一种计算机设备,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时执行以下步骤:获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库。
- 如权利要求17所述的计算机设备,所述处理器执行所述计算机可读指令时还执行以下步骤:设置与所述数据处理业务对应的数据记录范围,并将所述数据记录范围添加至所述同步记录表中。
- 如权利要求17所述的计算机设备,所述处理器执行所述计算机可读指令时还执行以下步骤:通过mybtis拦截器对所述数据操作指令进行拦截,并获取所述数据操作指令中的SQL语句;及对所述SQL语句进行解析,以提取出所述SQL语句中所包含的数据表的表名。
- 一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可读指令,所述计算机可读指令可被至少一个处理器执行,以使所述至少一个处理器执行以下步骤:获取数据操作指令,并对所述数据操作指令进行解析以得到所述数据操作指令中包含的数据表的表名,所述数据操作指令为基于SQL语句的指令;判断预设的同步记录表中是否存在与所述表名相匹配的数据表;若存在,则记录根据所述数据操作指令执行的数据处理业务所生成的增量数据;及定时将所述增量数据同步至目标数据库。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910513290.2 | 2019-06-14 | ||
| CN201910513290.2A CN110347747A (zh) | 2019-06-14 | 2019-06-14 | 数据库间数据同步方法、系统、计算机设备及存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020248375A1 true WO2020248375A1 (zh) | 2020-12-17 |
Family
ID=68181979
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/102843 Ceased WO2020248375A1 (zh) | 2019-06-14 | 2019-08-27 | 数据库间数据同步方法、系统、计算机设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN110347747A (zh) |
| WO (1) | WO2020248375A1 (zh) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115269419A (zh) * | 2022-08-02 | 2022-11-01 | 中银金融科技有限公司 | 一种数据存储过程的调试方法、装置及电子设备 |
| CN115878721A (zh) * | 2021-08-13 | 2023-03-31 | 漳州立达信光电子科技有限公司 | 一种数据同步方法、装置、终端和计算机可读存储介质 |
Families Citing this family (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111309742A (zh) * | 2020-01-20 | 2020-06-19 | 深圳壹账通智能科技有限公司 | 数据同步方法、装置、计算机设备及存储介质 |
| CN111400397B (zh) * | 2020-02-29 | 2023-04-11 | 平安科技(深圳)有限公司 | 数据同步方法、装置、设备和计算机存储介质 |
| CN111324614B (zh) * | 2020-03-18 | 2023-07-28 | 浩云科技股份有限公司 | 一种表的配置方法、装置、终端设备以及存储介质 |
| CN112015738A (zh) * | 2020-08-28 | 2020-12-01 | 支付宝(杭州)信息技术有限公司 | 用于实现多个数据明细表的联表处理的方法及装置 |
| CN112069194B (zh) * | 2020-08-31 | 2024-07-19 | 杭州铁驰云商科技有限公司 | 一种对数据库中数据的实时修改方法及系统 |
| CN112612797B (zh) * | 2020-12-30 | 2022-08-23 | 杭州拼便宜网络科技有限公司 | 多源同表数据加载方法、装置、设备及介质 |
| CN112559638B (zh) * | 2021-02-20 | 2021-05-07 | 恒生电子股份有限公司 | 数据同步的方法、装置、设备和存储介质 |
| CN113918648B (zh) * | 2021-09-24 | 2026-02-17 | 杭州数美科技有限公司 | 数据同步方法、装置、电子设备及存储介质 |
| CN114238523A (zh) * | 2021-12-17 | 2022-03-25 | 蚂蚁区块链科技(上海)有限公司 | 数据同步方法和装置 |
| CN115952172B (zh) * | 2023-03-08 | 2023-05-26 | 畅捷通信息技术股份有限公司 | 一种基于数据库临时表的数据匹配方法及装置 |
| CN116932649A (zh) * | 2023-07-20 | 2023-10-24 | 招商银行股份有限公司 | 数据库同步方法、数据库同步设备以及可读存储介质 |
| CN119311695B (zh) * | 2024-12-13 | 2025-04-08 | 天翼云科技有限公司 | 增量同步的校验方法、装置、计算机设备、可读存储介质 |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105912949A (zh) * | 2016-04-13 | 2016-08-31 | 北京京东尚科信息技术有限公司 | 数据权限管理方法、数据权限管理系统以及业务管理系统 |
| CN106294075A (zh) * | 2016-08-17 | 2017-01-04 | 浪潮软件股份有限公司 | 一种对sql进行监控的方法、装置及系统 |
| CN108205560A (zh) * | 2016-12-19 | 2018-06-26 | 腾讯科技(深圳)有限公司 | 一种数据同步方法以及装置 |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US10545943B2 (en) * | 2016-04-05 | 2020-01-28 | International Business Machines Corporation | Change stream analytics for data replication systems |
| CN108595522A (zh) * | 2018-03-27 | 2018-09-28 | 北京明朝万达科技股份有限公司 | 一种增量同步方法、装置及系统 |
| CN108769212B (zh) * | 2018-05-31 | 2023-04-07 | 康键信息技术(深圳)有限公司 | 数据同步方法、装置、计算机设备和存储介质 |
-
2019
- 2019-06-14 CN CN201910513290.2A patent/CN110347747A/zh active Pending
- 2019-08-27 WO PCT/CN2019/102843 patent/WO2020248375A1/zh not_active Ceased
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105912949A (zh) * | 2016-04-13 | 2016-08-31 | 北京京东尚科信息技术有限公司 | 数据权限管理方法、数据权限管理系统以及业务管理系统 |
| CN106294075A (zh) * | 2016-08-17 | 2017-01-04 | 浪潮软件股份有限公司 | 一种对sql进行监控的方法、装置及系统 |
| CN108205560A (zh) * | 2016-12-19 | 2018-06-26 | 腾讯科技(深圳)有限公司 | 一种数据同步方法以及装置 |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115878721A (zh) * | 2021-08-13 | 2023-03-31 | 漳州立达信光电子科技有限公司 | 一种数据同步方法、装置、终端和计算机可读存储介质 |
| CN115269419A (zh) * | 2022-08-02 | 2022-11-01 | 中银金融科技有限公司 | 一种数据存储过程的调试方法、装置及电子设备 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN110347747A (zh) | 2019-10-18 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020248375A1 (zh) | 数据库间数据同步方法、系统、计算机设备及存储介质 | |
| CN109474578B (zh) | 报文消息校验方法、装置、计算机设备和存储介质 | |
| CN109525990B (zh) | 无线投屏方法、装置、计算机设备和存储介质 | |
| CN111459954A (zh) | 分布式数据同步方法、装置、设备及介质 | |
| WO2019051948A1 (zh) | 监控数据的处理方法、设备、服务器及存储介质 | |
| WO2022142153A1 (zh) | 电表升级方法、系统、智能电表及存储介质 | |
| US20130152069A1 (en) | Method, apparatus and system for initiating terminal operation | |
| CN110597918A (zh) | 一种账户管理方法、装置及计算机可读存储介质 | |
| WO2020151181A1 (zh) | 基于区块链的跨平台数据更新方法、装置和计算机设备 | |
| CN110932918B (zh) | 日志数据采集方法、装置及存储介质 | |
| CN111177776A (zh) | 多租户数据隔离方法与系统 | |
| US20150350299A1 (en) | Method and apparatus for providing secure file transmission | |
| CN113204558A (zh) | 数据表结构自动更新方法和装置 | |
| WO2022179353A1 (zh) | 域名解析方法、装置及计算机设备 | |
| CN111158711A (zh) | 面向多个安卓系统终端的应用程序部署方法和设备 | |
| WO2016074412A1 (zh) | 基于网络配置协议进行兼容管理的方法、存储介质及设备 | |
| CN113986996B (zh) | 基于注解自定义返回响应方法、装置、设备和存储介质 | |
| CN115510366A (zh) | 业务消息推送方法、装置、计算机设备和存储介质 | |
| CN113076151B (zh) | 应用程序交互方法、装置、计算机设备及存储介质 | |
| CN110661850A (zh) | 一种边缘计算方法、系统、计算机设备和存储介质 | |
| CN117376300B (zh) | 一种消息全渠道发送方法、装置、电子设备及存储介质 | |
| CN117874033A (zh) | 数据库分表方法、装置、电子设备及存储介质 | |
| CN115391445A (zh) | 一种数据推送方法和相关装置 | |
| CN115941818A (zh) | 一种热加载工控协议解析和控制的方法及具有其的系统 | |
| CN116151530A (zh) | 数据处理方法及装置、数据处理系统及业务系统 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19933005 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19933005 Country of ref document: EP Kind code of ref document: A1 |