A partition table processing method, system, storage medium and electronic device
By automatically performing partition table transformations using preset scripts, the problems of low efficiency and risk of misoperation in existing technologies are solved, achieving efficient partition table transformation without business interruption.
Patent Information
- Application Number
- CN202211152085.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-21
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-09-21
AI Technical Summary
Existing technologies for converting ordinary tables into partitioned tables are inefficient and pose a risk of human error.
The system obtains the initial table through a preset script, determines that it is a regular table, retrieves the partition type selected by the user, and automatically performs partition table modification operations based on the parameters of the partition type, avoiding manual export and import and ensuring that business continuity is not affected.
It enables the automatic transformation of ordinary tables into partitioned tables without affecting business operations, improving transformation efficiency and avoiding errors caused by manual operation.
Smart Images

Figure CN115495451B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database maintenance, and more particularly to a partition table processing method and system, a storage medium and an electronic device. BACKGROUND
[0002] A common table refers to an object in a database for storing data, and is a structured data collection. A partition table refers to dividing a single table into multiple objects and storing these parts in different locations. A table that is partitioned is referred to as a partition table, and each part that is divided is referred to as a partition.
[0003] A partition table in a database Oracle has many advantages over a common table, such as improved query performance of the table, data of the partition table being stored in multiple parts, and loading and deleting data by partition being easier and more efficient than loading and deleting in the table. Therefore, it is necessary to transform a common table into a partition table.
[0004] A conventional way of transforming a common table into a partition table is to first create a partition table, and then manually export the original table and import it into the partition table. The transformation process is cumbersome, resulting in low transformation efficiency of the conventional way of transforming a common table into a partition table. SUMMARY
[0005] Therefore, the present application discloses a partition table processing method and system, a storage medium and an electronic device, which aims to automatically complete the partition table transformation operation of a common table without affecting the business, avoid the risk of manual processing errors, and improve the efficiency of transforming a common table into a partition table.
[0006] To achieve the above object, the disclosed technical solution is as follows:
[0007] The first aspect of the present application discloses a partition table processing method, which comprises:
[0008] obtaining an initial table through a preset script; the initial table is used to represent an initial table to be transformed into a partition table;
[0009] when the initial table exists a check table and the initial table is a common table, obtaining a partition type selected by a user; the partition type at least includes a range partition, a selection list partition or a hash partition;
[0010] determining a partition parameter corresponding to the partition type, and triggering a partition table transformation operation according to the partition parameter corresponding to the partition type; the partition table transformation operation is a partition table transformation operation without stopping the business.
[0011] Preferably, the initial table is obtained through a preset script, which comprises:
[0012] starting a preset script, and generating first prompt information through the preset script; the first prompt information is prompt information for obtaining an initial table to be converted into a partitioned table;
[0013] obtaining the initial table through the first prompt information.
[0014] Preferably, when the initial table exists a check table and the initial table is a normal table, a partition type selected by a user is obtained, including:
[0015] If the initial table exists a number dictionary view and an object corresponding to the number dictionary view, it is determined that the initial table exists the check table.
[0016] If the initial table does not exist partition table information, it is determined that the initial table is the normal table.
[0017] When the initial table exists the check table and the initial table is the normal table, the partition type selected by the user is obtained.
[0018] Preferably, the method further comprises:
[0019] If the initial table does not exist a number dictionary and an object corresponding to the number dictionary view, it is determined that the initial table does not exist the check table.
[0020] Preferably, the method further comprises:
[0021] If the initial table exists the partition table information, it is determined that the initial table is the partitioned table.
[0022] Preferably, the method further comprises:
[0023] When the partition type selected by the user is a range partition, a column name of a range partition key and a partition interval are obtained, and a partition table conversion operation is triggered according to the column name of the range partition key and the partition interval;
[0024] When the partition type selected by the user is a list partition, a column name of a list partition key and a partition list value are obtained, and the partition table conversion operation is triggered according to the column name of the list partition key and the partition list value;
[0025] When the partition type selected by the user is a hash partition, a column name of a hash partition key and a partition number are obtained, and the partition table conversion operation is triggered according to the column name of the hash partition key and the partition number.
[0026] Preferably, the method further comprises:
[0027] performing a processing data operation on the initial table and generating a trigger; the processing data operation is copying data of the initial table to a first transition table;
[0028] recording database operations on the initial table through the trigger;
[0029] generating a second transition table of a table structure required by a user through the database operations on the initial table and the partition parameter corresponding to the partition type;
[0030] defining the first transition table as a partition table through the second transition table;
[0031] adding constraints and indexes corresponding to the initial table to the partition table; the index represents all index objects on the initial table;
[0032] performing the trigger to record the database operations on the initial table on the partition table; wherein the data of the partition table performing the trigger to record the database operations on the initial table is consistent with the data of the initial table;
[0033] renaming the initial table as a third transition table and renaming the partition table as the table name of the initial table;
[0034] performing a cleaning operation on the trigger to complete the partition table reconstruction operation; the cleaning operation is an operation of deleting the first transition table, the second transition table and the third transition table.
[0035] The second aspect of the present application discloses a processing system of a partition table, the system comprises:
[0036] a first obtaining unit configured to obtain an initial table through a preset script; the initial table represents an initial table to be reconstructed as a partition table;
[0037] a second obtaining unit configured to obtain a partition type selected by a user when a check table exists in the initial table and the initial table is a normal table; the partition type at least includes a range partition, a selected list partition or a hash partition;
[0038] a first determining unit configured to determine a partition parameter corresponding to the partition type and trigger a partition table reconstruction operation according to the partition parameter corresponding to the partition type; the partition table reconstruction operation is a partition table reconstruction operation without stopping business.
[0039] The third aspect of the present application discloses a storage medium comprising stored instructions, wherein when the instructions are running, the device where the storage medium is located performs the processing method of the partition table as any one of the first aspect.
[0040] The fourth aspect of the present application discloses an electronic device, comprising a memory, and one or more instructions, wherein the one or more instructions are stored in the memory and configured to be executed by one or more processors to perform the processing method of the partition table according to any one of the first aspect.
[0041] According to the above technical solution, the present application discloses a processing method, system, storage medium and electronic device of a partition table, an initial table is obtained through a preset script; the initial table is used to represent an initial table to be transformed into a partition table, when the initial table exists a check table and the initial table is a normal table, a partition type selected by a user is obtained, the partition type at least includes a range partition, a selection list partition or a hash partition, partition parameters corresponding to the partition type are determined, and a partition table transformation operation is triggered and executed according to the partition parameters corresponding to the partition type, and the partition table transformation operation is a partition table transformation operation without stopping the business. Through the above scheme, it is not necessary to manually export the original table and import the partition table, only the partition parameters corresponding to the partition type are input to trigger and execute the partition table transformation operation after starting the preset script, the normal table can be automatically completed to perform the partition table transformation operation without affecting the business, the risk of misoperation of manual partition table transformation processing is avoided, and the efficiency of transforming the normal table into the partition table is improved. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the provided drawings.
[0043] Figure 1 A flowchart of a processing method of a partition table disclosed by the embodiments of the present application;
[0044] Figure 2 A structure diagram of a processing system of a partition table disclosed by the embodiments of the present application;
[0045] Figure 3 A structure diagram of an electronic device disclosed by the embodiments of the present application. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0047] In this application, the terms "comprising", "containing" or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, the element defined by the phrase "comprising a" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0048] As known from the background art, the existing way of transforming an ordinary table into a partitioned table is to first create a partitioned table, and then manually export the original table and import it into the partitioned table. Due to the cumbersome transformation process, the transformation efficiency of the existing way of transforming an ordinary table into a partitioned table is low.
[0049] To solve the above problems, the present application discloses a partitioned table processing method, system, storage medium and electronic equipment, which obtains an initial table through a preset script; the initial table is used to represent an initial table to be transformed into a partitioned table; when the initial table exists a check table and the initial table is an ordinary table, a partition type selected by a user is obtained, the partition type at least includes a range partition, a selection list partition or a hash partition, partition parameters corresponding to the partition type are determined, and a partition table transformation operation is triggered and executed according to the partition parameters corresponding to the partition type, and the partition table transformation operation is a partition table transformation operation without stopping the business. Through the above scheme, the original table does not need to be manually exported and imported into the partitioned table, after starting the preset script, the partition table transformation operation is triggered and executed by inputting the partition parameters corresponding to the partition type, so that the ordinary table transformation operation into a partitioned table can be automatically completed without affecting the business, the risk of misoperation of manual partition table transformation processing is avoided, and the efficiency of transforming an ordinary table into a partitioned table is improved. The specific implementation mode is specifically explained by the following embodiments.
[0050] Reference Figure 1 As shown in the figure, it is a flowchart of a partitioned table processing method disclosed by the embodiment of the present application, which mainly includes the following steps:
[0051] S101: Obtain an initial table through a preset script; the initial table is used to represent an initial table to be transformed into a partitioned table.
[0052] The preset script of the present scheme is deployed on the database server; when it is needed to be used, the script starting command is executed and the related parameters are input by the user according to the prompt information until the operation of transforming an ordinary table into a partitioned table is completed. The process of inputting the related parameters by the user can refer to the processes of A1-A3 described below.
[0053] The database server refers to a special server running a database system, and its function is to provide hardware support and guarantee for high-performance operation of the database system.
[0054] The process of obtaining the initial table through the preset script is as follows:
[0055] First, start the preset script, and generate a first prompt information through the preset script; the first prompt information is the prompt information for obtaining the initial table to be transformed into a partition table;
[0056] Among them, the script is executed, the preset script will pop up the first prompt information, and the user is informed to input the table information of the initial table to be transformed into a partition table, and the table name (set) of the initial table is denoted as A.
[0057] Then, the initial table is obtained through the first prompt information.
[0058] Among them, when the first prompt information is received, the initial table is obtained.
[0059] S102: Determine whether the initial table exists a check table, and whether the initial table is a normal table, if the initial table exists a check table, and the initial table is a normal table, execute S103, if the initial table does not exist a check table, and the initial table is not a normal table, return to execute S101.
[0060] In S102, the judgment basis for determining whether the initial table exists a check table and whether the initial table is a normal table is to determine whether the initial table exists the objects corresponding to the query digital dictionary (dba_objects) view and the digital dictionary view, and to view whether the dba_part_tables of the initial table is a partition table.
[0061] If the initial table exists the objects corresponding to the digital dictionary view and the digital dictionary view, it is determined that the initial table exists a check table; if the initial table does not exist the objects corresponding to the digital dictionary and the digital dictionary view, it is determined that the initial table does not exist a check table.
[0062] If the initial table exists partition table information, it is determined that the initial table is a partition table; if the initial table does not exist partition table information, it is determined that the initial table is a normal table.
[0063] Among them, the normal table refers to an object in the database for storing data, which is a structured data set.
[0064] The partition table is to divide a single table into multiple objects, and store these parts in different locations. The table to be partitioned is called a partition table, and each part divided is called a partition.
[0065] If the initial table does not exist a check table, and the initial table is not a normal table, return to execute S101, and prompt the user to re-input the table information of the initial table to be transformed into a partition table.
[0066] S103: Obtain a partition type selected by a user; the partition type at least includes a range partition, a list partition or a hash partition.
[0067] In S103, the range partition, the list partition and the hash partition are three forms of the partition table. The transformation into the partition table is one of the three forms.
[0068] S104: Determine a partition parameter corresponding to the partition type, and trigger the execution of the partition table transformation operation according to the partition parameter corresponding to the partition type; the partition table transformation operation is a partition table transformation operation without stopping the service.
[0069] When the partition type is the range partition, the corresponding partition parameter is the column name of the range partition key and the partition interval.
[0070] When the partition type is the list partition, the corresponding partition parameter is the column name of the list partition key and the partition list value.
[0071] When the partition type is the hash partition, the corresponding partition parameter is the column name of the hash partition key and the number of partitions.
[0072] The specific process of determining the partition parameter corresponding to the partition type and triggering the execution of the partition table transformation operation according to the partition parameter corresponding to the partition type is shown in A1-A3.
[0073] A1: When the partition type selected by the user is the range partition, obtain the column name of the range partition key and the partition interval, and trigger the execution of the partition table transformation operation according to the column name of the range partition key and the partition interval.
[0074] If the partition type selected by the user is the range partition, the user is prompted to input the column name of the range partition key and the partition interval.
[0075] A2: When the partition type selected by the user is the list partition, obtain the column name of the list partition key and the partition list value, and trigger the execution of the partition table transformation operation according to the column name of the list partition key and the partition list value.
[0076] If the partition type selected by the user is the list partition, the user is prompted to input the column name of the list partition key and the partition list value.
[0077] A3: When the partition type selected by the user is the hash partition, obtain the column name of the hash partition key and the number of partitions, and trigger the execution of the partition table transformation operation according to the column name of the hash partition key and the number of partitions.
[0078] If the partition type selected by the user is the hash partition, the user is prompted to input the column name of the hash partition key and the number of partitions.
[0079] The process of performing the partition table reconstruction operation is shown in B1-B8.
[0080] B1: Perform a processing data operation on an initial table (A table) and generate a trigger; the processing data operation is copying data of the initial table to a first transition table (B table).
[0081] The processing data operation (CTAS) is performed on the initial table, and the CTAS is a data manipulation language (DML) / data definition language (DDL) operation of copying data to the B table and generating a trigger to record all DML operations on the A table.
[0082] The DML operation includes all insert, delete, update, merge, etc. operations on the table, such as inserting data, deleting data, or modifying data.
[0083] B2: Record database operations on the A table through the trigger.
[0084] The database operation includes an operation of inserting data, deleting data, or modifying data.
[0085] B3: Generate a second transition table (C table) of a user-required table structure through database operations on the initial table and partition parameters corresponding to the partition type.
[0086] The second transition table of the user-required table structure is determined by user input of table information required to be reconstructed as a partition table.
[0087] B4: Define the B table as a partition table through the C table.
[0088] B5: Add constraints and indexes corresponding to the A table to the partition table; the index represents all index objects on the initial table.
[0089] The constraint includes a not null constraint, a unique constraint, etc.
[0090] B6: Perform a trigger to record database operations on the A table on the partition table; the data of the partition table performing the trigger to record database operations on the initial table is consistent with the data of the A table.
[0091] B7: Rename the A table as a third transition table (D table), and rename the partition table as the table name of the A table.
[0092] B8: Perform a cleaning operation on the trigger to complete the partition table reconstruction operation; the cleaning operation is an operation of deleting the B table, the C table, and the D table.
[0093] By copying B table, trigger records A table DML operation at the same time. By B table, first change B table to partition table, flatten data, add constraint and index, and then rename A table. This process has no effect on A table business except the last step of renaming. No need to stop business, also no missing index, constraint. The query performance of A table will not be affected during the transformation process, and the online transformation of partition table is truly realized.
[0094] In order to facilitate the understanding of the above process of performing partition table transformation operation, examples are given as follows:
[0095] For example, first, CTAS operation is performed on A table to copy data to B table, and trigger is generated to record all DML operations on A table, and partition table C with the table structure required by the user is generated according to the user input information.
[0096] Then, using the online redefinition method provided by ORACLE, B table is transformed into a partition table through C table. At this time, B table is the required partition table, and the data may not be consistent with A table (during A table has DML operation, which will be recorded by trigger, if A table has no DML operation, it means that A table data has no update, and B table is consistent with A table data at this time).
[0097] Finally, the constraints and indexes on A table are added to B table. The DML operation of A table recorded in the trigger is executed on B table (the table name is replaced in advance). After the DML operation is completed, the data of B table is consistent with A table. Then, A table is renamed as D table, and B table is renamed as A table. This step ends, and the operation of transforming ordinary table A into partition table is completed. Then, the trigger is cleaned up, and the intermediate transition B table, C table and D table are deleted. Thus, the whole process is completed, and the program ends.
[0098] In the embodiment of the present application, the initial table is obtained through the preset script, and the initial table is used to represent the initial table to be transformed into a partition table. When the initial table exists a check table and the initial table is a normal table, the partition type selected by the user is obtained, the partition type at least includes range partition, selection list partition or hash partition, the partition parameters corresponding to the partition type are determined, and the partition table transformation operation is triggered and executed according to the partition parameters corresponding to the partition type. The partition table transformation operation is a partition table transformation operation without stopping business. Through the above scheme, without manually exporting the original table and importing the partition table, after starting the preset script, the partition table transformation operation is triggered and executed by inputting the partition parameters corresponding to the partition type, so that the partition table transformation operation of the ordinary table can be automatically completed without affecting the business, the risk of misoperation of manual partition table transformation processing is avoided, and the efficiency of transforming the ordinary table into the partition table is improved.
[0099] Based on the above embodimentFigure 1 The disclosed processing method of a partition table also discloses a processing system of a partition table. Figure 2 As shown in the figure, the processing system of the partition table includes a first acquisition unit 201, a second acquisition unit 202, and a first determination unit 203.
[0100] The first acquisition unit 201 is configured to acquire an initial table through a preset script; the initial table is used to represent an initial table to be transformed into a partition table.
[0101] The second acquisition unit 202 is configured to acquire a partition type selected by a user when the initial table exists a check table and the initial table is a normal table; the partition type at least includes a range partition, a selection list partition, or a hash partition.
[0102] The first determination unit is configured to determine a partition parameter corresponding to the partition type, and trigger a partition table transformation operation according to the partition parameter corresponding to the partition type; the partition table transformation operation is a partition table transformation operation without stopping business.
[0103] Further, the first acquisition unit 201 includes a generation module and a first acquisition module.
[0104] The generation module is configured to start a preset script, and generate a first prompt information through the preset script; the first prompt information is prompt information for acquiring an initial table to be transformed into a partition table.
[0105] The first acquisition module is configured to acquire the initial table through the first prompt information.
[0106] Further, the second acquisition unit 202 includes a first determination module, a second determination module, and a second acquisition module.
[0107] The first determination module is configured to determine that the initial table exists a check table if the initial table exists a number dictionary view and an object corresponding to the number dictionary view.
[0108] The second determination module is configured to determine that the initial table is a normal table if the initial table does not exist a partition table information.
[0109] The second acquisition module is configured to acquire a partition type selected by a user when the initial table exists a check table and the initial table is a normal table.
[0110] Further, the processing system of the partition table also includes a second determination unit.
[0111] The second determination unit is configured to determine that the initial table does not exist a check table if the initial table does not exist an object corresponding to a number dictionary and a number dictionary view.
[0112] Further, the processing system of the partition table also includes a third determination unit.
[0113] The second determining unit is configured to determine that the initial table is a partition table if the initial table has the partition table information.
[0114] Further, the first determining unit 203 comprises a third obtaining module, a fourth obtaining module and a fifth obtaining module.
[0115] The third obtaining module is configured to, when the partition type selected by the user is a range partition, obtain a column name of a range partition key and a partition interval, and trigger execution of a partition table reconstruction operation according to the column name of the range partition key and the partition interval.
[0116] The fourth obtaining module is configured to, when the partition type selected by the user is a list partition, obtain a column name of a list partition key and a partition list value, and trigger execution of a partition table reconstruction operation according to the column name of the partition key and the partition list value.
[0117] The fifth obtaining module is configured to, when the partition type selected by the user is a hash partition, obtain a column name of a hash partition key and a partition number, and trigger execution of a partition table reconstruction operation according to the column name of the hash partition key and the partition number.
[0118] Further, the fifth obtaining module of the process of executing the partition table reconstruction operation comprises an execution submodule, a first recording submodule, a generation submodule, a definition submodule, an adding submodule, a second recording submodule, a renaming submodule and an operation submodule.
[0119] The execution submodule is configured to execute a data processing operation on the initial table, and generate a trigger; the data processing operation is to copy data of the initial table to a first transit transition table.
[0120] The first recording submodule is configured to record database operations on the initial table through the trigger.
[0121] The generation submodule is configured to generate a second transit transition table of a table structure required by the user through database operations on the initial table and partition parameters corresponding to the partition type.
[0122] The definition submodule is configured to define the first transit transition table as a partition table through the second transit transition table.
[0123] The adding submodule is configured to add constraints and indexes corresponding to the initial table to the partition table; the indexes represent all index objects on the initial table.
[0124] The second recording submodule is configured to execute the trigger to record database operations on the initial table on the partition table; data of the partition table executing the trigger to record the database operations on the initial table is consistent with data of the initial table.
[0125] The renaming submodule is configured to rename the initial table as a third transit transition table, and rename the partition table as a table name of the initial table.
[0126] The operation sub-module is configured to perform a cleaning operation on the trigger to complete the partition table reconstruction operation; the cleaning operation is an operation of deleting the first, second and third transition tables.
[0127] In the embodiments of the present application, the original table does not need to be manually exported and the partition table is imported, after starting the preset script, the partition table reconstruction operation is triggered by inputting the partition parameters corresponding to the partition type, so that the ordinary table reconstruction operation is automatically completed without affecting the business, the risk of manual operation is avoided, and the efficiency of the ordinary table reconstruction into the partition table is improved.
[0128] The embodiments of the present application also provide a storage medium, which comprises stored instructions, wherein when the instructions are executed, the device where the storage medium is located performs the processing method of the partition table.
[0129] The embodiments of the present application also provide an electronic device, a structural schematic diagram of which is shown in Figure 3 The electronic device specifically comprises a memory 301 and one or more than one instruction 302, wherein the one or more than one instruction 302 is stored in the memory 301 and is configured to be executed by one or more than one processor 303 to execute the one or more than one instruction 302 to perform the following operations:
[0130] The initial table is obtained through the preset script; the initial table is used to represent the initial table to be reconstructed into a partition table;
[0131] When the initial table exists the check table and the initial table is an ordinary table, the partition type selected by a user is obtained; the partition type at least comprises a range partition, a selected list partition or a hash partition;
[0132] The partition parameters corresponding to the partition type are determined, and the partition table reconstruction operation is triggered according to the partition parameters corresponding to the partition type; the partition table reconstruction operation is a partition table reconstruction operation without stopping the business.
[0133] For the foregoing method embodiments, in order to simply describe, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the action sequence described, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions and modules involved are not necessarily necessary for the present application.
[0134] It should be noted that each of the embodiments in the specification is described in progressive mode, and each embodiment focuses on the difference from other embodiments. The same and similar parts between embodiments can be referred to each other. For system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0135] The steps in the method of each embodiment of the present application can be adjusted, combined and deleted according to actual needs.
[0136] Finally, it should be noted that in this paper, relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations.
[0137] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
[0138] The above is only the preferred embodiment of the present application. It should be noted that for ordinary skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.
Claims
1. A method for processing partitioned tables, characterized in that, The method includes: An initial table is obtained through a preset script; the initial table is used to represent the initial table that needs to be transformed into a partitioned table. When the initial table has a check table and the initial table is a regular table, the partition type selected by the user is obtained; the partition type includes at least range partition, selection list partition, or hash partition. Determine the partition parameters corresponding to the partition type, and trigger the partition table modification operation based on the partition parameters corresponding to the partition type; the partition table modification operation is a partition table modification operation that does not stop the business. Wherein, when the initial table has a check table and the initial table is a regular table, obtaining the partition type selected by the user includes: If the initial table has a numeric dictionary view and an object corresponding to the numeric dictionary view, then it is determined that the initial table has a validation table. If the initial table does not contain partition table information, then the initial table is determined to be a regular table; If the initial table has a check table and the initial table is a regular table, obtain the partition type selected by the user; The process of performing partition table modification operations includes: Perform data processing operations on the initial table and generate triggers; the data processing operations involve copying data from the initial table to a first transit table. The trigger records the database operations on the initial table; A second transit table with the required table structure is generated by using database operations on the initial table and partition parameters corresponding to the partition type. The first transit table is defined as a partition table using the second transit table. Add the constraints and indexes corresponding to the initial table to the partition table; the index represents all index objects on the initial table; The trigger is executed on the partition table to record database operations on the initial table; wherein the data in the partition table that executes the trigger to record database operations on the initial table is consistent with the data in the initial table; The initial table is renamed to the third transit table, and the partition table is renamed to the name of the initial table. The trigger is cleaned up to complete the partition table modification operation; the cleanup operation is to delete the first transit table, the second transit table, and the third transit table.
2. The method according to claim 1, characterized in that, The step of obtaining the initial table through a preset script includes: Start the preset script and generate a first prompt message through the preset script; the first prompt message is a prompt message to obtain the initial table that needs to be transformed into a partitioned table; Obtain the initial table based on the first prompt message.
3. The method according to claim 1, characterized in that, Also includes: If the initial table does not contain a numeric dictionary and an object corresponding to the numeric dictionary view, then it is determined that the initial table does not contain a validation table.
4. The method according to claim 1, characterized in that, Also includes: If the initial table contains partition table information, then the initial table is determined to be a partition table.
5. The method according to claim 1, characterized in that, The step of determining the partition parameters corresponding to the partition type and triggering the partition table modification operation based on the partition parameters corresponding to the partition type includes: When the user selects a range partition, the column name and partition interval of the range partition key are obtained, and the partition table modification operation is triggered based on the column name of the range partition key and the partition interval. When the user selects list partition as the partition type, obtain the column name of the list partition key and the partition list value, and trigger the partition table modification operation based on the column name of the partition key and the partition list value. When the user selects hash partition as the partition type, obtain the column name of the hash partition key and the number of partitions, and trigger the partition table modification operation based on the column name of the hash partition key and the number of partitions.
6. A partition table processing system, characterized in that, The system includes: The first acquisition unit is used to acquire an initial table through a preset script; the initial table is used to characterize the initial table that needs to be transformed into a partitioned table; The second acquisition unit is used to acquire the partition type selected by the user when the initial table has a verification table and the initial table is a regular table; the partition type includes at least range partition, selection list partition, or hash partition. The first determining unit is used to determine the partition parameters corresponding to the partition type, and trigger the execution of a partition table modification operation based on the partition parameters corresponding to the partition type; the partition table modification operation is a partition table modification operation that does not stop the business. The second acquisition unit includes: The first determining module is used to determine that the initial table has a verification table if the initial table has a numeric dictionary view and an object corresponding to the numeric dictionary view. The second determining module is used to determine that the initial table is a regular table if the initial table does not have partition table information; The second acquisition module is used to acquire the partition type selected by the user when the initial table has a verification table and the initial table is a normal table; The process of performing partition table modification operations includes: Perform data processing operations on the initial table and generate triggers; the data processing operations involve copying data from the initial table to a first transit table. The trigger records the database operations on the initial table; A second transit table with the required table structure is generated by using database operations on the initial table and partition parameters corresponding to the partition type. The first transit table is defined as a partition table using the second transit table. Add the constraints and indexes corresponding to the initial table to the partition table; the index represents all index objects on the initial table; The trigger is executed on the partition table to record database operations on the initial table; wherein the data in the partition table that executes the trigger to record database operations on the initial table is consistent with the data in the initial table; The initial table is renamed to the third transit table, and the partition table is renamed to the name of the initial table. The trigger is cleaned up to complete the partition table modification operation; the cleanup operation is to delete the first transit table, the second transit table, and the third transit table.
7. A storage medium, characterized in that, The storage medium includes stored instructions, wherein, when the instructions are executed, the device in which the storage medium resides is controlled to perform the partition table processing method as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, It includes memory, and one or more instructions, wherein one or more instructions are stored in memory and configured to be executed by one or more processors using the partition table processing method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method and system for maintaining range partitioning table based on oracle database system
CN102982186A
Method and device for carrying out partition parallel reading on non-partition table
CN110334096A