CN113434595A - Database synchronization method and device, electronic equipment and storage medium - Google Patents

Database synchronization method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113434595A
CN113434595A CN202110702249.7A CN202110702249A CN113434595A CN 113434595 A CN113434595 A CN 113434595A CN 202110702249 A CN202110702249 A CN 202110702249A CN 113434595 A CN113434595 A CN 113434595A
Authority
CN
China
Prior art keywords
database
synchronized
metadata
instruction
synchronization
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.)
Pending
Application number
CN202110702249.7A
Other languages
Chinese (zh)
Inventor
俞翼飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Weikun Shanghai Technology Service Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Weikun Shanghai Technology Service Co Ltd filed Critical Weikun Shanghai Technology Service Co Ltd
Priority to CN202110702249.7A priority Critical patent/CN113434595A/en
Publication of CN113434595A publication Critical patent/CN113434595A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

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

The application relates to the technical field of database synchronization, and particularly discloses a database synchronization method, a database synchronization device, electronic equipment and a storage medium, wherein the database synchronization method comprises the following steps: acquiring a metadata dictionary, wherein the metadata dictionary is used for recording data structure characteristics of a metadata database corresponding to a database to be synchronized; performing feature extraction on the database to be synchronized to obtain first database features; generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized; and carrying out synchronous operation on the database to be synchronized according to the first synchronous instruction so as to enable the data structure of the database to be synchronized to be the same as that of the metadata database corresponding to the database to be synchronized.

Description

Database synchronization method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of database synchronization, in particular to a database synchronization method, a database synchronization device, electronic equipment and a storage medium.
Background
Due to different use habits and different purpose requirements of the cloud environments, even a provider of the cloud environment cannot ensure that the database of each cloud environment can keep the consistency of the database structure after delivery. At present, in order to ensure that the database structure of the database in each cloud environment still maintains consistency after delivery, a provider or an operation and maintenance party of the cloud environment needs to provide a set of synchronization mechanism to maintain synchronization of the database structures of the databases in each cloud environment. However, the existing synchronization mechanism generally adopts the form of coverage of the whole source database to perform consistent adjustment of the database structure, and the synchronization efficiency is low.
Disclosure of Invention
In order to solve the above problems in the prior art, embodiments of the present application provide a database synchronization method, an apparatus, an electronic device, and a storage medium, which can improve the database synchronization efficiency.
In a first aspect, an embodiment of the present application provides a database synchronization method, including:
acquiring a metadata dictionary, wherein the metadata dictionary is used for recording data structure characteristics of a metadata database corresponding to a database to be synchronized;
performing feature extraction on a database to be synchronized to obtain first database features;
generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and according to the first synchronization instruction, performing synchronization operation on the database to be synchronized so that the data structure of the database to be synchronized is the same as that of the metadata database corresponding to the database to be synchronized.
In a second aspect, an embodiment of the present application provides a database synchronization apparatus, including:
the acquisition module is used for acquiring a metadata dictionary, and the metadata dictionary is used for recording the data structure characteristics of a metadata database corresponding to the database to be synchronized;
the system comprises a characteristic extraction module, a synchronization module and a synchronization module, wherein the characteristic extraction module is used for extracting characteristics of a database to be synchronized to obtain first database characteristics;
the instruction generating module is used for generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and the synchronization module is used for performing synchronization operation on the database to be synchronized according to the first synchronization instruction so as to enable the data structure of the database to be synchronized to be the same as the data structure of the metadata database corresponding to the database to be synchronized.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor coupled to the memory, the memory for storing a computer program, the processor for executing the computer program stored in the memory to cause the electronic device to perform the method of the first aspect.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, the computer program causing a computer to perform the method according to the first aspect.
In a fifth aspect, embodiments of the present application provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program, the computer operable to cause the computer to perform a method according to the first aspect.
The implementation of the embodiment of the application has the following beneficial effects:
in the embodiment of the application, a metadata dictionary recording data structure characteristics of a metadata database corresponding to a database to be synchronized is obtained, the metadata dictionary is compared with first database characteristics of the database to be synchronized, then a first synchronization instruction is generated according to a comparison result, and the database to be synchronized is synchronized, so that the data structure of the database to be synchronized is the same as the data structure of the metadata database corresponding to the database to be synchronized. Therefore, when a task is synchronized, only by determining the difference between the first database characteristic of the database to be synchronized and the metadata dictionary, the synchronization instruction can be automatically generated according to the difference point, the database structure of the database to be synchronized is synchronized, the database structure consistency adjustment is not required to be performed in a mode of covering the whole source database, and the synchronization efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
Fig. 1 is a network architecture diagram of a database system according to an embodiment of the present application;
fig. 2 is a schematic hardware structure diagram of a database synchronization apparatus according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of a database synchronization method according to an embodiment of the present disclosure;
fig. 4 is a flowchart illustrating a method for generating a first synchronization instruction according to a first database characteristic and a data structure characteristic of a meta database corresponding to a database to be synchronized according to an embodiment of the present application;
fig. 5 is a schematic flowchart of a method for synchronizing databases related to databases to be synchronized according to an embodiment of the present application;
fig. 6 is a block diagram illustrating functional modules of a database synchronization apparatus according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments obtained by a person of ordinary skill in the art without any inventive work based on the embodiments in the present application are within the scope of protection of the present application.
The terms "first," "second," "third," and "fourth," etc. in the description and claims of this application and in the accompanying drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, result, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
First, it should be noted that, as shown in fig. 1, fig. 1 is a network architecture diagram of a database system related to the present application, and the database system 100 includes a database to be synchronized 101, an association database 102 corresponding to the database to be synchronized 101, and a metadata database 103 corresponding to the database to be synchronized 101. The number of the databases 101 to be synchronized may be multiple, the number of the associated databases 102 corresponding to the databases 101 to be synchronized may also be multiple, and the number of the metadata databases 103 corresponding to the databases 101 to be synchronized may also be multiple, and the mutual corresponding relationship and the associated relationship are not limited herein.
In the present embodiment, a description will be given of a database synchronization method proposed in the present application, taking a case of one database to be synchronized 101, one associated database 102, and one metadata database 103 as an example. The database synchronization method in the case of other numbers of databases 101 to be synchronized, associated databases 102, and metadata databases 103 is similar to the database synchronization method in the above case, and will not be described herein again. In the above case, the database to be synchronized 101 and the association database 102 are associated with each other, and the metadata database 103 is a database with a standard structure preset by a provider or an operation and maintenance party of the cloud environment.
Next, referring to fig. 2, fig. 2 is a schematic diagram of a hardware structure of a database synchronization apparatus according to an embodiment of the present disclosure. The database synchronization apparatus 200 includes at least one processor 201, a communication line 202, a memory 203, and at least one communication interface 204.
In this embodiment, the processor 201 may be a general processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more ics for controlling the execution of programs according to the present disclosure.
The communication link 202, which may include a path, carries information between the aforementioned components.
The communication interface 204 may be any transceiver or other device (e.g., an antenna, etc.) for communicating with other devices or communication networks, such as an ethernet, RAN, Wireless Local Area Network (WLAN), etc.
The memory 203 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, optical disk storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
In this embodiment, the memory 203 may be independent and connected to the processor 201 through the communication line 202. The memory 203 may also be integrated with the processor 201. The memory 203 provided in the embodiments of the present application may generally have a nonvolatile property. The memory 203 is used for storing computer execution instructions for executing the scheme of the application, and is controlled by the processor 201 to execute. The processor 201 is configured to execute computer-executable instructions stored in the memory 103, thereby implementing the methods provided in the embodiments described below.
In alternative embodiments, computer-executable instructions may also be referred to as application code, which is not specifically limited in this application.
In alternative embodiments, processor 201 may include one or more CPUs, such as CPU0 and CPU1 of FIG. 1.
In an alternative embodiment, database synchronization apparatus 200 may comprise a plurality of processors, such as processor 201 and processor 207 in FIG. 2. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In an alternative embodiment, if the database synchronization apparatus 200 is a server, the database synchronization apparatus 200 may further include an output device 205 and an input device 206. The output device 205 is in communication with the processor 201 and may display information in a variety of ways. For example, the output device 205 may be a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display device, a Cathode Ray Tube (CRT) display device, a projector (projector), or the like. The input device 206 is in communication with the processor 201 and may receive user input in a variety of ways. For example, the input device 206 may be a mouse, a keyboard, a touch screen device, or a sensing device, among others.
The database synchronization apparatus 200 may be a general-purpose device or a special-purpose device. The embodiment of the present application does not limit the type of the database synchronization apparatus 200.
Hereinafter, a database synchronization method disclosed in the present application will be described:
referring to fig. 3, fig. 3 is a schematic flowchart of a database synchronization method according to an embodiment of the present disclosure. The database synchronization method comprises the following steps:
301: a metadata dictionary is obtained.
In this embodiment, the metadata dictionary is used to record data structure characteristics of a metadata database corresponding to a database to be synchronized, where the metadata database is a database with a standard structure preset by a provider or an operation and maintenance party of a cloud environment where the database to be synchronized is located. In other words, the metadata database is a standard template of the database in the cloud environment, and is used for constraining the structure of other databases in the cloud environment.
In the present embodiment, the metadata dictionary may be obtained by performing feature extraction on a metadata library. For example, the extracted features may be the composition structure of all data tables in the metadata database, such as: field type, field length, field name, and index. Specifically, the metadata base comprises a data table 1 and a data table 2, wherein the field type of the data table 1 is D, the field length is E, the field name is F, and the index is G; the data table 2 has a field type of H, a field length of I, a field name of J, and an index of K. Obtaining a metadata dictionary of [ 1I D, E, F, G ]; [2 ] H, I, J, K ] }.
In this embodiment, the metadata dictionary may be generated in advance at a time when the system is idle before the task is synchronized. And after being generated, the data are associated with the database to be synchronized and then stored. Therefore, when the synchronization task starts, the call can be directly carried out according to the association relation, and the synchronization efficiency is improved.
In addition, the metadata dictionary can be synchronously updated along with the change of the database structure of the metadata database, so that when a new standard is provided, only the database structure of the metadata database needs to be modified, meanwhile, the synchronization standard in the whole synchronization process can be modified by synchronously updating the metadata dictionary, a large amount of repeated operations are reduced, and the synchronization efficiency is greatly improved.
302: and performing feature extraction on the database to be synchronized to obtain first database features.
In this embodiment, the method for extracting the features of the database to be synchronized to obtain the first database features is similar to the method for extracting the features of the metadata database in step 301, and is not described herein again.
303: and generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized.
In this embodiment, a method for generating a first synchronization instruction according to a first database characteristic and a data structure characteristic of a metadata database corresponding to a database to be synchronized is provided, as shown in fig. 4, where the method includes:
401: and determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized.
As can be seen from the above, the first database feature and the data structure feature of the metadata base are features obtained by feature extraction of the composition structures of the data tables in the respective corresponding databases, where the features extracted for the composition structure of a certain table, that is, the field type, the field length, the field name, and the index, can be regarded as a basic unit of the first database feature and the data structure feature of the metadata base, for example: the field type of the data table 2 is H, the field length is I, the field name is J, and the index is K, the extracted features are [ 2I H, I, J, K ], and [ 2I H, I, J, K ] are a basic unit of the first database feature and the data structure feature of the metadata database.
Thus, in this embodiment, the first database characteristics may be considered to include at least one first base unit, where each first base unit in the at least one first base unit is used to identify characteristics of a corresponding data table in the database to be synchronized; the data structure characteristics of the metadata database corresponding to the database to be synchronized comprise at least one second base unit, wherein each second base unit in the at least one second base unit is used for identifying the characteristics of the corresponding data table in the metadata database. Based on the word embedding processing, each first basic unit in the first database characteristic and each second basic unit in the data structure characteristic of the metadata database can be subjected to word embedding processing, the word embedding processing is converted into basic characteristics, and a label is added to each basic characteristic, wherein the label can be the type of the data table of the basic unit corresponding to the basic characteristic. Therefore, through the label, the basic characteristics corresponding to the data tables of the same type in the data structure characteristics of the first database characteristics and the metadata database can be found out and compared, if the difference exists, the basic characteristics are found out and the corresponding basic units are found out to be compared in detail, so that at least one first difference point is determined, and the comparison efficiency is improved.
402: for each first difference point in the at least one first difference point, generating a first instruction according to each first difference point respectively, and obtaining at least one first instruction corresponding to the at least one first difference point one to one.
For example, the difference type of each first difference point may be determined, and then the instruction generation rule corresponding to the difference type may be determined according to the difference type of each first difference point. And finally, according to the instruction generation rule corresponding to each first difference point, performing instruction conversion on each first difference point to generate a first instruction.
In this embodiment, the difference types may include: different differences in object type, missing differences in object type, and redundant differences in object type.
Specifically, for the difference points with different object types, the instruction generation rule is as follows: and generating a first instruction for modifying the object type of the database to be synchronized based on the data structure of the metadata dictionary. Illustratively, a TMP table exists in the database to be synchronized, wherein the field type of the ID is CHAR, but in the metadata dictionary, the field type of the ID of the TMP table is INT, and then a synchronization instruction for modifying the field type of the ID of the TMP table to INT is generated. In this embodiment, the first instruction may be an SQL database ALTER command: altretableTMPmodifyID INT.
For the difference points with missing object types, the instruction generation rule is as follows: and generating a first instruction for supplementing the object type of the database to be synchronized based on the data structure of the metadata dictionary. For example, if there is a TMP table in the metadata dictionary and the to-be-synchronized database does not have a TMP table, a synchronization instruction for adding the TMP table to the to-be-synchronized database is generated. In this embodiment, the synchronization command may be an SQL database create command: createtableTMP (ID INT).
For the redundant difference points of the object types, the instruction generation rule is as follows: and generating a first instruction for deleting the object type of the database to be synchronized based on the data structure of the metadata dictionary. For example, if there is a TMP table in the database to be synchronized and there is no TMP table in the metadata dictionary, a synchronization instruction for deleting the TMP table in the database to be synchronized is generated. In this embodiment, the synchronization command may be an SQL database drop command: dropteatmp.
403: a first synchronization instruction is generated based on the at least one first instruction.
In this embodiment, each of the obtained at least one first instruction may be spliced to obtain a first synchronization instruction.
304: and carrying out synchronous operation on the database to be synchronized according to the first synchronous instruction.
In this embodiment, after the first synchronization instruction is executed on the database to be synchronized, the data structure of the database to be synchronized may be the same as the data structure of the metadata database corresponding to the database to be synchronized, so that the data structure of the database to be synchronized is converted into a standard structure.
In an optional embodiment, the metadata dictionary may further include an association relationship of the databases to be synchronized, and based on this, the metadata dictionary may further determine an association database associated with the databases to be synchronized, and then synchronously execute the database synchronization method on the association database, so that the database structure of the association database and the databases to be synchronized are always consistent. Specifically, as shown in fig. 5, the present invention includes:
501: and determining the associated database of the database to be synchronized according to the associated relationship of the database to be synchronized.
502: and performing feature extraction on the associated database to obtain second database features.
In this embodiment, the method for extracting the feature of the associated database to obtain the second database feature is similar to the method for extracting the feature of the metadata database in step 301, and is not described herein again.
503: and generating a second synchronization instruction according to the second database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized.
In this embodiment, the method for generating the second synchronization instruction according to the second database feature and the data structure feature of the metadata database corresponding to the database to be synchronized is similar to the method for generating the first synchronization instruction according to the first database feature and the data structure feature of the metadata database corresponding to the database to be synchronized in step 303, and details are not repeated here.
504: and carrying out synchronous operation on the associated database according to the second synchronous instruction.
In this embodiment, the method for performing the synchronization operation on the associated database according to the second synchronization instruction is similar to the method for performing the synchronization operation on the database to be synchronized according to the first synchronization instruction in step 304, and is not described herein again.
Meanwhile, in the above case, since the metadata dictionary may further include an association relationship of the databases to be synchronized, when the metadata dictionary is obtained, in addition to obtaining the data structure characteristics of the metadata database corresponding to the databases to be synchronized, it is also necessary to obtain association information of the databases to be synchronized. In this embodiment, the method for obtaining the data structure feature of the metadata database corresponding to the database to be synchronized is similar to the method for extracting the feature of the metadata database in step 301, and is not described herein again.
For obtaining the association information of the database to be synchronized, in this embodiment, the association relationship between the database to be synchronized and other databases in the cloud environment may be collected through an interface provided by the Python code, so as to obtain the association information of the database to be synchronized. Illustratively, the database a is a database to be synchronized, and if it is determined that there is an association between the database a and the databases B and C through an interface provided by a Python code, the association information of the database a is (a | B, C).
In summary, in the database synchronization method provided by the present invention, the metadata dictionary recording the data structure characteristics of the metadata database corresponding to the database to be synchronized is obtained, and is compared with the first database characteristics of the database to be synchronized, and then the first synchronization instruction is generated according to the comparison result, so as to synchronize the database to be synchronized, so that the data structure of the database to be synchronized is the same as the data structure of the metadata database corresponding to the database to be synchronized. Therefore, when a task is synchronized, only by determining the difference between the first database characteristic of the database to be synchronized and the metadata dictionary, the synchronization instruction can be automatically generated according to the difference point, the database structure of the database to be synchronized is synchronized, the database structure consistency adjustment is not required to be performed in a mode of covering the whole source database, and the synchronization efficiency is improved. Meanwhile, the associated database of the database to be synchronized can be determined through the metadata dictionary, so that the database structures of the database to be synchronized and the associated database thereof can be synchronized simultaneously, and the synchronization efficiency is further improved. And the metadata dictionary can be synchronously updated along with the change of the database structure of the metadata database, so that when a new standard is provided, only the database structure of the metadata database needs to be modified, and meanwhile, the synchronous standard in the whole synchronization process can be modified by synchronously updating the metadata dictionary, a large amount of repeated operation is reduced, and the synchronization efficiency is greatly improved.
Referring to fig. 6, fig. 6 is a block diagram illustrating functional modules of a database synchronization apparatus according to an embodiment of the present disclosure. As shown in fig. 6, the database synchronization apparatus 600 includes:
the acquiring module 601 is configured to acquire a metadata dictionary, where the metadata dictionary is used to record data structure characteristics of a metadata database corresponding to a database to be synchronized;
the feature extraction module 602 is configured to perform feature extraction on a database to be synchronized to obtain a first database feature;
the instruction generating module 603 is configured to generate a first synchronization instruction according to the first database feature and the data structure feature of the metadata database corresponding to the database to be synchronized;
the synchronization module 604 is configured to perform a synchronization operation on the database to be synchronized according to the first synchronization instruction, so that the data structure of the database to be synchronized is the same as the data structure of the metadata database corresponding to the database to be synchronized.
In an embodiment of the present invention, in terms of generating a first synchronization instruction according to a first database feature and a data structure feature of a metadata database corresponding to a database to be synchronized, the instruction generating module 603 is specifically configured to:
determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
for each first difference point in the at least one first difference point, generating a first instruction according to each first difference point respectively to obtain at least one first instruction, wherein the at least one first instruction corresponds to the at least one first difference point one to one;
a first synchronization instruction is generated based on the at least one first instruction.
In an embodiment of the present invention, the first database characteristics include at least one first base unit, where each first base unit in the at least one first base unit is configured to identify characteristics of a corresponding data table in the database to be synchronized;
the data structure characteristics of the metadata database corresponding to the database to be synchronized comprise at least one second basic unit, wherein each second basic unit in the at least one second basic unit is used for identifying the characteristics of a corresponding data table in the metadata database;
based on this, in terms of determining at least one first difference point between the first database feature and the data structure feature of the metadata database corresponding to the database to be synchronized, the instruction generating module 603 is specifically configured to:
performing word embedding processing on each first basic unit in at least one first basic unit to obtain at least one first basic feature, wherein the at least one first basic feature corresponds to the at least one first basic unit one by one;
adding a first label to each first basic feature in at least one first basic feature, wherein the first label is a data table type of a data table corresponding to each first basic feature;
performing word embedding processing on each second basic unit in the at least one second basic unit to obtain at least one second basic feature, wherein the at least one second basic feature corresponds to the at least one second basic unit one by one;
adding a second label to each second basic feature in at least one second basic feature, wherein the second label is the data table type of the data table corresponding to each second basic feature;
and determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized according to the at least one first basic characteristic added with the first label and the at least one second basic characteristic added with the second label.
In the embodiment of the present invention, in terms of generating the first instruction according to each first difference point, the instruction generating module 603 is specifically configured to:
respectively determining the difference type of each first difference point;
determining an instruction generation rule corresponding to the difference type according to the difference type of each first difference point;
and according to the instruction generation rule corresponding to each first difference point, performing instruction conversion on each first difference point to generate a first instruction.
In an embodiment of the present invention, the difference types include: different differences of object types, missing differences of object types and redundant differences of object types;
when the difference types are different in object type, the first instruction is used for indicating the object type modification of the database to be synchronized;
when the difference type is the object type missing difference, the first instruction is used for indicating object type supplement to the database to be synchronized;
and when the difference type is the redundant difference of the object type, the first instruction is used for indicating the object type deletion of the database to be synchronized.
In an embodiment of the invention, the metadata dictionary further comprises an association of the databases to be synchronized, based on which,
the obtaining module 601 is further configured to determine an association database of the databases to be synchronized according to the association relationship of the databases to be synchronized;
the feature extraction module 602 is further configured to perform feature extraction on the associated database to obtain a second database feature;
the instruction generating module 603 is further configured to generate a second synchronization instruction according to the second database feature and the data structure feature of the metadata database corresponding to the database to be synchronized;
the synchronization module 604 is further configured to perform a synchronization operation on the associated database according to the second synchronization instruction, so that the data structure of the associated database is the same as the data structure of the metadata database corresponding to the database to be synchronized.
In an embodiment of the present invention, in terms of obtaining the metadata dictionary, the obtaining module 601 is specifically configured to:
acquiring the associated information of a database to be synchronized;
determining a metadata database corresponding to the database to be synchronized according to the configuration information of the database to be synchronized;
performing feature extraction on the metadata database to obtain data structure features of the metadata database;
and taking the associated information of the database to be synchronized and the data structure characteristics of the metadata database as a metadata dictionary.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, where the electronic device 700 is disposed in a first tenant system. As shown in fig. 7, the electronic device 700 includes a transceiver 701, a processor 702, and a memory 703. Connected to each other by a bus 704. The memory 703 is used to store computer programs and data, and may transfer the data stored in the memory 703 to the processor 702.
The processor 702 is configured to read the computer program in the memory 703 to perform the following operations:
acquiring a metadata dictionary, wherein the metadata dictionary is used for recording data structure characteristics of a metadata database corresponding to a database to be synchronized;
performing feature extraction on a database to be synchronized to obtain first database features;
generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and according to the first synchronization instruction, performing synchronization operation on the database to be synchronized so that the data structure of the database to be synchronized is the same as that of the metadata database corresponding to the database to be synchronized.
In an embodiment of the present invention, in terms of generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized, the processor 702 is specifically configured to perform the following operations:
determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
for each first difference point in the at least one first difference point, generating a first instruction according to each first difference point respectively to obtain at least one first instruction, wherein the at least one first instruction corresponds to the at least one first difference point one to one;
a first synchronization instruction is generated based on the at least one first instruction.
In an embodiment of the present invention, the first database characteristics include at least one first base unit, where each first base unit in the at least one first base unit is configured to identify characteristics of a corresponding data table in the database to be synchronized;
the data structure characteristics of the metadata database corresponding to the database to be synchronized comprise at least one second basic unit, wherein each second basic unit in the at least one second basic unit is used for identifying the characteristics of a corresponding data table in the metadata database;
based on this, in terms of determining at least one first difference point between the first database feature and the data structure feature of the metadata database corresponding to the database to be synchronized, the processor 702 is specifically configured to perform the following operations:
performing word embedding processing on each first basic unit in at least one first basic unit to obtain at least one first basic feature, wherein the at least one first basic feature corresponds to the at least one first basic unit one by one;
adding a first label to each first basic feature in at least one first basic feature, wherein the first label is a data table type of a data table corresponding to each first basic feature;
performing word embedding processing on each second basic unit in the at least one second basic unit to obtain at least one second basic feature, wherein the at least one second basic feature corresponds to the at least one second basic unit one by one;
adding a second label to each second basic feature in at least one second basic feature, wherein the second label is the data table type of the data table corresponding to each second basic feature;
and determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized according to the at least one first basic characteristic added with the first label and the at least one second basic characteristic added with the second label.
In an embodiment of the present invention, in terms of generating the first instruction according to each first difference point, the processor 702 is specifically configured to perform the following operations:
respectively determining the difference type of each first difference point;
determining an instruction generation rule corresponding to the difference type according to the difference type of each first difference point;
and according to the instruction generation rule corresponding to each first difference point, performing instruction conversion on each first difference point to generate a first instruction.
In an embodiment of the present invention, the difference types include: different differences of object types, missing differences of object types and redundant differences of object types;
when the difference types are different in object type, the first instruction is used for indicating the object type modification of the database to be synchronized;
when the difference type is the object type missing difference, the first instruction is used for indicating object type supplement to the database to be synchronized;
and when the difference type is the redundant difference of the object type, the first instruction is used for indicating the object type deletion of the database to be synchronized.
In an embodiment of the present invention, the metadata dictionary further includes an association relationship of databases to be synchronized, and based on this, the processor 702 is further configured to perform the following operations:
determining an association database of the database to be synchronized according to the association relationship of the database to be synchronized;
extracting the characteristics of the associated database to obtain the characteristics of a second database;
generating a second synchronization instruction according to the second database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and according to the second synchronization instruction, performing synchronization operation on the associated database so that the data structure of the associated database is the same as that of the metadata database corresponding to the database to be synchronized.
In an embodiment of the present invention, in obtaining the metadata dictionary, the processor 702 is specifically configured to perform the following operations:
acquiring the associated information of a database to be synchronized;
determining a metadata database corresponding to the database to be synchronized according to the configuration information of the database to be synchronized;
performing feature extraction on the metadata database to obtain data structure features of the metadata database;
and taking the associated information of the database to be synchronized and the data structure characteristics of the metadata database as a metadata dictionary.
It should be understood that the database synchronization device in the present application may include a smart Phone (e.g., an Android Phone, an iOS Phone, a Windows Phone, etc.), a tablet computer, a palm computer, a notebook computer, a Mobile Internet device MID (MID), a robot, a wearable device, etc. The database synchronization apparatus is merely exemplary and not exhaustive, and includes but is not limited to the database synchronization apparatus. In practical applications, the database synchronization apparatus may further include: intelligent vehicle-mounted terminal, computer equipment and the like.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention can be implemented by combining software and a hardware platform. With this understanding in mind, all or part of the technical solutions of the present invention that contribute to the background can be embodied in the form of a software product, which can be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods according to the embodiments or some parts of the embodiments.
Accordingly, the present application also provides a computer readable storage medium, which stores a computer program, wherein the computer program is executed by a processor to implement part or all of the steps of any one of the database synchronization methods as described in the above method embodiments. For example, the storage medium may include a hard disk, a floppy disk, an optical disk, a magnetic tape, a magnetic disk, a flash memory, and the like.
Embodiments of the present application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any one of the database synchronization methods as described in the above method embodiments.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are all alternative embodiments and that the acts and modules referred to are not necessarily required by the application.
In the above embodiments, the description of each embodiment has its own emphasis, and for parts not described in detail in a certain embodiment, reference may be made to the description of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is merely a logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The integrated unit may be implemented in the form of hardware, or may be implemented in the form of a software program module.
The integrated units, if implemented in the form of software program modules and sold or used as stand-alone products, may be stored in a computer readable memory. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a memory, and including several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method described in the embodiments of the present application. And the aforementioned memory comprises: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable memory, and the memory may include: flash Memory disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the methods and their core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A database synchronization method, the method comprising:
acquiring a metadata dictionary, wherein the metadata dictionary is used for recording data structure characteristics of a metadata database corresponding to a database to be synchronized;
performing feature extraction on the database to be synchronized to obtain first database features;
generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and carrying out synchronous operation on the database to be synchronized according to the first synchronous instruction so as to enable the data structure of the database to be synchronized to be the same as that of the metadata database corresponding to the database to be synchronized.
2. The method according to claim 1, wherein the generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized comprises:
determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
for each first difference point in the at least one first difference point, generating a first instruction according to the first difference point respectively to obtain at least one first instruction, wherein the at least one first instruction is in one-to-one correspondence with the at least one first difference point;
and generating the first synchronization instruction according to the at least one first instruction.
3. The method of claim 2,
the first database characteristics comprise at least one first basic unit, wherein each first basic unit in the at least one first basic unit is used for identifying characteristics of a corresponding data table in the database to be synchronized;
the data structure characteristics of the metadata database corresponding to the database to be synchronized comprise at least one second basic unit, wherein each second basic unit in the at least one second basic unit is used for identifying the characteristics of a corresponding data table in the metadata database;
the determining at least one first difference point between the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized includes:
performing word embedding processing on each first basic unit in the at least one first basic unit to obtain at least one first basic feature, wherein the at least one first basic feature is in one-to-one correspondence with the at least one first basic unit;
adding a first label to each first basic feature in the at least one first basic feature, wherein the first label is a data table type of a data table corresponding to each first basic feature;
performing word embedding processing on each second basic unit in the at least one second basic unit to obtain at least one second basic feature, wherein the at least one second basic feature is in one-to-one correspondence with the at least one second basic unit;
adding a second label to each second basic feature in the at least one second basic feature, wherein the second label is a data table type of a data table corresponding to each second basic feature;
and according to the at least one first basic feature added with the first label and the at least one second basic feature added with the second label, determining at least one first difference point between the first database feature and the data structure feature of the metadata database corresponding to the database to be synchronized.
4. The method according to claim 2, wherein the generating a first instruction according to each first difference point respectively comprises:
respectively determining the difference type of each first difference point;
determining an instruction generation rule corresponding to the difference type according to the difference type of each first difference point;
and according to the instruction generation rule corresponding to each first difference point, performing instruction conversion on each first difference point to generate the first instruction.
5. The method of claim 4,
the difference types include: different differences of object types, missing differences of object types and redundant differences of object types;
when the difference types are different object types, the first instruction is used for indicating the object type modification of the database to be synchronized;
when the difference type is an object type missing difference, the first instruction is used for indicating object type supplement to the database to be synchronized;
and when the difference type is the object type redundancy difference, the first instruction is used for indicating the object type deletion of the database to be synchronized.
6. The method according to any one of claims 1-5, wherein the metadata dictionary further comprises an association relationship of the databases to be synchronized, the method further comprising:
determining an associated database of the database to be synchronized according to the association relationship of the database to be synchronized;
performing feature extraction on the associated database to obtain second database features;
generating a second synchronization instruction according to the second database characteristics and the data structure characteristics of the metadata database corresponding to the database to be synchronized;
and according to the second synchronization instruction, performing synchronization operation on the associated database so as to enable the data structure of the associated database to be the same as that of the metadata database corresponding to the database to be synchronized.
7. The method of claim 6, wherein obtaining the metadata dictionary comprises:
acquiring the associated information of the database to be synchronized;
determining a metadata database corresponding to the database to be synchronized according to the configuration information of the database to be synchronized;
performing feature extraction on the metadata database to obtain data structure features of the metadata database;
and taking the associated information of the database to be synchronized and the data structure characteristics of the metadata database as the metadata dictionary.
8. A database synchronization apparatus, the apparatus comprising:
the system comprises an acquisition module, a synchronization module and a synchronization module, wherein the acquisition module is used for acquiring a metadata dictionary which is used for recording data structure characteristics of a metadata database corresponding to a database to be synchronized;
the characteristic extraction module is used for extracting characteristics of the database to be synchronized to obtain first database characteristics;
the instruction generating module is used for generating a first synchronization instruction according to the first database characteristic and the data structure characteristic of the metadata database corresponding to the database to be synchronized;
and the synchronization module is used for carrying out synchronization operation on the database to be synchronized according to the first synchronization instruction so as to enable the data structure of the database to be synchronized to be the same as that of the metadata database corresponding to the database to be synchronized.
9. An electronic device comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, the one or more programs including instructions for performing the steps in the method of any of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program which is executed by a processor to implement the method according to any one of claims 1-7.
CN202110702249.7A 2021-06-23 2021-06-23 Database synchronization method and device, electronic equipment and storage medium Pending CN113434595A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110702249.7A CN113434595A (en) 2021-06-23 2021-06-23 Database synchronization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110702249.7A CN113434595A (en) 2021-06-23 2021-06-23 Database synchronization method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113434595A true CN113434595A (en) 2021-09-24

Family

ID=77753740

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110702249.7A Pending CN113434595A (en) 2021-06-23 2021-06-23 Database synchronization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113434595A (en)

Similar Documents

Publication Publication Date Title
CN110597595B (en) Method for providing multi-language information, method for configuring multi-language information, device, equipment and medium
CN109189841B (en) Multi-data source access method and system
CN108536745B (en) Shell-based data table extraction method, terminal, equipment and storage medium
CN106648569B (en) Target serialization realization method and device
US20230012642A1 (en) Method and device for snapshotting metadata, and storage medium
CN112988583A (en) Method and device for testing syntax compatibility of database
CN114416877A (en) Data processing method, device and equipment and readable storage medium
CN114416868B (en) Data synchronization method, device, equipment and storage medium
CN112783482B (en) Visual form generation method, device, equipment and storage medium
US20140279842A1 (en) Inferring a sequence of editing operations to facilitate merging versions of a shared document
CN112559913B (en) Data processing method, device, computing equipment and readable storage medium
CN111767267B (en) Metadata processing method and device and electronic equipment
CN107729347A (en) Acquisition methods, device, equipment and the computer-readable recording medium of synonymous label
CN113434595A (en) Database synchronization method and device, electronic equipment and storage medium
CN115454971A (en) Data migration method and device, electronic equipment and storage medium
CN115544981A (en) Document processing method, document processing device, electronic device, storage medium, and program product
CN110543520B (en) Data migration method and device
CN113127496B (en) Method and device for determining change data in database, medium and equipment
CN109522211B (en) Interface parameter transmission method and device, electronic equipment and storage medium
CN113254455A (en) Dynamic configuration method and device of database, computer equipment and storage medium
CN113190718A (en) Data processing method and device for graph database, electronic equipment and storage medium
CN115104092A (en) Data synchronization method and related device
CN113760600A (en) Database backup method, database restoration method and related device
CN114253944B (en) Database bidirectional synchronization method and device and electronic equipment
CN113515504B (en) Data management method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination