Data table processing method and device, equipment, medium and product
By parsing and processing requests and calling built-in functions to generate identification values, the problem of occupancy of database resources when creating identification columns for data tables in the prior art is solved, and the effect of improving data table processing efficiency and database performance is achieved.
Patent Information
- Application Number
- CN202510072747.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-16
AI Technical Summary
When creating identification columns for data tables, the existing technology requires adding new system function objects to occupy database resources, resulting in low data table processing efficiency.
By parsing and processing the request, the generation rule parameters for generating identification values are obtained, and the input parameters of the built-in function are configured according to these parameters. The built-in function is called to generate each identification value of the identification column. Finally, the identification value and source data table map are added to the table schema to generate the target data table.
There is no need to add system function objects to the database, which reduces the use of database resources and improves the efficiency of data table processing and database performance.
Smart Images

Figure CN120011361A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of databases, and in particular to a method, device, equipment, medium and product for processing a data table. Background Art
[0002] In a database management system, an identity column is a special column type that is used to automatically generate and maintain a unique identifier for each row in a table; this identifier plays a vital role in database operations because it ensures the uniqueness and integrity of data and also helps improve the efficiency of data access. Therefore, it is necessary to create an identity column for a data table based on actual business needs.
[0003] At present, some methods for creating identification columns for data tables add a system function object for generating identification columns in the database, and call the system function to generate the identification column when actually generating data for the identification column. However, this solution requires adding a system function object, which occupies object identifiers in the database, reduces database resource utilization, and results in low processing efficiency of the data table. Summary of the invention
[0004] The present application provides a data table processing method, device, equipment, medium and product to improve the processing efficiency of the data table.
[0005] In a first aspect, the present application provides a method for processing a data table, the method comprising: receiving a first processing request, the first processing request being used to request generation of a target data table corresponding to a source data table, the target data table representing the data table after an identification column is added to the source data table, the identification column comprising multiple identification values; parsing to obtain generation rule parameters for the identification value according to the first processing request; the generation rule parameters comprising at least one of the following: data type, starting value, and change amount; configuring input parameters of a built-in function according to the generation rule parameters, and obtaining each identification value of the identification column by calling the built-in function according to the input parameters; wherein the input parameters comprising a data type, a previous identification value, and a change amount; the built-in function being used to calculate the next identification value of the previous identification value according to the input parameters; creating a table structure for the target data table, adding the identification value of the identification column and the source data table mapping to the table structure, and obtaining the target data table.
[0006] In one possible implementation, the input parameters of the built-in function are configured according to the generation rule parameters, including: if the generation rule parameters include a data type, the data type in the generation rule parameters is used as the data type in the input parameters; if the generation rule parameters include a change, the change in the generation rule parameters is used as the change in the input parameters; if the generation rule parameters include a starting value, before the built-in function is called for the first time, the starting value in the generation rule parameters is used as the previous identification value in the input parameters, and, before each subsequent call to the built-in function, the identification value most recently calculated by the built-in function is used as the previous identification value in the input parameters.
[0007] In a possible implementation, the input parameters of the built-in function are configured according to the generation rule parameters, specifically including: if the generation rule parameters do not include a change amount, a preset default change amount is used as the change amount in the input parameter; if the generation rule parameters do not include a starting value, before the built-in function is called for the first time, a preset default starting value is used as the previous identification value in the input parameter.
[0008] In a possible implementation, the default starting value and the default change amount are 1.
[0009] In a possible implementation, the identification value of the identification column and the source data table mapping are added to the table architecture to obtain the target data table, including: according to the first processing request, establishing a parsing expression, and converting the parsing expression into an executable expression; the parsing expression defines a data source corresponding to each column in the target data table; according to the executable expression, obtaining the data source corresponding to each column in the table architecture; wherein the data source corresponding to the identification column is each identification value calculated by a built-in function, and the data source corresponding to other columns is the data under the column corresponding to the column in the source data table; by executing the executable expression, the data source corresponding to each column in the table architecture is added to the column to obtain the target data table.
[0010] In a possible implementation, before parsing the generation rule parameters of the identification value according to the first processing request, it also includes: verifying whether the first processing request contains an auto-increment function; if it does not contain an auto-increment function, determining that the first processing request has failed the verification; if it contains an auto-increment function, verifying whether the first processing request is a selection insert statement, if it is a selection insert statement, determining that the first processing request has passed the verification; if it is not a selection insert statement, determining that the first processing request has failed the verification.
[0011] In a possible implementation, before parsing the generation rule parameters of the identification value according to the first processing request, it also includes: verifying whether the data type defined by the auto-increment function in the first processing request is a numeric type; if it is a numeric type, determining that the first processing request has been verified; if it is not a numeric type, determining that the first processing request has not been verified.
[0012] In one possible implementation, the method also includes: if the data type of the auto-increment function defined in the first processing request is a numerical type with a scale, verifying whether the scale of the numerical type with a scale is 0; if the scale is 0, determining that the first processing request verification is successful; if the scale is not 0, determining that the first processing request verification is unsuccessful.
[0013] In a possible implementation, before parsing the generation rule parameters of the identification value according to the processing request, it also includes: verifying whether the starting value and the change amount defined by the auto-increment function in the first processing request are within the value range corresponding to the data type defined by the auto-increment function; if the starting value and the change amount are both within the value range, it is determined that the first processing request has been verified; otherwise, it is determined that the first processing request has not been verified.
[0014] In a possible implementation, parsing and obtaining the generation rule parameters of the identification value according to the first processing request specifically includes: if the first processing request is verified to be successful, parsing and obtaining the generation rule parameters of the identification value according to the first processing request.
[0015] In a possible implementation, the method further includes: after obtaining the last identification value of the current identification column, establishing a dependency relationship between the identification column of the target data table and the current input parameters, the current input parameters including the data type, the last identification value, and the change amount.
[0016] In a possible implementation, the method also includes: receiving a second processing request, the second processing request is used to request to insert row data into the target data table; according to the second processing request, querying the dependency relationship to obtain the input parameters corresponding to the identification column of the target data table; according to the input parameters corresponding to the identification column of the target data table, calling the built-in function to obtain the identification value corresponding to the row data inserted in the target data table; adding the identification value corresponding to the inserted row data to the identification column of the target data table.
[0017] In a second aspect, the present application provides a data table processing device, the device comprising: a receiving module, used to receive a first processing request, the first processing request is used to request the generation of a target data table corresponding to a source data table, the target data table represents the data table after the source data table is added with an identification column, the identification column including multiple identification values; a parsing module, used to parse and obtain generation rule parameters of the identification value according to the first processing request; the generation rule parameters include at least one of the following: data type, starting value, and change amount; a generating module, used to configure the input parameters of a built-in function according to the generation rule parameters, and obtain each identification value of the identification column by calling the built-in function according to the input parameters; wherein the input parameters include a data type, a previous identification value, and a change amount; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters; a creating module, used to create a table structure of the target data table, add the identification value of the identification column and the source data table mapping to the table structure, and obtain the target data table.
[0018] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the above method.
[0019] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the above method.
[0020] In a fifth aspect, the present application provides a computer program product, including a computer program, which is used to implement the above method when executed by a processor.
[0021] In the data table processing method, device, equipment, medium and product provided by the present application, the generation rule parameters for generating identification values are obtained by parsing the processing request; the input parameters of the built-in function are configured according to the generation rule parameters; after each identification value of the identification column is obtained by calling the built-in function according to the input parameters, the identification value of the identification column obtained and the source data table mapping are added to the table architecture to obtain the target data table including the identification column. This solution can generate identification values by calling a unified built-in function in response to the processing request, without adding a new system function object in the database, reducing the occupation of object identifiers in the database, saving database resources, and improving the performance of the database system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] Figure 1 A schematic diagram of a process flow of a data table processing method is exemplified;
[0024] Figure 2 A schematic diagram of a process flow of a data table processing method is exemplified;
[0025] Figure 3 A schematic diagram of a process flow of a data table processing method is exemplified;
[0026] Figure 4 A schematic diagram of a process flow of a data table processing method is exemplified;
[0027] Figure 5 A schematic diagram of a process flow of a data table processing method is exemplified;
[0028] Figure 6 A schematic diagram of a process flow of a data table processing method is exemplified;
[0029] Figure 7 A schematic diagram of a process flow of a data table processing method is exemplified;
[0030] Figure 8 is a flowchart of a method for processing a data table according to an example;
[0031] Fig. 9 A schematic diagram of the structure of a data table processing device is shown in FIG.
[0032] Fig.10 A structural schematic diagram of an electronic device is exemplarily shown in FIG.
[0033] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0035] It should be noted that the brief description of the terms in this application is only for the convenience of understanding the implementation methods described below, and is not intended to limit the implementation methods of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings. The terms "first", "second", etc. in the specification and claims and the above-mentioned drawings in this application are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise indicated. It should be understood that the terms used in this way can be interchangeable where appropriate, for example, they can be implemented in an order other than those given in the diagram or description of the embodiment of this application. The terms "including" and "having" in the specification and claims and the above-mentioned drawings in this application and any of their variations are intended to cover but not exclude inclusion, for example, a product or device containing a series of components is not necessarily limited to those components clearly listed, but may include other components that are not clearly listed or inherent to these products or devices. The term "module" used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic or a combination of hardware or / and software code that can perform functions related to the element.
[0036] In a database management system, an identity column is a special column type that is used to automatically generate and maintain a unique identifier for each row in a table; this identifier plays a vital role in database operations because it ensures the uniqueness and integrity of data and also helps improve the efficiency of data access. Therefore, it is necessary to create an identity column for a data table based on actual business needs.
[0037] At present, in some methods for creating identification columns for data tables, a system function object for generating identification columns is added to the database. When actually generating data for the identification column, it is necessary to call different system function objects according to the information contained in the processing request sent by the user and the processing request with different information to generate the identification column; for example, when the processing request only includes the function name and the data type, the corresponding system function object needs to be called to generate the identification column; when the processing request includes the function name, the data type, the starting value and the growth value, another corresponding system function object needs to be called to generate the identification column; this solution needs to add corresponding system function objects for processing requests in various situations, which will occupy the object identifiers in the database, resulting in reduced database resource utilization and affecting the performance of the database; when a large amount of data needs to be processed, calling different system functions separately will also reduce the processing efficiency of the data table.
[0038] The technical content provided by this application is intended to solve some technical problems of related technologies such as those mentioned above. In the data table processing method, device, equipment, medium and product of this application, by parsing the processing request, the generation rule parameters for generating the identification value are obtained; according to the generation rule parameters, the input parameters of the built-in function are configured; according to the input parameters, after calling the built-in function to obtain each identification value of the identification column, the identification value of the identification column obtained and the source data table mapping are added to the table architecture to obtain the target data table including the identification column. This solution can generate identification values by calling a unified built-in function in response to the processing request, without adding a new system function object in the database, reducing the occupation of object identifiers in the database, saving database resources, and improving the performance of the database system.
[0039] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0040] Embodiment 1
[0041] Figure 1 A flow chart of a method for processing a data table is shown in FIG. Figure 1 As shown, the method includes:
[0042] Step 101: Receive a first processing request, where the first processing request is used to request generation of a target data table corresponding to a source data table, where the target data table represents a data table after an identification column is added to the source data table, where the identification column includes multiple identification values;
[0043] Step 102: According to the first processing request, parse and obtain generation rule parameters of the identification value; the generation rule parameters include at least one of the following: data type, starting value, and change amount;
[0044] Step 103: according to the generation rule parameters, configure the input parameters of the built-in function, and obtain each identification value of the identification column by calling the built-in function according to the input parameters; wherein the input parameters include the data type, the previous identification value and the change amount; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters;
[0045] Step 104: Create a table schema for the target data table, add the identification value of the identification column and the source data table mapping to the table schema, and obtain the target data table.
[0046] Specifically, a first processing request is received; wherein the first processing request is a processing request for requesting to generate a target data table corresponding to the source data table according to the source data table; the target data table represents a data table including an identification column, and the identification column includes multiple identification values. In this example, the source data table is a data table that already exists in the database and is the source of the target data table to be created; the first processing request represents to create a new target data table by querying the data in the source data table, and to add an identification column to the target data table. According to the received first processing request, the generation rule parameters of the identification value in the first processing request are parsed; the parameters of the identification value generation rule include: at least one of the data type, the starting value, and the change amount. In actual application, the data type in the generation rule parameter represents the data type of the identification column, the starting value represents the starting value of the identification value generated for the identification column, and the starting value is usually the first identification value of the identification column, and the change amount represents the growth value or the decrease value of the identification value generated. Afterwards, according to the generation rule parameters of the identification value obtained by parsing, the input parameters are configured for the built-in function generating the identification value; according to the input parameters, the built-in function is called to obtain each identification value of the identification column. According to the generation rule parameters, the input parameters of the built-in function are obtained, and the input parameters include the data type, the previous identification value, and the change amount; as an example, a sequence object can be created according to the generation rule parameters, and the sequence includes the data type, the starting value of the generation rule parameters, the previous identification value, and the change amount; wherein the previous identification value is the input parameter used to obtain the next identification value according to the sequence. After the sequence is created, the built-in function is called to generate the identification value; the data type of the identification value is the data type of the generation rule parameter, and the previous identification value of the input parameter before the first call to the function is the starting value of the generation rule parameter. According to the previous identification value and the change amount, the built-in function is called to obtain the next identification value until all the identification values of the identification column are obtained; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters; exemplary, the built-in function is the nextval (get next value) function; in actual applications, the nextval function is usually used in conjunction with the sequence object; the nextval function is used to obtain the next value of the sequence; a sequence is a database object specially designed to generate unique numbers, which are usually increasing; by calling the nextval function, it can be ensured that the next value in the sequence is obtained each time. Next, based on the received first processing request, a table schema of the target data table is created; in actual applications, the processing request includes relevant attribute information of the source data table and the target data table, such as data type, table name, column name of each column and attributes of each column, etc.; the table schema represents the structure of the target data table, and the target data table includes an identification column. The table schema of the target data table is created based on the number of rows and columns in the target data table, the data type of each column, the attributes of each column, the data type of the identification column, the position of the identification column in the target data table, and whether the identification column is a non-empty column and other related information.By adding the identification value of the identification column obtained above and the source data table mapping to the created table structure, a complete target data table can be obtained. In this example, the identification value generation rule parameters are obtained by directly parsing the processing request sent by the received user, and the input parameters of the built-in function are obtained according to the parsed rule parameters. The built-in function is called to generate the identification value, which improves the processing efficiency of the data table; avoids occupying the database object identifier due to the addition of a system function object to generate an identification column, improves the storage space utilization of the database, and thus optimizes the performance of the database.
[0047] Specifically, different input parameters of the built-in function need to be configured according to different generation rule parameters; accordingly, as an example; Figure 2 A flowchart of a method for processing a data table is exemplified; based on any example, input parameters of a built-in function are configured according to generation rule parameters, including:
[0048] Step 201: If the generation rule parameter contains a data type, the data type in the generation rule parameter is used as the data type in the input parameter;
[0049] Step 202: If the generation rule parameters include a change amount, the change amount in the generation rule parameters is used as the change amount in the input parameters;
[0050] Step 203: If the generation rule parameters include a starting value, before the built-in function is called for the first time, the starting value in the generation rule parameters is used as the previous identification value in the input parameters, and then before each call to the built-in function, the identification value most recently calculated by the built-in function is used as the previous identification value in the input parameters.
[0051] Specifically, if the generated rule parameter obtained by parsing contains a data type, the data type of the generated rule parameter is used as the data type of the built-in function. If the generated rule parameter obtained by parsing contains a change amount, the change amount of the generated rule parameter is used as the change amount of the built-in function; in practical applications, the change amount represents the growth value of the generated identity column, and the growth value usually refers to the incremental step set for the identity column in the database; this step determines how the column value will increase each time new data is inserted into the table. If the generated rule parameter obtained by parsing includes a starting value, the starting value is used as the first identity value of the identity column; and before the first call to the built-in function, the starting value is used as the previous identity value in the input parameter; thereafter, before each call to the built-in function, the identity value calculated by the built-in function is used as the previous identity value of the input parameter; each identity value in this example is obtained by adding the calculated previous identity value to the change amount. In this example, the input parameters of the built-in function are determined according to the data type, starting value, and change amount of the generation rule parameters, and the built-in function is subsequently called to calculate the identity value of the identity column, making the calculation result of the identity value more accurate; and this example can flexibly configure parameters for the built-in function according to the data type, starting value, and growth value obtained by parsing, thereby improving the scalability of the built-in function input parameters.
[0052] Furthermore, Figure 3 A flowchart of a method for processing a data table is exemplified; based on any example, the input parameters of the built-in function are configured according to the generation rule parameters, specifically including:
[0053] Step 301: If the generation rule parameters do not include a change amount, a preset default change amount is used as the change amount in the input parameters;
[0054] Step 302: If the generation rule parameters do not include a starting value, before the built-in function is called for the first time, a preset default starting value is used as the previous identification value in the input parameter.
[0055] In actual applications, when the generation rule parameter of the identification value obtained by parsing the processing request transmitted by the user does not include a change amount, a preset default change amount is used as the change amount of the input parameter; exemplarily, after receiving the first processing request, the received first processing request is parsed, and the generation rule parameter obtained after the parsing does not include a change amount, a default change amount is pre-set, and the default change amount is used as the change amount of the input parameter. Similarly, when the generation rule parameter of the identification value obtained by parsing the processing request transmitted by the user does not include a starting value, the preset default starting value is used as the previous identification value of the input parameter before the first call to the built-in function; exemplarily, after receiving the first processing request, the received first processing request is parsed, and the generation rule parameter obtained after the parsing does not include a starting value, a default starting value is pre-set, and the default starting value is used as the previous identification value in the input parameter before the first call to the built-in function. In this example, when the generation rule parameters only include the data type but do not include the starting value and the change amount, the preset default change amount is used as the change amount of the input parameter; and before the built-in function is called for the first time, the preset default starting value is used as the previous identification value of the input parameter, and then the built-in function is called to calculate the identification value of the identification column based on the input parameters, thereby improving the accuracy of the identification value calculation results.
[0056] Specifically, the default starting value and the default change amount in this example are 1.
[0057] The default starting value and the default change are set to 1; the default starting value of 1 is used as the previous identification value before the first call of the built-in function, that is, the first identification value is 1; the previous identification value before the first call of the built-in function is 1. The default change is set to 1 as the default change in the input parameter of the built-in function; at this time, the growth value of the generated identification value is 1. Exemplarily, the first identification value is 1, the change is 1, and the next identification value generated by calling the built-in function is the sum of the previous identification value and the change, then the second identification value is 2; and so on, the generated representation column is a continuous identification column value; in practical applications, continuous identification column values make data management easier and more efficient, and facilitate subsequent query, sorting and analysis operations; unified starting value and change value make database design more standardized and normalized. In this example, the default starting value and default change are set to 1, and the input parameters of the built-in function are obtained according to the default starting value and default change of 1; subsequently, according to the input parameters obtained, the built-in function is called to generate the identification value of the identification column, which improves the accuracy of generating identification columns and improves the efficiency of generating identification columns.
[0058] Further, it is necessary to generate a complete target data table according to the data required by the target data table and the table schema of the created target data table; accordingly, as an example; Figure 4A flowchart of a method for processing a data table is exemplified; based on any example, the identification value of the identification column and the source data table mapping are added to the table schema to obtain a target data table, including:
[0059] Step 401: Establish a parsing expression according to the first processing request, and convert the parsing expression into an executable expression; the parsing expression defines a data source corresponding to each column in the target data table;
[0060] Step 402: Obtain the data source corresponding to each column in the table schema according to the executable expression; wherein the data source corresponding to the identification column is each identification value calculated by the built-in function, and the data source corresponding to other columns is the data under the corresponding column of the column in the source data table;
[0061] Step 403: By executing the executable expression, the data source corresponding to each column in the table schema is added to the column to obtain the target data table.
[0062] Specifically, according to the received first processing request, a parsing expression is established; the parsing expression defines the data source corresponding to each column in the target data table; exemplary, the parsing expression defines the source of the data source corresponding to each column in the target data table, for example, from which column of the source data table the data actually to be inserted into each column in the target data table is obtained; the table name of the source data table, the column name of each column, the data type and attribute information of each column, etc.; and the structural information, column name, and attribute information of each column of the target data table; the target data table includes an identification column, and the parsing expression also defines the relevant information of the identification column, including the attribute information of the identification column and the position information of the column where the identification column is located, etc. According to the parsed key information, a parsing expression is established, and the parsing expression is converted into an executable expression; the executable expression is the actual execution expression used to create the target data table in the actual execution stage; according to the executable expression obtained after the conversion, the data source corresponding to each column is obtained; wherein, the data source corresponding to the identification column is each identification value calculated by the aforementioned built-in function; the data source of other columns includes the data under the corresponding column of each column in the source data table, and the data of other columns is obtained from the source data table. Exemplarily, the target data table may also include some columns, which are obtained through specified operations based on some columns in the source data table. In this case, the data required for the column is calculated according to the specified operation rules. After the data required for the target data table is prepared, the data source corresponding to each column in the created table structure is added to the column by executing the executable expression to obtain a complete target data table. In this example, by establishing a parsing expression containing the data source corresponding to each column in the target data table according to the first processing request, the parsing expression is converted into an executable expression; and the data source of each column of the table structure of the target data table is obtained by executing the executable expression, and the data of the target data table is filled into the table structure of the created target data table to obtain a complete target data table; the accuracy and completeness of the target data table generation are improved.
[0063] Specifically, before parsing the generation rule parameters of the identification value according to the processing request, the processing request must be verified; accordingly, as an example; Figure 5 A flowchart of a method for processing a data table is exemplified; based on any example, before parsing the generation rule parameters of the identification value according to the first processing request, it also includes:
[0064] Step 501: Verify whether the first processing request contains an auto-increment function;
[0065] Step 502: If the auto-increment function is not included, it is determined that the first processing request verification fails;
[0066] Step 503: If the auto-increment function is included, verify whether the first processing request is a selective insert statement. If it is a selective insert statement, determine that the first processing request has passed the verification; if it is not a selective insert statement, determine that the first processing request has not passed the verification.
[0067] In practical applications, the auto-increment function represents a function for generating an identification column for a data table; after receiving the first processing request sent by the user, it is first necessary to verify whether the first processing request contains the auto-increment function, that is, whether this request is a request for generating an identification column; if the first processing request does not contain the auto-increment function, it is determined that the first processing request has not been verified. For example, if the first processing request has not been verified, an error may be reported without performing subsequent related processing. If the first processing request contains the auto-increment function, it is verified whether the first processing request is a select insert statement. If the first processing request is a select insert statement, it is determined that the first processing request has been verified, that is, the first processing request is a request to generate a target data table corresponding to the source data table according to the source data table; if the first processing request is not a select insert statement, it is determined that the first processing request has not been verified, which means that the first processing request is not a request to generate a target data table of the source data table according to the source data table. At this time, it is determined that the first processing request has not been verified and an error is reported. In this example, by verifying whether the first processing request contains an auto-increment function and whether it is a select insert statement, the accuracy of the target data table generation and the identification column generation in the target data table can be guaranteed; at the same time, the problem of low processing efficiency caused by subsequent problems in the data table processing process due to lack of verification is avoided, thereby improving the efficiency of data table processing.
[0068] Specifically, after verifying that the first processing request contains an auto-increment function and is a select insert statement, further other related verifications are required; accordingly, as an example; Figure 6 A flowchart of a method for processing a data table is exemplified; based on any example, before parsing the generation rule parameters of the identification value according to the first processing request, it also includes:
[0069] Step 601: Verify whether the data type defined by the increment function in the first processing request is a numeric type;
[0070] Step 602: If it is a numerical type, determine that the first processing request is verified to be successful;
[0071] Step 603: If it is not a numeric type, it is determined that the first processing request verification fails.
[0072] Specifically, when the first processing request is received, it is also necessary to verify whether the data type defined by the auto-increment function in the first processing request is a numeric type; in actual applications, the auto-increment function in the first processing request indicates the generation of an identifier column, and the data type of the generated identifier column is usually a numeric type; therefore, it is necessary to verify whether the data type defined by the first function is a numeric type; if the data type defined by the auto-increment function is a numeric type; then it is determined that the first processing request has been verified; if the fixed-point data type of the auto-increment function in the first processing request is not a numeric type, then it is determined that the first processing request has not been verified, an error is reported, and subsequent processing is not performed. In this example, whether the data type defined by the auto-increment function in the first processing request is a numeric type is verified to ensure that the data type of the generated identifier column is a numeric type, thereby improving the accuracy of the identifier column generation.
[0073] Furthermore, after determining that the data type is a numerical type, it is also necessary to determine whether the data type is a numerical type with a scale, and perform further verification; accordingly, as an example, the method further includes:
[0074] If the data type defined by the increment function in the first processing request is a numerical type with a scale, verifying whether the scale of the numerical type with a scale is 0;
[0075] If the scale is 0, it is determined that the first processing request verification has passed; if the scale is not 0, it is determined that the first processing request verification has not passed.
[0076] Specifically, when the data type defined by the increment function in the first processing request is a numerical type with a scale, it is necessary to further verify whether the scale of the numerical type with a scale is 0. If the scale is 0, it is determined that the first processing request verification has passed. If the scale is not 0, it is determined that the first processing request verification has not passed. At this time, an error is reported and subsequent processing is not performed. In practical applications, the scale usually refers to the number of digits after the decimal point in a numerical value; it determines the precision of the numerical value, that is, how many digits can be after the decimal point; for example, if the scale is 2, then the value will be retained to two decimal places. In this example, it is necessary to ensure that the scale of the numerical type with a scale is 0, that is, an integer numerical type; this ensures the accuracy of the results generated by the identity column, and also improves the processing efficiency of the data table.
[0077] Furthermore, it is also necessary to verify the starting value and the change amount defined by the auto-increment function in the first processing request; accordingly, as an example, Figure 7 A flowchart of a method for processing a data table is exemplified; based on any example, before parsing and obtaining generation rule parameters of an identification value according to a processing request, the method further includes:
[0078] Step 701: Verify whether the starting value and the change amount of the auto-increment function defined in the first processing request are within the value range corresponding to the data type defined by the auto-increment function;
[0079] Step 702: If the initial value and the change amount are both within the value range, it is determined that the first processing request verification has passed; otherwise, it is determined that the first processing request verification has not passed.
[0080] Specifically, it is also necessary to verify whether the starting value and the change amount defined in the auto-increment function in the first processing request are within the value range corresponding to the data type defined by the auto-increment function; in actual applications, after determining the data type, the value range corresponding to the corresponding data type can be obtained; verify whether the starting value and the change amount are within the value range. If both the starting value and the change amount are within the value range, it is determined that the first processing request has been verified; otherwise, it is determined that the first processing request has not been verified, an error is reported, and subsequent processing is not performed; in this example, by verifying that the starting value and the change amount defined in the auto-increment function are within the value range corresponding to the data type, the accuracy of the definition of the starting value and the change amount is ensured, further improving the accuracy of the generated identification value and ensuring the processing efficiency of the data table.
[0081] After the verification of the first processing request is completed, the corresponding processing is determined according to the verification result; accordingly, as an example; according to the first processing request, the generation rule parameters of the identification value are parsed, specifically including:
[0082] If the first processing request is verified to be successful, then the generation rule parameters of the identification value are parsed according to the first processing request.
[0083] Specifically, if the first processing request is verified, that is, the first processing request contains an auto-increment function, the first processing request is a select insert statement, the data type defined by the auto-increment function in the first processing request is a numeric type, if it is a numeric type with a scale, the scale is 0, and the starting value and the change amount defined by the auto-increment function in the first processing request are both within the value range of the data type; if the above verifications are all passed, the generation rule parameters of the identification value can be parsed according to the first processing request. In this example, the first processing request is verified, and the generation rule parameters of the identification value can be parsed according to the first processing request; the processing efficiency of the data table and the accuracy of the generated identification column are improved.
[0084] Furthermore, it is necessary to generate a dependency relationship between the input parameter and the identification column of the target data table; accordingly, as an example, the method further includes:
[0085] After obtaining the last identification value of the current identification column, a dependency relationship is established between the identification column of the target data table and the current input parameters, where the current input parameters include the data type, the last identification value, and the change amount.
[0086] Specifically, after the last identification value of the identification column in the target data table is generated, a dependency relationship is established between the identification column of the created target data table and the current input parameters; at this time, the current input parameters include the data type, the last identification value, and the change. In combination with the above example, a sequence can be established based on the data type, the previous identification value, and the change. At this time, the sequence includes the data type, the last identification value, and the change. A dependency relationship is established between the sequence consisting of the last identification value, the data type, and the change and the identification column of the data table, and this relationship is recorded in the database. In this example, by establishing a dependency relationship between the target data table and the current input parameters and storing them in the database, the reliability of the maintenance of the target data table is improved and the efficiency of subsequent database-related processing is guaranteed.
[0087] Furthermore, the dependency relationship obtained above is stored in a database, and other database-related operations can be performed later based on the dependency relationship; accordingly, as an example, the method further includes:
[0088] receiving a second processing request, where the second processing request is used to request inserting row data into a target data table;
[0089] According to the second processing request, query the dependency relationship to obtain the input parameter corresponding to the identification column of the target data table;
[0090] According to the input parameter corresponding to the identity column of the target data table, call the built-in function to obtain the identity value corresponding to the row data inserted in the target data table;
[0091] Add the identity value corresponding to the inserted row data to the identity column of the target data table.
[0092] Specifically, a second processing request for inserting row data into the aforementioned established target data table is received; according to the received second processing request, the aforementioned dependency relationship is queried to obtain the input parameter corresponding to the identification column of the target data table; according to the input parameter corresponding to the identification column of the target data table, a built-in function is called to obtain the identification value corresponding to the inserted row data in the target data table; the obtained identification value corresponding to the inserted row data is added to the identification column of the target data table to obtain the identification column after the row data is inserted into the target data table. In this example, when inserting new row data into the target data table, the identification value corresponding to the inserted row data is obtained by calling the built-in function according to the aforementioned dependency relationship to update the identification column, thereby improving the processing efficiency of the data table and the accuracy of updating the identification column.
[0093] As an example, Figure 8 FIG. 1 is a flow chart of a method for processing a data table according to an example; Figure 8As shown, first, a first processing request is received; it is verified whether the first processing request contains an auto-increment function. If the first processing request does not contain an auto-increment function, it is determined that the verification fails and an error is reported; if the first processing request contains an auto-increment function, it is determined that the verification passes. It is further verified whether the first processing request is a select-insert statement. If the first processing request is not a select-insert statement, it is determined that the verification fails and an error is reported; if the first processing request is a select-insert statement, it is determined that the verification passes. It is further verified whether the data type defined by the auto-increment function in the first processing request is a numerical type. If it is not a numerical type, it is determined that the verification fails and an error is reported; if it is a numerical type, the verification passes, and it is further determined whether the data type defined by the auto-increment function is a numerical type with a scale. If it is a numerical type with a scale, it is verified whether the scale of the numerical type with a scale is 0. If the scale is not 0, the verification fails and an error is reported; if the scale is 0, it is determined that the verification passes. Further verify whether the starting value and the change amount defined by the auto-increment function in the first processing request are within the value range corresponding to the data type; if at least one of the starting value and the change amount is not within the value range, it is determined that the verification has not passed and an error is reported; if both the starting value and the change amount are within the value range, the verification is passed. If the data type of the auto-increment function in the first processing request is a numerical type, but not a numerical type with a scale, it is also further verified whether the starting value and the change amount defined by the auto-increment function in the first processing request are within the value range corresponding to the data type. After all the above verifications are passed, the generation rule parameters of the identification column are parsed and generated according to the first processing request; and the input parameters of the built-in function are configured according to the generation rule parameters, and the built-in function is called according to the input parameters to obtain the identification value of the identification column. Afterwards, according to the first processing request, a parsing expression is created, and the parsing expression is converted into an executable expression; the architecture of the target data table is created; according to the executable expression, the data source of the target data table is obtained and inserted into the architecture of the target data table to obtain the target data table; finally, the identification column of the target data table is established with the input parameters after the last generation of the identification value.
[0094] In the data table processing method provided by this embodiment, by parsing the processing request, the generation rule parameters for generating the identification value are obtained; according to the generation rule parameters, the input parameters of the built-in function are configured; according to the input parameters, after calling the built-in function to obtain each identification value of the identification column, the identification value of the identification column and the source data table mapping are added to the table architecture to obtain the target data table including the identification column. This solution can generate the identification value by calling a unified built-in function in response to the processing request, without adding a new system function object in the database, reducing the occupation of the object identifier in the database, saving database resources, and improving the performance of the database system.
[0095] Embodiment 2
[0096] Fig. 9A schematic diagram of the structure of a data table processing device is shown in FIG. Fig. 9 As shown, the device comprises:
[0097] Receiving module 21: used for receiving a first processing request, the first processing request is used for requesting to generate a target data table corresponding to a source data table, the target data table represents a data table after adding an identification column to the source data table, the identification column includes a plurality of identification values;
[0098] Parsing module 22: used for parsing and obtaining generation rule parameters of the identification value according to the first processing request; the generation rule parameters include at least one of the following: data type, starting value, and change amount;
[0099] Generating module 23: configured to configure the input parameters of the built-in function according to the generating rule parameters, and obtain each identification value of the identification column by calling the built-in function according to the input parameters; wherein the input parameters include the data type, the previous identification value and the change amount; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters;
[0100] Creation module 24: used to create a table schema of a target data table, add the identification value of the identification column and the source data table mapping to the table schema, and obtain the target data table.
[0101] Specifically, a first processing request is received; wherein the first processing request is a processing request for requesting to generate a target data table corresponding to the source data table according to the source data table; the target data table represents a data table including an identification column, and the identification column includes multiple identification values. In this example, the source data table is a data table that already exists in the database and is the source of the target data table to be created; the first processing request represents to create a new target data table by querying the data in the source data table, and to add an identification column to the target data table. According to the received first processing request, the generation rule parameters of the identification value in the first processing request are parsed; the parameters of the identification value generation rule include: at least one of the data type, the starting value, and the change amount. In actual application, the data type in the generation rule parameter represents the data type of the identification column, the starting value represents the starting value of the identification value generated for the identification column, and the starting value is usually the first identification value of the identification column, and the change amount represents the growth value of the generated identification value. Afterwards, according to the generation rule parameters of the identification value obtained by parsing, the input parameters are configured for the built-in function for generating the identification value; according to the input parameters, the built-in function is called to obtain each identification value of the identification column. According to the generation rule parameters, the input parameters of the built-in function are obtained, and the input parameters include the data type, the previous identification value, and the change amount; as an example, a sequence object can be created according to the generation rule parameters, and the sequence includes the data type, the starting value of the generation rule parameters, the previous identification value, and the change amount; wherein the previous identification value is the input parameter used to obtain the next identification value according to the sequence. After the sequence is created, the built-in function is called to generate the identification value; the data type of the identification value is the data type of the generation rule parameter, and the previous identification value of the input parameter before the first call to the function is the starting value of the generation rule parameter. According to the previous identification value and the change amount, the built-in function is called to obtain the next identification value until all the identification values of the identification column are obtained; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters; exemplary, the built-in function is the nextval (get next value) function; in actual applications, the nextval function is usually used in conjunction with the sequence object; the nextval function is used to obtain the next value of the sequence; a sequence is a database object specially designed to generate unique numbers, which are usually increasing; by calling the nextval function, it can be ensured that the next value in the sequence is obtained each time. Next, based on the received first processing request, a table schema of the target data table is created; in actual applications, the processing request includes relevant attribute information of the source data table and the target data table, such as data type, table name, column name of each column and attributes of each column, etc.; the table schema represents the structure of the target data table, and the target data table includes an identification column. The table schema of the target data table is created based on the number of rows and columns in the target data table, the data type of each column, the attributes of each column, the data type of the identification column, the position of the identification column in the target data table, and whether the identification column is a non-empty column and other related information.By adding the identification value of the identification column obtained above and the source data table mapping to the created table structure, a complete target data table can be obtained. In this example, the identification value generation rule parameters are obtained by directly parsing the processing request sent by the received user, and the input parameters of the built-in function are obtained according to the parsed rule parameters. The built-in function is called to generate the identification value, which improves the processing efficiency of the data table; avoids occupying the database object identifier due to the addition of a system function object to generate an identification column, improves the storage space utilization of the database, and thus optimizes the performance of the database.
[0102] Specifically, it is necessary to configure different input parameters of the built-in function according to different generation rule parameters; accordingly, as an example; the generation module 23 is used for:
[0103] If the generation rule parameters contain data types, the data types in the generation rule parameters will be used as the data types in the input parameters;
[0104] If the generation rule parameters contain a change amount, the change amount in the generation rule parameters will be used as the change amount in the input parameters;
[0105] If the generation rule parameters contain a starting value, then before the built-in function is called for the first time, the starting value in the generation rule parameters is used as the previous identification value in the input parameters. And, before each subsequent call to the built-in function, the identification value most recently calculated by the built-in function is used as the previous identification value in the input parameters.
[0106] Specifically, if the generated rule parameter obtained by parsing contains a data type, the data type of the generated rule parameter is used as the data type of the built-in function. If the generated rule parameter obtained by parsing contains a change amount, the change amount of the generated rule parameter is used as the change amount of the built-in function; in practical applications, the change amount represents the growth value of the generated identity column, and the growth value usually refers to the incremental step set for the identity column in the database; this step determines how the column value will increase each time new data is inserted into the table. If the generated rule parameter obtained by parsing includes a starting value, the starting value is used as the first identity value of the identity column; and before the first call to the built-in function, the starting value is used as the previous identity value in the input parameter; thereafter, before each call to the built-in function, the identity value calculated by the built-in function is used as the previous identity value of the input parameter; each identity value in this example is obtained by adding the calculated previous identity value to the change amount. In this example, the input parameters of the built-in function are determined according to the data type, starting value, and change amount of the generation rule parameters, and the built-in function is subsequently called to calculate the identity value of the identity column, making the calculation result of the identity value more accurate; and this example can flexibly configure parameters for the built-in function according to the data type, starting value, and growth value obtained by parsing, thereby improving the scalability of the built-in function input parameters.
[0107] Furthermore, the generating module 23 is also used for:
[0108] If the generation rule parameters do not include the change amount, the preset default change amount will be used as the change amount in the input parameters;
[0109] If the generation rule parameters do not contain a starting value, the preset default starting value is used as the previous identification value in the input parameter before the built-in function is called for the first time.
[0110] In actual applications, when the generation rule parameter of the identification value obtained by parsing the processing request transmitted by the user does not include a change amount, a preset default change amount is used as the change amount of the input parameter; exemplarily, after receiving the first processing request, the received first processing request is parsed, and the generation rule parameter obtained after the parsing does not include a change amount, a default change amount is pre-set, and the default change amount is used as the change amount of the input parameter. Similarly, when the generation rule parameter of the identification value obtained by parsing the processing request transmitted by the user does not include a starting value, the preset default starting value is used as the previous identification value of the input parameter before the first call to the built-in function; exemplarily, after receiving the first processing request, the received first processing request is parsed, and the generation rule parameter obtained after the parsing does not include a starting value, a default starting value is pre-set, and the default starting value is used as the previous identification value in the input parameter before the first call to the built-in function. In this example, when the generation rule parameters only include the data type but do not include the starting value and the change amount, the preset default change amount is used as the change amount of the input parameter; and before the built-in function is called for the first time, the preset default starting value is used as the previous identification value of the input parameter, and then the built-in function is called to calculate the identification value of the identification column based on the input parameters, thereby improving the accuracy of the identification value calculation results.
[0111] Specifically, the default starting value and the default change amount are 1.
[0112] The default starting value and the default change are set to 1; the default starting value of 1 is used as the previous identification value before the first call of the built-in function, that is, the first identification value is 1; the previous identification value before the first call of the built-in function is 1. The default change is set to 1 as the default change in the input parameter of the built-in function; at this time, the growth value of the generated identification value is 1. Exemplarily, the first identification value is 1, the change is 1, and the next identification value generated by calling the built-in function is the sum of the previous identification value and the change, then the second identification value is 2; and so on, the generated representation column is a continuous identification column value; in practical applications, continuous identification column values make data management easier and more efficient, and facilitate subsequent query, sorting and analysis operations; unified starting value and change value make database design more standardized and normalized. In this example, the default starting value and default change are set to 1, and the input parameters of the built-in function are obtained according to the default starting value and default change of 1; subsequently, according to the input parameters obtained, the built-in function is called to generate the identification value of the identification column, which improves the accuracy of generating identification columns and improves the efficiency of generating identification columns.
[0113] Furthermore, it is necessary to generate a complete target data table according to the data required by the target data table and the table structure of the created target data table; accordingly, as an example; the creation module 24 is used to:
[0114] According to the first processing request, a parsing expression is established, and the parsing expression is converted into an executable expression; the parsing expression defines a data source corresponding to each column in the target data table;
[0115] According to the executable expression, obtain the data source corresponding to each column in the table schema; the data source corresponding to the identity column is the identity values calculated by the built-in function, and the data source corresponding to other columns is the data under the corresponding column of the column in the source data table;
[0116] By executing the executable expression, the data source corresponding to each column in the table schema is added to the column to obtain the target data table.
[0117] Specifically, according to the received first processing request, a parsing expression is established; the parsing expression defines the data source corresponding to each column in the target data table; exemplary, the parsing expression defines the source of the data source corresponding to each column in the target data table, for example, from which column of the source data table the data actually to be inserted into each column in the target data table is obtained; the table name of the source data table, the column name of each column, the data type and attribute information of each column, etc.; and the structural information, column name, and attribute information of each column of the target data table; the target data table includes an identification column, and the parsing expression also defines the relevant information of the identification column, including the attribute information of the identification column and the position information of the column where the identification column is located, etc. According to the parsed key information, a parsing expression is established, and the parsing expression is converted into an executable expression; the executable expression is the actual execution expression used to create the target data table in the actual execution stage; according to the executable expression obtained after the conversion, the data source corresponding to each column is obtained; wherein, the data source corresponding to the identification column is each identification value calculated by the aforementioned built-in function; the data source of other columns includes the data under the corresponding column of each column in the source data table, and the data of other columns is obtained from the source data table. Exemplarily, the target data table may also include some columns, which are obtained through specified operations based on some columns in the source data table. In this case, the data required for the column is calculated according to the specified operation rules. After the data required for the target data table is prepared, the data source corresponding to each column in the created table structure is added to the column by executing the executable expression to obtain a complete target data table. In this example, by establishing a parsing expression containing the data source corresponding to each column in the target data table according to the first processing request, the parsing expression is converted into an executable expression; and the data source of each column of the table structure of the target data table is obtained by executing the executable expression, and the data of the target data table is filled into the table structure of the created target data table to obtain a complete target data table; the accuracy and completeness of the target data table generation are improved.
[0118] Specifically, before parsing the generation rule parameters of the identification value according to the processing request, the processing request must be verified; accordingly, as an example, the device also includes: a verification module 25, the verification module 25 is used to:
[0119] Verifying whether the first processing request includes an auto-increment function;
[0120] If the auto-increment function is not included, it is determined that the first processing request verification has failed;
[0121] If the auto-increment function is included, verify whether the first processing request is a selective insert statement. If it is a selective insert statement, determine that the first processing request has passed the verification; if it is not a selective insert statement, determine that the first processing request has not passed the verification.
[0122] In practical applications, the auto-increment function represents a function for generating an identification column for a data table; after receiving the first processing request sent by the user, it is first necessary to verify whether the first processing request contains the auto-increment function, that is, whether this request is a request for generating an identification column; if the first processing request does not contain the auto-increment function, it is determined that the first processing request has not been verified. For example, if the first processing request has not been verified, an error may be reported without performing subsequent related processing. If the first processing request contains the auto-increment function, it is verified whether the first processing request is a select insert statement. If the first processing request is a select insert statement, it is determined that the first processing request has been verified, that is, the first processing request is a request to generate a target data table corresponding to the source data table according to the source data table; if the first processing request is not a select insert statement, it is determined that the first processing request has not been verified, which means that the first processing request is not a request to generate a target data table of the source data table according to the source data table. At this time, it is determined that the first processing request has not been verified and an error is reported. In this example, by verifying whether the first processing request contains an auto-increment function and whether it is a select insert statement, the accuracy of the target data table generation and the identification column generation in the target data table can be guaranteed; at the same time, the problem of low processing efficiency caused by subsequent problems in the data table processing process due to lack of verification is avoided, thereby improving the efficiency of data table processing.
[0123] Specifically, after verifying that the first processing request contains an auto-increment function and is a select insert statement, other related verifications need to be further performed; accordingly, as an example; the verification module 25 is also used to:
[0124] Verify whether the data type defined by the increment function in the first processing request is a numeric type;
[0125] If it is a numeric type, it is determined that the first processing request verification is passed;
[0126] If it is not a numeric type, it is determined that the first processing request verification fails.
[0127] Specifically, when the first processing request is received, it is also necessary to verify whether the data type defined by the auto-increment function in the first processing request is a numeric type; in actual applications, the auto-increment function in the first processing request indicates the generation of an identifier column, and the data type of the generated identifier column is usually a numeric type; therefore, it is necessary to verify whether the data type defined by the first function is a numeric type; if the data type defined by the auto-increment function is a numeric type; then it is determined that the first processing request has been verified; if the fixed-point data type of the auto-increment function in the first processing request is not a numeric type, then it is determined that the first processing request has not been verified, an error is reported, and subsequent processing is not performed. In this example, whether the data type defined by the auto-increment function in the first processing request is a numeric type is verified to ensure that the data type of the generated identifier column is a numeric type, thereby improving the accuracy of the identifier column generation.
[0128] Further, after determining that it is a numerical type, it is also necessary to determine whether the data type is a numerical type with a scale, and perform further verification; accordingly, as an example, the verification module 25 is also used for:
[0129] If the data type defined by the increment function in the first processing request is a numerical type with a scale, verifying whether the scale of the numerical type with a scale is 0;
[0130] If the scale is 0, it is determined that the first processing request verification has passed; if the scale is not 0, it is determined that the first processing request verification has not passed.
[0131] Specifically, when the data type defined by the increment function in the first processing request is a numerical type with a scale, it is necessary to further verify whether the scale of the numerical type with a scale is 0. If the scale is 0, it is determined that the first processing request verification has passed. If the scale is not 0, it is determined that the first processing request verification has not passed. At this time, an error is reported and subsequent processing is not performed. In practical applications, the scale usually refers to the number of digits after the decimal point in a numerical value; it determines the precision of the numerical value, that is, how many digits can be after the decimal point; for example, if the scale is 2, then the value will be retained to two decimal places. In this example, it is necessary to ensure that the scale of the numerical type with a scale is 0, that is, an integer numerical type; this ensures the accuracy of the results generated by the identity column, and also improves the processing efficiency of the data table.
[0132] Furthermore, it is also necessary to verify the starting value and the change amount defined by the auto-increment function in the first processing request; accordingly, as an example, the verification module 25 is also used to:
[0133] Verify whether the starting value and the change amount of the auto-increment function defined in the first processing request are within the value range corresponding to the data type defined by the auto-increment function;
[0134] If the initial value and the change are both within the value range, it is determined that the first processing request verification has passed; otherwise, it is determined that the first processing request verification has failed.
[0135] Specifically, it is also necessary to verify whether the starting value and the change amount defined in the auto-increment function in the first processing request are within the value range corresponding to the data type defined by the auto-increment function; in actual applications, after determining the data type, the value range corresponding to the corresponding data type can be obtained; verify whether the starting value and the change amount are within the value range. If both the starting value and the change amount are within the value range, it is determined that the first processing request has been verified; otherwise, it is determined that the first processing request has not been verified, an error is reported, and subsequent processing is not performed; in this example, by verifying that the starting value and the change amount defined in the auto-increment function are within the value range corresponding to the data type, the accuracy of the definition of the starting value and the change amount is ensured, further improving the accuracy of the generated identification value and ensuring the processing efficiency of the data table.
[0136] After the verification of the first processing request is completed, the corresponding processing is determined according to the verification result; accordingly, as an example; the parsing module 22 is used to:
[0137] If the first processing request is verified to be successful, then the generation rule parameters of the identification value are parsed according to the first processing request.
[0138] Specifically, if the first processing request is verified, that is, the first processing request contains an auto-increment function, the first processing request is a select insert statement, the data type defined by the auto-increment function in the first processing request is a numeric type, if it is a numeric type with a scale, the scale is 0, and the starting value and the change amount defined by the auto-increment function in the first processing request are both within the value range of the data type; if the above verifications are all passed, the generation rule parameters of the identification value can be parsed according to the first processing request. In this example, the first processing request is verified, and the generation rule parameters of the identification value can be parsed according to the first processing request; the processing efficiency of the data table and the accuracy of the generated identification column are improved.
[0139] Furthermore, it is necessary to generate a dependency relationship between the input parameter and the identification column of the target data table; accordingly, as an example, the device further includes: an adding module 26, the adding module 26 is used to:
[0140] After obtaining the last identification value of the current identification column, a dependency relationship is established between the identification column of the target data table and the current input parameters, where the current input parameters include the data type, the last identification value, and the change amount.
[0141] Specifically, after the last identification value of the identification column in the target data table is generated, a dependency relationship is established between the identification column of the created target data table and the current input parameters; at this time, the current input parameters include the data type, the last identification value, and the change. In combination with the above example, a sequence can be established based on the data type, the previous identification value, and the change. At this time, the sequence includes the data type, the last identification value, and the change. A dependency relationship is established between the sequence consisting of the last identification value, the data type, and the change and the identification column of the data table, and this relationship is recorded in the database. In this example, by establishing a dependency relationship between the target data table and the current input parameters and storing them in the database, the reliability of the maintenance of the target data table is improved and the efficiency of subsequent database-related processing is guaranteed.
[0142] Furthermore, the dependency relationship obtained above is stored in a database, and other database-related operations can be performed later based on the dependency relationship; accordingly, as an example, the device further includes an updating module 27, which is used to:
[0143] receiving a second processing request, where the second processing request is used to request inserting row data into a target data table;
[0144] According to the second processing request, query the dependency relationship to obtain the input parameter corresponding to the identification column of the target data table;
[0145] According to the input parameter corresponding to the identity column of the target data table, call the built-in function to obtain the identity value corresponding to the row data inserted in the target data table;
[0146] Add the identity value corresponding to the inserted row data to the identity column of the target data table.
[0147] Specifically, a second processing request for inserting row data into the aforementioned established target data table is received; according to the received second processing request, the aforementioned dependency relationship is queried to obtain the input parameter corresponding to the identification column of the target data table; according to the input parameter corresponding to the identification column of the target data table, a built-in function is called to obtain the identification value corresponding to the inserted row data in the target data table; the obtained identification value corresponding to the inserted row data is added to the identification column of the target data table to obtain the identification column after the row data is inserted into the target data table. In this example, when inserting new row data into the target data table, the identification value corresponding to the inserted row data is obtained by calling the built-in function according to the aforementioned dependency relationship to update the identification column, thereby improving the processing efficiency of the data table and the accuracy of updating the identification column.
[0148] The data table processing device provided in this embodiment obtains generation rule parameters for generating identification values by parsing the processing request; configures the input parameters of the built-in function according to the generation rule parameters; after calling the built-in function to obtain each identification value of the identification column according to the input parameters, the identification value of the identification column and the source data table mapping obtained are added to the table architecture to obtain the target data table including the identification column. This solution can generate identification values by calling a unified built-in function in response to the processing request, without adding a new system function object in the database, reducing the occupation of object identifiers in the database, saving database resources, and improving the performance of the database system.
[0149] Embodiment 3
[0150] Fig.10 exemplarily shows a structural schematic diagram of an electronic device, the device comprising:
[0151] The device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, the memory 292, and the communication interface 293 may communicate with each other through the bus 294. The communication interface 293 may be used for information transmission. The processor 291 may call the logic instructions in the memory 292 to execute the above-mentioned example method.
[0152] In addition, the logic instructions in the above-mentioned memory 292 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0153] The memory 292 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, implementing the methods in the above method examples.
[0154] The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0155] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method in any embodiment.
[0156] An embodiment of the present application also provides a computer program product, including a computer program, which is used to implement the method in any embodiment when executed by a processor.
[0157] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0158] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed in the same time period, but can be executed in different time periods, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0159] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0160] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0161] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc.
[0162] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0163] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0164] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only.
[0165] It should be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.
[0166] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variation, use or adaptation of the present invention, which follows the general principles of the present invention and includes common knowledge or conventional techniques in the art not disclosed by the present invention, is not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof.
Claims
1. A method for processing a data table, characterized in that: The method comprises: receiving a first processing request, wherein the first processing request is used to request generation of a target data table corresponding to a source data table, wherein the target data table represents a data table after an identification column is added to the source data table, wherein the identification column includes a plurality of identification values; According to the first processing request, the generation rule parameters of the identification value are obtained by parsing; the generation rule parameters include at least one of the following: data type, starting value, and change amount; According to the generation rule parameters, the input parameters of the built-in function are configured, and according to the input parameters, each identification value of the identification column is obtained by calling the built-in function; wherein the input parameters include a data type, a previous identification value, and a change amount; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters; A table schema of the target data table is created, and the identification value of the identification column and the source data table mapping are added to the table schema to obtain the target data table.
2. The method according to claim 1, characterized in that The step of configuring the input parameters of the built-in function according to the generation rule parameters includes: If the generation rule parameter contains a data type, the data type in the generation rule parameter is used as the data type in the input parameter; If the generation rule parameters include a change amount, the change amount in the generation rule parameters is used as the change amount in the input parameters; If the generation rule parameters contain a starting value, before the built-in function is called for the first time, the starting value in the generation rule parameters is used as the previous identification value in the input parameters, and, before each subsequent call to the built-in function, the most recently calculated identification value of the built-in function is used as the previous identification value in the input parameters.
3. The method according to claim 2, characterized in that The step of configuring the input parameters of the built-in function according to the generation rule parameters specifically includes: If the generation rule parameters do not include a change amount, a preset default change amount is used as the change amount in the input parameters; If the generation rule parameter does not include a starting value, before the built-in function is called for the first time, a preset default starting value is used as the previous identification value in the input parameter.
4. The method according to claim 3, characterized in that The default starting value and the default change amount are 1.
5. The method according to claim 1, characterized in that The step of adding the identification value of the identification column and the source data table mapping to the table schema to obtain the target data table includes: According to the first processing request, a parsing expression is established, and the parsing expression is converted into an executable expression; the parsing expression defines a data source corresponding to each column in the target data table; According to the executable expression, the data source corresponding to each column in the table schema is obtained; wherein the data source corresponding to the identification column is each identification value calculated by the built-in function, and the data source corresponding to other columns is the data under the corresponding column of the column in the source data table; By executing the executable expression, the data source corresponding to each column in the table architecture is added to the column to obtain the target data table.
6. The method according to claim 1, characterized in that Before parsing the generation rule parameters of the identification value according to the first processing request, the method further includes: Verifying whether the first processing request includes an auto-increment function; If the auto-increment function is not included, it is determined that the first processing request verification fails; If it contains an auto-increment function, verify whether the first processing request is a selective insert statement. If it is a selective insert statement, determine that the first processing request has been verified successfully; if it is not a selective insert statement, determine that the first processing request has not been verified successfully.
7. The method according to claim 6, characterized in that Before parsing the generation rule parameters of the identification value according to the first processing request, the method further includes: Verify whether the data type defined by the auto-increment function in the first processing request is a numeric type; If it is a numerical type, it is determined that the first processing request is verified to be successful; If it is not a numerical type, it is determined that the first processing request verification has failed.
8. The method according to claim 7, characterized in that The method further comprises: If the data type defined by the increment function in the first processing request is a numerical type with a scale, verifying whether the scale of the numerical type with a scale is 0; If the scale is 0, it is determined that the first processing request verification has passed; if the scale is not 0, it is determined that the first processing request verification has not passed.
9. The method according to claim 8, characterized in that Before parsing the generation rule parameters of the identification value according to the first processing request, the method further includes: Verify whether the starting value and the change amount of the auto-increment function defined in the first processing request are within the value range corresponding to the data type defined by the auto-increment function; If the starting value and the change are both within the value range, it is determined that the first processing request verification has passed; otherwise, it is determined that the first processing request verification has failed.
10. The method according to any one of claims 6 to 9, characterized in that: The step of parsing the generation rule parameters of the identification value according to the first processing request specifically includes: If the first processing request is verified to be successful, then the generation rule parameters of the identification value are parsed according to the first processing request.
11. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: After obtaining the last identification value of the current identification column, a dependency relationship between the identification column of the target data table and the current input parameters is established, wherein the current input parameters include the data type, the last identification value, and the change amount.
12. The method according to claim 11, characterized in that The method further comprises: receiving a second processing request, where the second processing request is used to request inserting row data into the target data table; According to the second processing request, query the dependency relationship to obtain input parameters corresponding to the identification column of the target data table; According to the input parameter corresponding to the identification column of the target data table, calling the built-in function to obtain the identification value corresponding to the row data inserted in the target data table; The identification value corresponding to the inserted row data is added to the identification column of the target data table.
13. A data table processing device, characterized in that: The device comprises: A receiving module, configured to receive a first processing request, wherein the first processing request is used to request generation of a target data table corresponding to a source data table, wherein the target data table represents a data table after an identification column is added to the source data table, wherein the identification column includes a plurality of identification values; A parsing module, configured to parse, according to the first processing request, a generation rule parameter of the identification value; the generation rule parameter includes at least one of the following: a data type, a starting value, and a change amount; A generation module, configured to configure the input parameters of the built-in function according to the generation rule parameters, and obtain each identification value of the identification column by calling the built-in function according to the input parameters; wherein the input parameters include a data type, a previous identification value, and a change amount; the built-in function is used to calculate the next identification value of the previous identification value according to the input parameters; A creation module is used to create a table schema of the target data table, add the identification value of the identification column and the source data table mapping to the table schema, and obtain the target data table.
14. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 12 when executed by a processor.
16. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 12 when being executed by a processor.