CN114116907A - 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
CN114116907A
CN114116907A CN202111431326.6A CN202111431326A CN114116907A CN 114116907 A CN114116907 A CN 114116907A CN 202111431326 A CN202111431326 A CN 202111431326A CN 114116907 A CN114116907 A CN 114116907A
Authority
CN
China
Prior art keywords
database
source
data
backup
information
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
CN202111431326.6A
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.)
Shanghai Information2 Software Inc
Original Assignee
Shanghai Information2 Software Inc
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 Shanghai Information2 Software Inc filed Critical Shanghai Information2 Software Inc
Priority to CN202111431326.6A priority Critical patent/CN114116907A/en
Publication of CN114116907A publication Critical patent/CN114116907A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention 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 table structure information and table data information contained in a source database; when the row address identification is determined to be started for synchronization according to a pre-configured file, a main key is newly added in a standby database according to table structure information to create a standby database table, wherein the standby database is heterogeneous to a source database; and synchronizing the data in the source database to the created standby database table according to the table data information. In the process of determining the starting of the row address identifier to synchronize the heterogeneous databases, a standby database table is created by adding a main key in the standby database, and data in the source database is synchronized to the standby database table based on the added main key, so that the heterogeneous databases are quickly and accurately synchronized.

Description

Database synchronization method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of databases, in particular to a database synchronization method, a database synchronization device, electronic equipment and a storage medium.
Background
With the rapid development of internet informatization, big data is rapidly applied to various industries, data security backup is particularly important at this time, and especially heterogeneous database synchronization is an important means in the field of computer data backup, for example, synchronizing data in a source-end database ORACLE to a backup-end database, namely, a heterogeneous database MYSQL.
However, in the synchronization process, a situation that the source-end database ORACLE contains a large number of tables without main keys occurs, and in such a situation, full-field comparison and updating are required, so that the speed of synchronizing the data to the backup-end database in a full amount is influenced; in addition, due to the limitation of the table structure of the backup database, when the table data synchronized by the source database does not meet the limitation requirement of the backup database, for example, when the number of the joint primary key columns in the source database exceeds 16, an error is reported, so that the synchronization of the databases cannot be accurately and quickly realized, and therefore, the existing database synchronization method cannot meet the requirement of a user on the quick and accurate synchronization of heterogeneous databases.
Disclosure of Invention
The embodiment of the invention provides a database synchronization method, a database synchronization device, electronic equipment and a storage medium, so as to realize quick and accurate synchronization of heterogeneous databases.
In a first aspect, an embodiment of the present invention provides a database synchronization method, including: acquiring table structure information and table data information contained in a source database;
when the row address identification is determined to be started for synchronization according to a pre-configured file, a main key is newly added in a standby database according to table structure information to create a standby database table, wherein the standby database is heterogeneous to a source database;
and synchronizing the data in the source database to the created standby database table according to the table data information.
In a second aspect, an embodiment of the present invention provides a database synchronization apparatus, including: the source database information acquisition module is used for acquiring the table structure information and the table data information contained in the source database;
the backup database table creating module is used for creating a backup database table by adding a main key in the backup database according to the table structure information when the row address identification needs to be started for synchronization according to a pre-configured file, wherein the backup database is heterogeneous to the source database;
and the data synchronization module is used for synchronizing the data in the source end database to the created standby end database table according to the table data information.
In a third aspect, an embodiment of the present invention provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when executed by one or more processors, cause the one or more processors to implement the method as described above.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is configured to, when executed by a processor, implement the method as described above.
According to the technical scheme of the embodiment of the invention, in the process of determining the starting of the row address identifier to synchronize the heterogeneous databases, the spare-end database table is created by adding the main key in the spare-end database, and the data in the source-end database is synchronized into the spare-end database table based on the added main key, so that the heterogeneous databases are quickly and accurately synchronized.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
FIG. 1 is a flow chart of a database synchronization method according to an embodiment of the present invention;
fig. 2 is a schematic application scenario diagram of a database synchronization method according to an embodiment of the present invention;
FIG. 3 is a flowchart of a database synchronization method according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a database synchronization apparatus according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention.
It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, software implementations, hardware implementations, and so on.
Example one
Fig. 1 is a flowchart of a database synchronization method according to an embodiment of the present invention, where the present embodiment is applicable to a case of fast and accurate synchronization of heterogeneous databases, and the method may be executed by a database synchronization apparatus according to an embodiment of the present invention, where the apparatus may be implemented in a software and/or hardware manner. As shown in fig. 1, the method specifically includes the following operations:
step S101, obtaining the table structure information and the table data information contained in the source database.
Optionally, the table structure information includes primary key information and a type of the source database; the table data information includes a row address identifier, a type of the source database, and a source data value.
Optionally, the obtaining table structure information included in the source database includes: performing table structure copying based on a source database, assembling table structure copying results into table structure objects, and issuing the table structure objects to the middleware; the table structure information is obtained from the middleware by reading the table structure object.
Fig. 2 is a schematic diagram of an application scenario of the synchronization method for the databases according to this embodiment, where the source-side database is ORACLE, the backup-side database is MYSQL, and ORACLE and MYSQL are heterogeneous databases, and a middleware, such as KAFKA, is used between the source-side database ORACLE and the backup-side database MYSQL to perform information transmission. Based on a source end database ORACLE, a GET TABLE statement is adopted to carry out TABLE structure copy, a TABLE structure copy result is assembled into a TABLE structure object CREATE TABLE JSON in a data flow mode and is issued to a middleware KAFKA, the TABLE structure object comprises TABLE structure information, the TABLE structure information specifically comprises main key information and the type of the source end database, and the TABLE structure information is obtained by reading the TABLE structure object from the middleware, wherein the main key information specifically comprises information such as whether a main key is included or not, the number of the main keys is combined and the like.
Optionally, the obtaining table data information included in the source database includes: performing table data replication based on a source database, assembling table data replication results into table data objects in different forms, and issuing the table data objects to a middleware; the table data information is obtained from the middleware by reading the table data object.
Wherein the form of the table data object comprises: inserting a table data object, updating a table data object, or deleting a table data object.
Specifically, based on the source database ORACLE, TABLE DATA copy is performed by using a GET TABLE DATA statement, and the TABLE DATA copy result is assembled into different TABLE DATA objects and issued to the middleware KAFKA, for example, an INSERT TABLE DATA object INSERT JSON, an UPDATE TABLE DATA object UPDATE JSON, or a DELETE TABLE DATA object DELETE JSON, and the like, where the TABLE DATA objects include a row address identifier, a type of the source database, and a source DATA value, and the TABLE DATA information is obtained by reading the TABLE DATA objects from the middleware, where the row address identifier may be represented by a row address symbol, and each record stored in the source database ORACLE has a unique identifier ROWID for marking, so that a unique record may be queried by using a ROWID.
Step S102, when it is determined that the row address identification needs to be started for synchronization according to the pre-configured file, a main key is newly added in the backup database according to the table structure information to create a backup database table.
Optionally, adding a new main key in the standby database according to the table structure information to create a standby database table may include: and determining the type of the source end database to be ORACLE according to the table structure information, and if the source end database has no main key, using the row address identifier of the source end database as a main key newly added by the standby end database to create a standby end database table.
The configuration file in this embodiment is set before the database synchronization, and whether a read sync switch is turned on or not may be added to the configuration file, and when the switch turns on the read sync switch, the read sync switch determines that the type of the SOURCE database is ORACLE according to the table structure information read from the middleware, and the SOURCE database table has no primary key, at this time, a new column of SOURCE _ read (which is separated from the wide of the SOURCE database) is added to the backup database as a non-empty primary key to create the backup database table. Wherein, because ROWID in the SOURCE database is fixed as 18-bit character string, the SOURCE _ ROWID column in the standby database sets the data type as CHAR (18).
It should be noted that, in this embodiment, since the new primary key SOURCE _ row of the backup database corresponds to the unique identifier row in the SOURCE database one to one, by adding a new column of primary keys, data synchronization needs to be performed on each record in the database only according to the primary key column as the identifier during subsequent data synchronization, and full-field comparison is not needed, so as to achieve fast data synchronization.
And step S103, synchronizing the data in the source database to the created standby database table according to the table data information.
Optionally, synchronizing data in the source database to the created backup database table according to the table data information includes: and determining the type of the source database to be ORACLE according to the table data information, and synchronizing the source data value of the standby database table according to the newly added main key if the row address identifier is not null.
When the row address identification switch opens handle, add, column, ROWID, and true, the type of the SOURCE database is ORACLE, and the ROWID read from the middleware KAFKA into INSERT JSON, UPDATE JSON, or DELETE JSON is not empty, the backup database MYSQL synchronizes the SOURCE data values corresponding to INSERT, UPDATE, or DELETE statements according to the main key column SOURCE _ ROWID.
It should be noted that, in this embodiment, only the backup database is illustrated as MYSQL, and specific types of the backup database are not limited, and as long as the backup database and the source database ORACLE are heterogeneous databases, the backup database and the source database are within the protection scope of the present application, and the embodiment is not limited thereto.
According to the technical scheme of the embodiment of the invention, in the process of determining the starting of the row address identifier to synchronize the heterogeneous databases, the spare-end database table is created by adding the main key in the spare-end database, and the data in the source-end database is synchronized into the spare-end database table based on the added main key, so that the heterogeneous databases are quickly and accurately synchronized.
Example two
Fig. 3 is a flowchart of a database synchronization method according to an embodiment of the present invention, where on the basis of the foregoing embodiment, the present embodiment specifically describes step S102, and the method specifically includes the following operations:
step S201, obtaining table structure information and table data information contained in the source database.
Optionally, the table structure information includes primary key information and a type of the source database; the table data information includes a row address identifier, a type of the source database, and a source data value.
Optionally, the obtaining table structure information included in the source database includes: performing table structure copying based on a source database, assembling table structure copying results into table structure objects, and issuing the table structure objects to the middleware; the table structure information is obtained from the middleware by reading the table structure object.
Optionally, the obtaining table data information included in the source database includes: performing table data replication based on a source database, assembling table data replication results into table data objects in different forms, and issuing the table data objects to a middleware; the table data information is obtained from the middleware by reading the table data object.
Step S202, when it is determined that the row address identification needs to be started for synchronization according to the pre-configured file, determining the type of the source end database to be ORACLE according to the table structure information, and if the number of columns of the joint main key contained in the source end database exceeds a preset threshold value, taking the row address identification of the source end database as a newly added main key of the standby end database, and changing the column of the joint main key into a common column to create a standby end database table.
It should be noted that, when database synchronization is performed, there are cases where there are associated primary keys in an ORACLE of a source-side database, but the number of the associated primary keys exceeds 16, and since MYSQL of a backup-side database does not allow the number of columns of the associated primary keys to exceed 16, a case where a database synchronization error occurs when synchronization of heterogeneous databases is directly performed, at this time, a new column of primary keys is added in a backup-side database table, and the way of adding the primary keys is substantially the same as that in the above-mentioned embodiment.
Step S203, synchronizing the data in the source database to the created backup database table according to the table data information.
Optionally, synchronizing data in the source database to the created backup database table according to the table data information includes: and determining the type of the source database to be ORACLE according to the table data information, and synchronizing the source data value of the standby database table according to the newly added main key if the row address identifier is not null.
It should be noted that, in this embodiment, the limitation of the backup database MYSQL further includes that when MYSQL uses char (n) or VARCHAR (n) as the primary key, n cannot exceed 255, and obviously, when the source ORACLE uses char (n) or VARCHAR2(n) as the primary key, and n is greater than 255, if the synchronization of the database is directly performed, an error is reported in the backup database MYSQL, and the fast and accurate synchronization of the heterogeneous database cannot be achieved, and the above problem can be effectively solved by adding a new primary key.
It is worth mentioning that, according to the embodiment of the application, by adding the primary key to the backup database, not only can the problem that the source database has no primary key to be quickly synchronized and the problem that the column number of the combined primary key exceeds the number of items when the heterogeneous databases are synchronized be solved, but also other derivative problems occurring when the heterogeneous databases are synchronized can be synchronously solved. In addition, the limitation of the backup database in this embodiment is not limited to: the backup database cannot have more than 16 federated primary key columns, and char (n) or varchar (n) to make primary key n cannot exceed 255. Other types of restrictions on the backup database are also within the scope of the present application, and are not described in detail in this embodiment.
According to the technical scheme of the embodiment of the invention, in the process of determining the starting of the row address identifier to synchronize the heterogeneous databases, the spare-end database table is created by adding the main key in the spare-end database, and the data in the source-end database is synchronized into the spare-end database table based on the added main key, so that the heterogeneous databases are quickly and accurately synchronized. And when the number of columns of the joint main keys contained in the source database table exceeds a preset threshold value, not only a new column of main keys is added in the standby database, but also the joint main keys are changed into common columns to create the standby database table, so that the situation that accurate and rapid synchronization cannot be caused due to different limits of the source database and the standby database on the number of the joint main keys is avoided.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a database synchronization apparatus according to an embodiment of the present invention, where the apparatus includes: a source database information acquisition module 310, a backup database table creation module 320, and a data synchronization module 330.
The source database information obtaining module 310 is configured to obtain table structure information and table data information included in a source database;
a backup database table creating module 320, configured to, when it is determined that the row address identifier needs to be started for synchronization according to a pre-configured file, add a main key in the backup database according to the table structure information to create a backup database table, where the backup database is heterogeneous to the source database;
and the data synchronization module 330 is configured to synchronize data in the source database to the created standby database table according to the table data information.
Optionally, the table structure information includes primary key information and a type of the source database;
the table data information includes a row address identifier, a type of the source database, and a source data value.
Optionally, the source database information obtaining module is configured to perform table structure replication based on the source database, and assemble table structure replication results into a table structure object and issue the table structure object to the middleware;
the table structure information is obtained from the middleware by reading the table structure object.
Optionally, the source database information obtaining module is configured to copy table data based on the source database, and assemble table data copy results into table data objects of different forms and issue the table data objects to the middleware;
the table data information is obtained from the middleware by reading the table data object.
Optionally, the form of the table data object includes: inserting a table data object, updating a table data object, or deleting a table data object.
Optionally, the backup database table creating module is configured to determine, according to the table structure information, that the type of the source database is ORACLE, and the source database has no primary key, create a backup database table by using the row address identifier of the source database as a primary key added to the backup database, or,
and determining the type of the source end database to be ORACLE according to the table structure information, and if the column number of the combined main key contained in the source end database exceeds a preset threshold value, taking the row address identifier of the source end database as a newly added main key of the standby end database, and changing the column of the combined main key into a common column to create a standby end database table.
Optionally, the data synchronization module is configured to determine, according to the table data information, that the type of the source database is ORACLE, and the row address identifier is not null, synchronize the source data value with the backup database table according to the newly added primary key.
The device can execute the database synchronization method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, reference may be made to the method provided in any embodiment of the present invention.
Example four
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary electronic device 412 suitable for use in implementing embodiments of the present invention. The electronic device 412 shown in fig. 5 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present invention.
As shown in fig. 5, the electronic device 412 is in the form of a general purpose computing device. The components of the electronic device 412 may include, but are not limited to: one or more processors 416, a memory 428, and a bus 418 that couples the various system components (including the memory 428 and the processors 416).
Bus 418 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 412 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 412 and includes both volatile and nonvolatile media, removable and non-removable media.
The memory 428 is used to store instructions. Memory 428 can include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)430 and/or cache memory 432. The electronic device 412 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 434 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 418 by one or more data media interfaces. Memory 428 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) of program modules 442 may be stored, for instance, in memory 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. The program modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
The electronic device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device, display 424, etc.), with one or more devices that enable a user to interact with the electronic device 412, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 412 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 422. Also, the electronic device 412 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) through the network adapter 420. As shown, network adapter 420 communicates with the other modules of electronic device 412 over bus 418. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with the electronic device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor 416, by executing instructions stored in the memory 428, performs various functional applications and data processing, such as implementing the database synchronization method provided by the embodiments of the present invention: acquiring table structure information and table data information contained in a source database; when the row address identification is determined to be started for synchronization according to a pre-configured file, a main key is newly added in a standby database according to table structure information to create a standby database table, wherein the standby database is heterogeneous to a source database; and synchronizing the data in the source database to the created standby database table according to the table data information.
EXAMPLE five
Embodiments of the present invention provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a database synchronization method as provided in all embodiments of the present invention of the present application:
acquiring table structure information and table data information contained in a source database; when the row address identification is determined to be started for synchronization according to a pre-configured file, a main key is newly added in a source end database according to table structure information to create a standby end database table, wherein the standby end database is heterogeneous to the source end database; and synchronizing the data in the source database to the created standby database table according to the table data information.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, or the like, as well as conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method for synchronizing databases, comprising:
acquiring table structure information and table data information contained in a source database;
when it is determined that a row address identifier needs to be started for synchronization according to a pre-configured file, a main key is newly added in a standby database according to the table structure information to create a standby database table, wherein the standby database is heterogeneous to the source database;
and synchronizing the data in the source database to the created standby database table according to the table data information.
2. The method of claim 1, wherein the table structure information includes primary key information and a type of source database;
the table data information includes a row address identifier, a type of a source database, and a source data value.
3. The method of claim 2, wherein the obtaining table structure information contained in the source database comprises:
performing table structure copying based on a source database, assembling table structure copying results into table structure objects, and issuing the table structure objects to the middleware;
and reading the table structure object from the middleware to acquire the table structure information.
4. The method of claim 3, wherein the obtaining table data information contained in the source database comprises:
performing table data replication based on a source database, assembling table data replication results into table data objects in different forms, and issuing the table data objects to the middleware;
and reading the table data object from the middleware to acquire the table data information.
5. The method of claim 4, wherein the form of the table data object comprises: inserting a table data object, updating a table data object, or deleting a table data object.
6. The method as claimed in claim 2, wherein said adding a main key in the backup database according to the table structure information to create a backup database table comprises:
determining the type of the source end database to be ORACLE according to the table structure information, and if the source end database has no main key, using the row address identifier of the source end database as a main key added by the backup end database to create the backup end database table, or,
and determining the type of the source end database to be ORACLE according to the table structure information, and if the number of columns of the combined main key contained in the source end database exceeds a preset threshold value, taking the row address identifier of the source end database as a newly added main key of the backup end database, and changing the column of the combined main key into a common column to create the backup end database table.
7. The method of claim 2, wherein the synchronizing data in a source database into the created backup database table according to the table data information comprises:
and determining the type of the source database to be ORACLE according to the table data information, and if the row address identifier is not null, synchronizing the source data value by the standby database table according to the newly added main key.
8. A database synchronization apparatus, comprising:
the source database information acquisition module is used for acquiring the table structure information and the table data information contained in the source database;
the backup database table creating module is used for creating a backup database table by adding a main key in a backup database according to the table structure information when the fact that the row address identification needs to be started for synchronization is determined according to a pre-configured file, wherein the backup database is heterogeneous to the source database;
and the data synchronization module is used for synchronizing the data in the source end database to the created standby end database table according to the table data information.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202111431326.6A 2021-11-29 2021-11-29 Database synchronization method and device, electronic equipment and storage medium Pending CN114116907A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111431326.6A CN114116907A (en) 2021-11-29 2021-11-29 Database synchronization method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111431326.6A CN114116907A (en) 2021-11-29 2021-11-29 Database synchronization method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114116907A true CN114116907A (en) 2022-03-01

Family

ID=80371181

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111431326.6A Pending CN114116907A (en) 2021-11-29 2021-11-29 Database synchronization method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114116907A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033647A (en) * 2022-08-11 2022-09-09 杭州湖畔网络技术有限公司 Data synchronization method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033647A (en) * 2022-08-11 2022-09-09 杭州湖畔网络技术有限公司 Data synchronization method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US9600507B2 (en) Index structure for a relational database table
CN109906448B (en) Method, apparatus, and medium for facilitating operations on pluggable databases
US9483516B2 (en) Multi-version concurrency control across row store and column store
CN110647579A (en) Data synchronization method and device, computer equipment and readable medium
US8732127B1 (en) Method and system for managing versioned structured documents in a database
US10296497B2 (en) Storing a key value to a deleted row based on key range density
US9418094B2 (en) Method and apparatus for performing multi-stage table updates
US10606839B2 (en) Preventing staleness in query results when using asynchronously updated indexes
KR20200104789A (en) Method, apparatus, device and medium for storing and querying data
CN109471851B (en) Data processing method, device, server and storage medium
US10282437B2 (en) Partial indexes for partitioned tables
US8527480B1 (en) Method and system for managing versioned structured documents in a database
CN109634587B (en) Method and equipment for generating warehousing script and warehousing data
US9922100B2 (en) Systems and methods for facilitating the development of an application that accesses data
US20060282470A1 (en) Determining compliance of a database architecture to an enterprise data standard
CN108628885B (en) Data synchronization method and device and storage equipment
US10552394B2 (en) Data storage with improved efficiency
US10235422B2 (en) Lock-free parallel dictionary encoding
US8589454B2 (en) Computer data file merging based on file metadata
US8396858B2 (en) Adding entries to an index based on use of the index
CN114116907A (en) Database synchronization method and device, electronic equipment and storage medium
CN112783482B (en) Visual form generation method, device, equipment and storage medium
CN112487025A (en) Data query method and device, electronic equipment and storage medium
CN112039975A (en) Method, device, equipment and storage medium for processing message field
CN111897837A (en) Data query method, device, equipment and 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