Oracle Database Synchronization Method and Device
By configuring the database configuration table and archive configuration table, using the Oracle data flashback feature, Oracle database synchronization is automatically performed, which solves the problem of inefficient synchronization in the existing technology, and realizes efficient data synchronization and reduces the programming difficulty of the application.
Patent Information
- Application Number
- CN202011343898.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-26
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2040-11-26
AI Technical Summary
Existing methods are inefficient when syncing data from Oracle business databases to archived databases.
By configuring the database configuration table and archive configuration table, using the Oracle data flashback feature, Oracle database synchronization is automatically performed, including verifying the consistency of the database model, reading and synchronizing recordsets that meet specific requirements to the archive database.
It improves data synchronization efficiency and reduces the programming difficulty of the application, so that the application can access all data by simply accessing the archived database.
Smart Images

Figure CN114547183B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and in particular, to an Oracle database synchronization method and device. Background Art
[0002] In an Oracle business database, as time goes by, the data in the data table will gradually increase. To avoid the impact of more and more data on the performance of online data processing, generally, the data with a relatively long time will be saved to an archive database, and then the corresponding data in the business database will be deleted. The existing methods have the problem of low efficiency when synchronizing the data in the business database to the archive database. Summary of the Invention
[0003] An embodiment of the present invention provides an Oracle database synchronization method for synchronizing the data in an Oracle business database to an Oracle archive database with high efficiency. The method includes:
[0004] Configuring a database configuration table and an archive configuration table, where the database configuration table includes Oracle business database information, Oracle archive database information, and an archive configuration table name field, and the archive configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archive period field;
[0005] After verifying and passing the Oracle business database and the Oracle archive database according to the Oracle business database information and the Oracle archive database information in the database configuration table, reading the archive configuration table name in the archive configuration table name field of the database configuration table;
[0006] For each business database table in the archive configuration table corresponding to the archive configuration table name, reading the field indicating whether to archive expired data of the business database table;
[0007] When the value of the field indicating whether to archive expired data of the business database table is yes, reading a first record set that meets the first requirement of the business database table from the flashback cache of the Oracle business database, and synchronizing the first record set to the corresponding archive database table; reading a second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archive database table according to the value of the archive period field of the business database table;
[0008] When the value of the field indicating whether to archive expired data of the business database table is no, reading a second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archive database table according to the value of the archive period field of the business database table.
[0009] An embodiment of the present invention provides an Oracle database synchronization device for synchronizing data in an Oracle business database to an Oracle archive database with high efficiency. The device includes:
[0010] A configuration module for configuring a database configuration table and an archive configuration table. The database configuration table includes Oracle business database information, Oracle archive database information, and an archive configuration table name field. The archive configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archive period field;
[0011] A verification module for, after verifying and passing the Oracle business database and the Oracle archive database according to the Oracle business database information and the Oracle archive database information in the database configuration table, reading the name of the archive configuration table in the archive configuration table name field of the database configuration table;
[0012] A data reading module for reading, for each business database table in the archive configuration table corresponding to the archive configuration table name, the field indicating whether to archive expired data of the business database table;
[0013] A first synchronization module for, when the value of the field indicating whether to archive expired data of the business database table is yes, reading a first record set of the business database table that meets the first requirement from the flashback cache of the Oracle business database, and synchronizing the first record set to the corresponding archive database table; calling a second synchronization module to read a second record set of the business database table that meets the second requirement from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archive database table according to the value of the archive period field of the business database table;
[0014] A second synchronization module for, when the value of the field indicating whether to archive expired data of the business database table is no, reading a second record set of the business database table that meets the second requirement from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archive database table according to the value of the archive period field of the business database table.
[0015] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above Oracle database synchronization method is implemented.
[0016] An embodiment of the present invention also provides a computer-readable storage medium storing a computer program for executing the above Oracle database synchronization method.
[0017] In an embodiment of the present invention, a database configuration table and an archiving configuration table are configured. The database configuration table includes Oracle business database information, Oracle archiving database information, and an archiving configuration table name field. The archiving configuration table includes at least a business database table name field, a field indicating whether to archive expired data, and an archiving period field. After verifying the Oracle business database and the Oracle archiving database according to the Oracle business database information and the Oracle archiving database information in the database configuration table and passing the verification, the name of the archiving configuration table in the archiving configuration table name field of the database configuration table is read. For each business database table in the archiving configuration table corresponding to the archiving configuration table name, the field indicating whether to archive expired data of the business database table is read. When the value of the field indicating whether to archive expired data of the business database table is "yes", a first record set that meets the first requirement of the business database table is read from the flashback cache of the Oracle business database, and the first record set is synchronized to the corresponding archiving database table. A second record set that meets the second requirement of the business database table is read from the flashback cache of the Oracle business database, and the second record set is synchronized to the corresponding archiving database table according to the value of the archiving period field of the business database table. When the value of the field indicating whether to archive expired data of the business database table is "no", a second record set that meets the second requirement of the business database table is read from the flashback cache of the Oracle business database, and the second record set is synchronized to the corresponding archiving database table according to the value of the archiving period field of the business database table. In the above process, the Oracle data flashback feature is utilized to synchronize the data in the business database to the archiving database. Specifically, by configuring the database configuration table and the archiving configuration table, the Oracle database synchronization is automatically executed with high efficiency, enabling the application program to access all data only by accessing the archiving database, which greatly reduces the programming difficulty of the application program. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts. In the drawings:
[0019] Figure 1 It is a flowchart of the Oracle database synchronization method in the embodiment of the present invention;
[0020] Figure 2 It is a flowchart for verifying the business database and the archiving database in the embodiment of the present invention;
[0021] Figure 3 The flowchart for table configuration in the embodiments of the present invention;
[0022] Figure 4 The flowchart for synchronizing expired data in the embodiments of the present invention;
[0023] Figure 5 The flowchart for synchronizing data that meets the requirements of a preset time period in the embodiments of the present invention;
[0024] Figure 6 The schematic diagram of the Oracle database synchronization device in the embodiments of the present invention;
[0025] Figure 7 The schematic diagram of the computer device in the embodiments of the present invention. Detailed implementation manners
[0026] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer and more understandable, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Herein, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but not to limit the present invention.
[0027] In the description of this specification, the terms "include", "comprise", "have", "contain", etc. are all open-ended terms, that is, they are intended to include but not limited to. The descriptions referring to terms such as "an embodiment", "a specific embodiment", "some embodiments", "for example", etc. mean that the specific features, structures or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. The order of steps involved in each embodiment is used to schematically illustrate the implementation of the present application, and the order of steps is not limited and can be adjusted appropriately as needed.
[0028] Figure 1 The flowchart of the Oracle database synchronization method in the embodiments of the present invention, as Figure 1 shown, the method includes:
[0029] Step 101, configure a database configuration table and an archive configuration table, wherein the database configuration table includes Oracle business database information, Oracle archive database information, and an archive configuration table name field, and the archive configuration table includes at least a business database table name field, a field for whether to archive expired data, and an archive period field;
[0030] Step 102: After verifying and passing the Oracle business database and the Oracle archive database based on the Oracle business database information and the Oracle archive database information in the database configuration table, read the archive configuration table name in the archive configuration table name field of the database configuration table;
[0031] Step 103: For each business database table in the archive configuration table corresponding to the archive configuration table name, read the field of whether to archive expired data of the business database table;
[0032] Step 1031: When the value of the field of whether to archive expired data of the business database table is "yes", read the first record set that meets the first requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the first record set to the corresponding archive database table; read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archive database table according to the value of the archive period field of the business database table;
[0033] Step 1032: When the value of the field of whether to archive expired data of the business database table is "no", read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archive database table according to the value of the archive period field of the business database table.
[0034] In the embodiment of the present invention, the flashback feature of Oracle data is utilized to synchronize the data in the business database to the archive database. Specifically, by configuring the database configuration table and the archive configuration table, the Oracle database synchronization is automatically executed, with high efficiency, enabling the application program to access all data only by accessing the archive database, which greatly reduces the programming difficulty of the application program.
[0035] Specifically, when implemented, the database configuration table includes Oracle business database information, Oracle archive database information, and an archive configuration table name field. Among them, the Oracle business database information includes a business database name field, a business database user name field, and a business database password field, and the Oracle archive database information includes an archive database name field, an archive database user name field, and an archive database password field. The above Oracle business database information and Oracle archive database information provide the permission information for the application program to access the two databases.
[0036] Figure 2This is a flowchart for validating the business database and the archived database in an embodiment of the present invention. First, the database configuration table is read to obtain Oracle business database information and Oracle archived database information, and then the validation process is carried out.
[0037] In one embodiment, the Oracle business database and the Oracle archived database are validated according to the Oracle business database information and the Oracle archived database information in the database configuration table, including:
[0038] According to the Oracle business database information and the Oracle archived database information, verify whether the models of the Oracle business database and the Oracle archived database are consistent;
[0039] If they are consistent, determine that the verification result is passed;
[0040] If they are inconsistent, determine that the verification result is not passed and generate an alarm message.
[0041] In the above embodiment, the models of the database include the hierarchical model, the network model, and the relational model. Only when the models are consistent, the subsequent synchronization process is carried out, otherwise the synchronization process is exited. Through verification, the security of database synchronization is improved, and the probability of synchronization failure is greatly reduced.
[0042] In one embodiment, the archived configuration table further includes a business data lifespan field, a primary key column field, a time column field, and a business database table ROWID lifespan field;
[0043] After configuring the database configuration table and the archived configuration table, it further includes:
[0044] Configure the archived record table and the archived comparison table. Among them, the archived record table includes a business database table name field and an SCN_last field, and the archived comparison table includes at least a business database table name, a business database table ROWID, an archived database table name, an archived database table ROWID, and an archived time.
[0045] In the above embodiment, the business data lifespan field and the time column field in the archived configuration table provide a basis for subsequent data synchronization, which can ensure the probability of successful synchronization. The primary key column field is used when each row record in the first record set and the second record set is updated or inserted. Similarly, configuring the archived record table and the archived comparison table also provides a basis for subsequent synchronization. By configuring the aforementioned 4 tables, the efficiency and success rate of database synchronization can be ensured. The business database table ROWID lifespan field refers to the storage time recorded in the archived comparison table. Beyond this business database table ROWID lifespan field value, the record will be deleted. This deletion process is not listed in Figure 2 is not listed.
[0046] Figure 3 This is the flowchart for table configuration in the embodiments of the present invention. The configuration sequence is, in turn, the database configuration table, the archiving configuration table, the archiving record table, and the archiving comparison table. Among them, the unit of the archiving period field value in the archiving configuration table is minutes. Considering the impact on system performance, the recommended value is 1 minute. The ROWID of the archiving database table is the ROWID of the data row in the target database.
[0047] In step 1031, the value of the field "whether to archive expired data" in the business database table is "yes". At this time, the expired data in the business data table is synchronized. After completion, the data that meets the requirements of the preset time period is synchronized. In step 1032, the value of the field "whether to archive expired data" in the business database table is "no". At this time, the data that meets the requirements of the preset time period is synchronized. By dividing the steps of synchronizing the two databases, the flexibility of database synchronization is improved, and the database data can be synchronized as needed.
[0048] In one embodiment, the first requirement is the records with the value of the OPERATION_VERSION field in the business database table being empty;
[0049] The second requirement is the records with the value of the OPERAGTION_VERSION field between the m-th row and the n-th row in the business database table not being empty. m is the value of the SCN_sys field in the Oracle business database; n is the value of the SCN_last field of the business database table in the archiving record table.
[0050] In the above embodiment, the business database table exists in the flashback cache. For each business database table, there is an OPERATION_VERSION field. The records with the value of the OPERATION_VERSION field in the business database table being empty are read out to form a first record set; the records with the value of the OPERAGTION_VERSION field between the m-th row and the n-th row in the business database table not being empty are read out to form a second record set. Among them, m is the value of the SCN_sys field in the Oracle business database, which can be directly read and is a fixed value. n is the value of the SCN_last field of the business database table in the archiving record table, and n can be updated. By setting two record sets, the expired data and the data that meets the requirements of the preset time period can be synchronized respectively, improving the efficiency.
[0051] It should be noted that if there are multiple business database tables in the archiving configuration table, during synchronization, the multiple business database tables can execute the synchronization process in parallel or sequentially, and the synchronization method can be flexibly selected as needed.
[0052] For step 1031, Figure 4The following is the flowchart for synchronizing expired data in an embodiment of the present invention. In one embodiment, synchronizing the first record set to the corresponding archived database table includes:
[0053] For each row record in the first record set, determine whether the value of the ROWID field in the business database table of this row record exists in the archive comparison table;
[0054] If it exists, update this row record to the corresponding archived database table;
[0055] If it does not exist, insert this row record into the corresponding archived database table, and insert the ROWID of the business database table of this row record into the archive comparison table.
[0056] In the above process, it is determined whether to update or insert based on the value of the ROWID field in the business database table, with clear logic and a high synchronization success rate.
[0057] For step 1032, Figure 5 The following is the flowchart for synchronizing data that meets the requirements of a preset time period in an embodiment of the present invention. In one embodiment, synchronize the second record set to the corresponding archived database table according to the value of the archive period field in this business database table, including:
[0058] For each row record in the second record set, obtain the value of the OPERAGTION_VERSION field of this row record;
[0059] If the value of the OPERAGTION_VERSION field of this row record is I, insert this row record into the corresponding archived database table, and insert the ROWID of the business database table of this row record into the archive comparison table;
[0060] If the value of the OPERAGTION_VERSION field of this row record is U, update this row record to the corresponding archived database table;
[0061] If the value of the OPERAGTION_VERSION field of this row record is D, determine whether the value of the time column field of this row record is within the value of the business data lifespan field. If so, delete this row record from the corresponding archived database table and delete the ROWID of the business database table of this row record from the archive comparison table;
[0062] Update the value of the SCN_last field of this business database table in the archive record table.
[0063] In the above embodiment, automated synchronization is achieved by using a pre-configured archive comparison table, archive record table, and archive configuration table respectively, with high efficiency.
[0064] In summary, in the method proposed in the embodiment of the present invention, a database configuration table and an archiving configuration table are configured. The database configuration table includes Oracle business database information, Oracle archiving database information, and an archiving configuration table name field. The archiving configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archiving period field. After verifying and passing the Oracle business database and the Oracle archiving database according to the Oracle business database information and the Oracle archiving database information in the database configuration table, the archiving configuration table name in the database configuration table is read. For each business database table in the archiving configuration table corresponding to the archiving configuration table name, the field indicating whether to archive expired data of the business database table is read. When the value of the field indicating whether to archive expired data of the business database table is "yes", a first record set that meets the first requirement of the business database table is read from the flashback cache of the Oracle business database, and the first record set is synchronized to the corresponding archiving database table. A second record set that meets the second requirement of the business database table is read from the flashback cache of the Oracle business database, and the second record set is synchronized to the corresponding archiving database table according to the value of the archiving period field of the business database table. When the value of the field indicating whether to archive expired data of the business database table is "no", a second record set that meets the second requirement of the business database table is read from the flashback cache of the Oracle business database, and the second record set is synchronized to the corresponding archiving database table according to the value of the archiving period field of the business database table. In the above process, the Oracle data flashback feature is utilized to synchronize the data in the business database to the archiving database. Specifically, by configuring the database configuration table and the archiving configuration table, the Oracle database synchronization is automatically executed, with high efficiency, enabling the application program to access all data only by accessing the archiving database, which greatly reduces the programming difficulty of the application program.
[0065] The embodiment of the present invention also proposes an Oracle database synchronization device, the principle of which is similar to that of the Oracle database synchronization method and will not be elaborated here.
[0066] Figure 6 For the schematic diagram of the Oracle database synchronization device in the embodiment of the present invention, as Figure 6 shown, the device includes:
[0067] A configuration module 601, configured to configure a database configuration table and an archiving configuration table, where the database configuration table includes Oracle business database information, Oracle archiving database information, and an archiving configuration table name field, and the archiving configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archiving period field;
[0068] The verification module 602 is used to, after verifying and passing the Oracle business database and the Oracle archive database according to the Oracle business database information and the Oracle archive database information in the database configuration table, read the archive configuration table name in the archive configuration table name field of the database configuration table;
[0069] The data reading module 603 is used to, for each business database table in the archive configuration table corresponding to the archive configuration table name, read the field of whether to archive expired data of the business database table;
[0070] The first synchronization module 6031 is used to, when the value of the field of whether to archive expired data of the business database table is yes, read the first record set that meets the first requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the first record set to the corresponding archive database table; call the second synchronization module 6032 to read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archive database table according to the value of the archive period field of the business database table;
[0071] The second synchronization module 6032 is used to, when the value of the field of whether to archive expired data of the business database table is no, read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archive database table according to the value of the archive period field of the business database table.
[0072] In one embodiment, the archive configuration table further includes a business data lifespan field, a primary key column field, a time column field, and a business database table ROWID lifespan field;
[0073] The configuration module 601 is further used to: configure an archive record table and an archive comparison table, where the archive record table includes a business database table name field and an SCN_last field, and the archive comparison table at least includes a business database table name, a business database table ROWID, an archive database table name, an archive database table ROWID, and an archive time.
[0074] In one embodiment, the verification module 602 is specifically used to:
[0075] Verify whether the models of the Oracle business database and the Oracle archive database are consistent according to the Oracle business database information and the Oracle archive database information;
[0076] If they are consistent, determine that the verification result is passed;
[0077] If they are inconsistent, determine that the verification result is not passed and generate an alarm message.
[0078] In one embodiment, the first requirement is for records where the value of the OPERATION_VERSION field in the business database table is empty;
[0079] The second requirement is for records where the value of the OPERAGTION_VERSION field between the m-th row and the n-th row of the business database table is not empty, where m is the value of the SCN_sys field in the Oracle business database; and n is the value of the SCN_last field of the business database table in the archive record table.
[0080] In one embodiment, the first synchronization module 6031 is specifically configured to:
[0081] For each row record in the first record set, determine whether the value of the ROWID field of the business database table of this row record exists in the archive comparison table;
[0082] If it exists, update this row record to the corresponding archive database table;
[0083] If it does not exist, insert this row record into the corresponding archive database table, and insert the ROWID of the business database table of this row record into the archive comparison table.
[0084] In one embodiment, the second synchronization module 6032 is specifically configured to:
[0085] For each row record in the second record set, obtain the value of the OPERAGTION_VERSION field of this row record;
[0086] If the value of the OPERAGTION_VERSION field of this row record is I, insert this row record into the corresponding archive database table, and insert the ROWID of the business database table of this row record into the archive comparison table;
[0087] If the value of the OPERAGTION_VERSION field of this row record is U, update this row record to the corresponding archive database table;
[0088] If the value of the OPERAGTION_VERSION field of this row record is D, determine whether the value of the time column field of this row record is within the value of the business data lifespan field. If so, delete this row record from the corresponding archive database table, and delete the ROWID of the business database table of this row record from the archive comparison table;
[0089] Update the value of the SCN_last field of this business database table in the archive record table.
[0090] In summary, in the device proposed in the embodiments of the present invention, a configuration module is used to configure a database configuration table and an archiving configuration table. The database configuration table includes Oracle business database information, Oracle archiving database information, and an archiving configuration table name field. The archiving configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archiving period field. A verification module is used to, after verifying and passing the Oracle business database and the Oracle archiving database according to the Oracle business database information and the Oracle archiving database information in the database configuration table, read the name of the archiving configuration table in the archiving configuration table name field of the database configuration table. A data reading module is used to, for each business database table in the archiving configuration table corresponding to the archiving configuration table name, read the field indicating whether to archive expired data of the business database table. A first synchronization module is used to, when the value of the field indicating whether to archive expired data of the business database table is "yes", read a first record set that meets the first requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the first record set to the corresponding archiving database table; call a second synchronization module to read a second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archiving database table according to the value of the archiving period field of the business database table. A second synchronization module is used to, when the value of the field indicating whether to archive expired data of the business database table is "no", read a second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archiving database table according to the value of the archiving period field of the business database table. In the above process, the Oracle data flashback feature is utilized to synchronize the data in the business database to the archiving database. Specifically, by configuring the database configuration table and the archiving configuration table, the Oracle database synchronization is automatically executed, with high efficiency, enabling the application program to access all data only by accessing the archiving database, which greatly reduces the programming difficulty of the application program.
[0091] An embodiment of the present application also provides a computer device, Figure 7 which is a schematic diagram of the computer device in the embodiments of the present invention. The computer device can implement all steps in the Oracle database synchronization method in the above embodiments. The computer device specifically includes the following:
[0092] a processor 701, a memory 702, a communication interface 703, and a communication bus 704;
[0093] Among them, the processor 701, the memory 702, and the communication interface 703 complete mutual communication through the communication bus 704; the communication interface 703 is used to implement information transmission between related devices such as server-side devices, detection devices, and client-side devices;
[0094] The processor 701 is used to call the computer program in the memory 702, and when the processor executes the computer program, all steps in the Oracle database synchronization method in the above-mentioned embodiments are implemented.
[0095] An embodiment of the present application further provides a computer-readable storage medium that can implement all steps in the Oracle database synchronization method in the above-mentioned embodiments. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all steps in the Oracle database synchronization method in the above-mentioned embodiments are implemented.
[0096] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0097] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate for implementing in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the function specified in one block or multiple blocks.
[0098] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the function specified in one block or multiple blocks.
[0099] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are executed on the computer or other programmable apparatus to generate a computer-implemented process, thereby providing instructions for implementing the process Figure 1 one process or a plurality of processes and / or blocks Figure 1 steps for the functions specified in one block or a plurality of blocks.
[0100] The specific embodiments described above have further elaborated on the purpose, technical solutions, and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. An Oracle database synchronization method, characterized in that, Including: Configuring a database configuration table and an archiving configuration table, where the database configuration table includes Oracle business database information, Oracle archiving database information, and an archiving configuration table name field, and the archiving configuration table at least includes a business database table name field, a field for whether to archive expired data, and an archiving period field; After verifying and passing the Oracle business database and the Oracle archiving database according to the Oracle business database information and the Oracle archiving database information in the database configuration table, reading the name of the archiving configuration table in the archiving configuration table name field in the database configuration table; For each business database table in the archiving configuration table corresponding to the archiving configuration table name, reading the field for whether to archive expired data of the business database table; When the value of the field for whether to archive expired data of the business database table is "yes", reading a first record set that meets the first requirement from the flashback cache of the Oracle business database, and synchronizing the first record set to the corresponding archiving database table; reading a second record set that meets the second requirement from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archiving database table according to the value of the archiving period field of the business database table; When the value of the field for whether to archive expired data of the business database table is "no", reading a second record set that meets the second requirement from the flashback cache of the Oracle business database, and synchronizing the second record set to the corresponding archiving database table according to the value of the archiving period field of the business database table; The first requirement is a record with an empty value in the OPERATION_VERSION field of the business database table; The second requirement is a record with a non-empty value in the OPERATION_VERSION field between the m-th row and the n-th row of the business database table, where m is the value of the SCN_sys field in the Oracle business database; n is the value of the SCN_last field of the business database table in the archiving record table; Synchronizing the first record set to the corresponding archiving database table includes: for each row record in the first record set, determining whether the value of the ROWID field of the business database table of the row record exists in the archiving comparison table; if it exists, updating the row record to the corresponding archiving database table; if it does not exist, inserting the row record into the corresponding archiving database table, and inserting the ROWID of the business database table of the row record into the archiving comparison table; Synchronize the second record set to the corresponding archived database table according to the value of the archiving period field in the business database table, including: for each row record in the second record set, obtain the value of the OPERAGTION_VERSION field of this row record; if the value of the OPERAGTION_VERSION field of this row record is I, insert this row record into the corresponding archived database table, and insert the ROWID of the business database table of this row record into the archiving comparison table; if the value of the OPERAGTION_VERSION field of this row record is U, update this row record to the corresponding archived database table; if the value of the OPERAGTION_VERSION field of this row record is D, determine whether the value of the time column field of this row record is within the value of the business data lifespan field, and if so, delete this row record from the corresponding archived database table and delete the ROWID of the business database table of this row record from the archiving comparison table; update the value of the SCN_last field of this business database table in the archiving record table.
2. The Oracle database synchronization method according to claim 1, wherein Verify the Oracle business database and the Oracle archived database according to the Oracle business database information and the Oracle archived database information in the database configuration table, including: Verify whether the models of the Oracle business database and the Oracle archived database are consistent according to the Oracle business database information and the Oracle archived database information; If they are consistent, determine that the verification result is passed; If they are inconsistent, determine that the verification result is not passed and generate an alarm message.
3. The Oracle database synchronization method according to claim 1, characterized in that, The archived configuration table further includes a business data lifespan field, a primary key column field, a time column field, and a business database table ROWID lifespan field; After configuring the database configuration table and the archived configuration table, it further includes: Configure the archiving record table and the archiving comparison table, where the archiving record table includes a business database table name field and an SCN_last field, and the archiving comparison table at least includes a business database table name, a business database table ROWID, an archived database table name, an archived database table ROWID, and an archiving time.
4. An Oracle database synchronization device, characterized in that, Including: A configuration module for configuring the database configuration table and the archived configuration table, where the database configuration table includes Oracle business database information, Oracle archived database information, and an archived configuration table name field, and the archived configuration table at least includes a business database table name field, a field indicating whether to archive expired data, and an archiving period field; A verification module for reading the name of the archived configuration table in the archived configuration table name field in the database configuration table after verifying and passing the Oracle business database and the Oracle archived database according to the Oracle business database information and the Oracle archived database information in the database configuration table; A data reading module for reading the field indicating whether to archive expired data of each business database table in the archived configuration table corresponding to the archived configuration table name. The first synchronization module is used to, when the value of the field indicating whether to archive expired data in the business database table is "yes", read the first record set that meets the first requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the first record set to the corresponding archived database table; call the second synchronization module to read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archived database table according to the value of the archiving period field of the business database table; The second synchronization module is used to, when the value of the field indicating whether to archive expired data in the business database table is "no", read the second record set that meets the second requirement of the business database table from the flashback cache of the Oracle business database, and synchronize the second record set to the corresponding archived database table according to the value of the archiving period field of the business database table; The first requirement is the record with the value of the OPERATION_VERSION field in the business database table being empty; The second requirement is the record with the value of the OPERATION_VERSION field not being empty between the m-th row and the n-th row of the business database table, where m is the value of the SCN_sys field in the Oracle business database; n is the value of the SCN_last field of the business database table in the archived record table; Synchronizing the first record set to the corresponding archived database table includes: for each row record in the first record set, determining whether the value of the ROWID field of the business database table of this row record exists in the archiving comparison table; if it exists, updating this row record to the corresponding archived database table; if it does not exist, inserting this row record into the corresponding archived database table and inserting the ROWID of the business database table of this row record into the archiving comparison table; Synchronizing the second record set to the corresponding archived database table according to the value of the archiving period field of the business database table includes: for each row record in the second record set, obtaining the value of the OPERAGTION_VERSION field of this row record; if the value of the OPERAGTION_VERSION field of this row record is "I", inserting this row record into the corresponding archived database table and inserting the ROWID of the business database table of this row record into the archiving comparison table; if the value of the OPERAGTION_VERSION field of this row record is "U", updating this row record to the corresponding archived database table; if the value of the OPERAGTION_VERSION field of this row record is "D", determining whether the value of the time column field of this row record is within the value of the business data lifespan field; if it is, deleting this row record from the corresponding archived database table and deleting the ROWID of the business database table of this row record from the archiving comparison table; updating the value of the SCN_last field of the business database table in the archived record table.
5. The Oracle database synchronization device according to claim 4, wherein The archived configuration table further includes a business data lifespan field, a primary key column field, a time column field, and a ROWID lifespan field of the business database table; The configuration module is further configured to: configure an archiving record table and an archiving comparison table, wherein the archiving record table includes a business database table name field and an SCN_last field, and the archiving comparison table includes at least a business database table name, a business database table ROWID, an archiving database table name, an archiving database table ROWID, and an archiving time.
6. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Data archiving method, system and equipment and storage medium
CN109726174A
Expired data archiving method and device
CN110866006A