Method for supporting synchronization of databases of any type
By configuring database parameters and SQL differences, a standard converter is generated to achieve data synchronization between different types of databases, solving the problem of insufficient database synchronization scalability in the existing technology, improving synchronization efficiency and security, and reducing maintenance costs.
Patent Information
- Application Number
- CN202411461452.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-21
AI Technical Summary
The prior art is difficult to achieve efficient, accurate and secure data synchronization between different types of databases, and it is insufficient in scalability, so it requires frequent re-customized development, which increases costs.
By obtaining the parameter configuration files of the source database and the target database, configuring the mapping relationship and SQL differences of field types, generating a standard converter, executing SQL applicable to each database, obtaining data files, and comparing file differences, generating tasks to be synchronized, and completing Database synchronization.
It achieves efficient, accurate and secure data synchronization between different types of databases, improves scalability, is suitable for existing and future new databases, and reduces maintenance costs.
Smart Images

Figure CN119336847A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of databases, and in particular to a method for supporting synchronization of any type of databases. Background Art
[0002] The development of database technology will be directly related to the digital transformation of enterprises. However, there are many types of databases on the market, and domestic databases are developing rapidly. When conducting data analysis, data synchronization between different types of databases is often required. If there is a method that can support synchronization between any types of databases and is scalable, it can support upgraded versions of existing databases and be applicable to new databases that may appear on the market in the future. It will bring convenience to enterprises while ensuring accurate, efficient and secure data synchronization.
[0003] When synchronization between databases is required, when a new type of database is involved, there are two common existing technical solutions:
[0004] First analyze the new type of database, then manually write scripts or programs suitable for the new database to read the data from the source database and write it to the target database;
[0005] You can buy a synchronization tool suitable for a new database on the market. When another new database appears, you can only buy the appropriate synchronization tool again.
[0006] The disadvantages of the existing technology are: manual program writing is inefficient and has a high error rate, the database synchronization tool is complex to configure and has limitations in scalability. When the database version is updated or a new type of database is connected, both methods need to be customized and developed again, which increases the cost investment. Summary of the invention
[0007] In view of the above problems, the present invention is proposed to provide a method for supporting synchronization of any type of databases, which overcomes the above problems or at least partially solves the above problems.
[0008] According to one aspect of the present invention, a method for synchronizing a database of any type is provided, the method comprising:
[0009] Get the parameter configuration file of the source database;
[0010] Configure the mapping relationship between the field types applicable to the source database and the standard field types;
[0011] Get the parameter configuration file of the target database;
[0012] Configure the mapping relationship between the field types applicable to the target database and the standard field types;
[0013] After configuring the mapping relationship of field types and the difference of SQL, obtain the standard converter;
[0014] Execute the SQL applicable to the source database to obtain the data files of the source database;
[0015] Execute the SQL applicable to the target database to obtain the data file of the target database;
[0016] Compare the standard source data file and the standard target data file;
[0017] Complete synchronization between different types of databases.
[0018] Optionally, the obtaining of the parameter configuration file of the source database specifically includes: the type of the source database, the field type applicable to the source database, and the SQL applicable to the source database.
[0019] Optionally, the mapping relationship between the field type applicable to the configuration source database and the standard field type specifically includes:
[0020] Compare the differences between the SQL applicable to the source database and the standard SQL, adjust the differences, and form SQL applicable to the source database.
[0021] Optionally, the obtaining of the parameter configuration file of the target database specifically includes: the type of the target database, the field type applicable to the target database, and the SQL applicable to the target database.
[0022] Optionally, the mapping relationship between the field type applicable to the configured target database and the standard field type specifically includes:
[0023] Compare the differences between the SQL applicable to the target database and the standard SQL, adjust the differences, and form SQL applicable to the target database.
[0024] Optionally, executing SQL applicable to the source database to obtain the data file of the source database specifically includes:
[0025] The source data table, source field, and source field type are automatically converted into standard field types through a standard converter to generate a standard source data file.
[0026] Optionally, executing SQL applicable to the target database to obtain the data file of the target database specifically includes:
[0027] The target data table, target field, and target field type will be automatically converted to the standard field type through the standard converter to generate a standard target data file.
[0028] Optionally, after comparing the standard source data file and the standard target data file, the step further includes: when a difference occurs, generating a task to be synchronized.
[0029] Optionally, the synchronization between different types of databases specifically includes:
[0030] Execute the SQL applicable to the target database according to the task to be synchronized, modify the data files with differences in the target database, and complete the synchronization between different types of databases.
[0031] The present invention provides a method for synchronizing a database that supports any type of database, and the method comprises: obtaining a parameter configuration file of a source database; configuring a mapping relationship between a field type applicable to the source database and a standard field type; obtaining a parameter configuration file of a target database; configuring a mapping relationship between a field type applicable to the target database and a standard field type; after configuring the mapping relationship of the field type and the difference in SQL, obtaining a standard converter; executing SQL applicable to the source database to obtain a data file of the source database; executing SQL applicable to the target database to obtain a data file of the target database; comparing a standard source data file with a standard target data file; and completing synchronization between databases of different types.
[0032] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0034] Figure 1 A flowchart of a method for synchronizing a database of any type provided by an embodiment of the present invention;
[0035] Figure 2 A flow chart of a configuration standard converter provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0037] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.
[0038] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0039] The synchronization between different types of databases has the problems of inconsistent table structure field type standards and differences in structured query language (SQL). The present invention establishes a set of standardized field types, and maps the field types of various types of databases into unified standardized field types through parameter configuration. In addition, a set of standardized SQL is integrated according to international standards. This set of SQL specifications is applicable to most databases. Even if there are a few differences, they can be adjusted through configuration files to SQL applicable to the current database, thereby achieving synchronization between different types of databases.
[0040] like Figure 1 and Figure 2 As shown, a method for synchronizing databases of any type is supported, including:
[0041] (1) Obtain the parameter configuration file of the source database, which includes the type of the source database, the field type applicable to the source database, and the SQL applicable to the source database.
[0042] (2) Configure the mapping relationship between the field types applicable to the source database and the standard field types, compare the differences between the SQL applicable to the source database and the standard SQL, adjust the differences, and form SQL applicable to the source database.
[0043] (3) Obtain the parameter configuration file of the target database, which includes the type of the target database, the field type applicable to the target database, and the SQL applicable to the target database.
[0044] (4) Configure the mapping relationship between the field types applicable to the target database and the standard field types, compare the differences between the SQL applicable to the target database and the standard SQL, adjust the differences, and form SQL applicable to the target database.
[0045] (5) After configuring the mapping relationship between field types and the SQL differences, it is temporarily called the standard converter.
[0046] (6) Execute the SQL applicable to the source database to obtain the data file of the source database, including the source data table and source field. The source field type is automatically converted into the standard field type through the standard converter to generate a standard source data file.
[0047] (7) Execute the SQL applicable to the target database to obtain the data file of the target database, including the target data table and target field. The target field type will be automatically converted into the standard field type through the standard converter to generate a standard target data file.
[0048] (8) Compare the standard source data file and the standard target data file. When differences occur, generate tasks to be synchronized.
[0049] (9) Execute the SQL applicable to the target database according to the task to be synchronized, modify the data files that have differences in the target database, and complete the synchronization between different types of databases.
[0050] The field type mapping relationship and SQL applicable to commonly used databases (Oracle, MySql, DB2, SqlServer) are built-in, and there is no need to perform steps (1)(2)(3)(4). When a new type of database appears, the type of database can be built-in through the operations of steps (1)(2)(3)(4), thereby continuously expanding the types of built-in databases and achieving synchronization between any types of databases.
[0051] Beneficial effect: The scalability of the database synchronization method is improved to meet the needs of databases of different types and versions as well as new databases that may appear on the market in the future.
[0052] Simplify the configuration rules of database synchronization methods and reduce maintenance costs.
[0053] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for synchronizing a database of any type, characterized in that: The synchronization method comprises: Get the parameter configuration file of the source database; Configure the mapping relationship between the field types applicable to the source database and the standard field types; Get the parameter configuration file of the target database; Configure the mapping relationship between the field types applicable to the target database and the standard field types; After configuring the mapping relationship of field types and the difference of SQL, obtain the standard converter; Execute the SQL applicable to the source database to obtain the data files of the source database; Execute the SQL applicable to the target database to obtain the data file of the target database; Compare the standard source data file and the standard target data file; Complete synchronization between different types of databases.
2. A method for synchronizing a database of any type according to claim 1, characterized in that: The obtaining of the parameter configuration file of the source database specifically includes: the type of the source database, the field type applicable to the source database, and the SQL applicable to the source database.
3. A method for synchronizing a database of any type according to claim 1, characterized in that: The mapping relationship between the field types applicable to the configuration source database and the standard field types specifically includes: Compare the differences between the SQL applicable to the source database and the standard SQL, adjust the differences, and form SQL applicable to the source database.
4. A method for synchronizing a database of any type according to claim 1, characterized in that: The obtaining of the parameter configuration file of the target database specifically includes: the type of the target database, the field type applicable to the target database, and the SQL applicable to the target database.
5. A method for synchronizing a database of any type according to claim 1, characterized in that: The mapping relationship between the field types applicable to the configuration target database and the standard field types specifically includes: Compare the differences between the SQL applicable to the target database and the standard SQL, adjust the differences, and form SQL applicable to the target database.
6. A method for synchronizing a database of any type according to claim 1, characterized in that: The executing SQL applicable to the source database to obtain the data file of the source database specifically includes: The source data table, source field, and source field type are automatically converted into standard field types through a standard converter to generate a standard source data file.
7. A method for synchronizing databases of any type according to claim 1, characterized in that: The executing of the SQL applicable to the target database to obtain the data file of the target database specifically includes: The target data table, target field, and target field type will be automatically converted to the standard field type through the standard converter to generate a standard target data file.
8. A method for synchronizing a database of any type according to claim 1, characterized in that: After comparing the standard source data file and the standard target data file, the method further includes: when a difference occurs, generating a task to be synchronized.
9. A method for synchronizing databases of any type according to claim 1, characterized in that: The synchronization between different types of databases specifically includes: Execute the SQL applicable to the target database according to the task to be synchronized, modify the data files with differences in the target database, and complete the synchronization between different types of databases.