Data modification method and device, electronic equipment, storage medium and program product
By determining and traversing the modification properties of the multi-table join query result set and operating only on the columns that are allowed to be modified, the error problem in the data modification of the multi-table join query result set is solved, and the convenience and accuracy of data modification are improved.
Patent Information
- Application Number
- CN202510562034.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-08-12
AI Technical Summary
In relational database management systems, errors are prone to occur when modifying the result set data of multi-table connection queries, and even operations cannot be performed.
By determining the result set to be modified, traversing the modified attributes of the column to be modified, and in response to the operations on the modification page, data modification is only performed if the modification attribute allows.
It reduces the probability of logical errors in data modification and improves the convenience and accuracy of data modification.
Smart Images

Figure CN120470010A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a data modification method, device, electronic device, storage medium and program product. Background Art
[0002] In a relational database management system (RDBMS), a multi-table join operation is a very common operation that combines rows from two or more tables based on related columns, thereby obtaining related data from multiple tables. Multi-table join queries performed through multi-table join operations are very common queries in relational databases. Through multi-table join operations, data from multiple tables can be combined based on set conditions.
[0003] In current common relational database management client tools, modifying data in the result set of a multi-table join query presents several technical challenges. For example, modifying column data from different tables in the result set of a multi-table join query can result in modification errors or even failure to perform the data modification operation due to issues with the algorithm used. Summary of the Invention
[0004] The present invention provides a data modification method, device, electronic device, storage medium and program product to realize the modification of data in the result set of multi-table connection query, thereby improving the convenience of data modification.
[0005] According to one aspect of the present invention, there is provided a data modification method, comprising:
[0006] Determine a result set to be modified, wherein the result set to be modified consists of columns to be modified;
[0007] Traversing the to-be-modified column, determining a modification attribute of the to-be-modified column, the modification attribute indicating whether the to-be-modified column can be modified;
[0008] In response to a modification operation on the to-be-modified result set on a modification page, data corresponding to the modification operation in the to-be-modified result set is modified, wherein the modification operation includes an operation constrained by the modification attribute.
[0009] According to another aspect of the present invention, there is provided a data modification device, comprising:
[0010] A determination module, configured to determine a result set to be modified, wherein the result set to be modified is composed of columns to be modified;
[0011] A traversal module, configured to traverse the column to be modified and determine a modification attribute of the column to be modified, wherein the modification attribute indicates whether the column to be modified can be modified;
[0012] The modification module is configured to modify data corresponding to a modification operation on the result set to be modified on a modification page, wherein the modification operation includes an operation constrained by the modification attribute.
[0013] According to another aspect of the present invention, an electronic device is provided, comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the data modification method described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data modification method described in any embodiment of the present invention when executed.
[0018] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the data modification method according to any embodiment of the present invention is implemented.
[0019] The technical solution of the embodiment of the present invention is to determine the result set to be modified; traverse the columns to be modified to determine the modification attributes of the columns to be modified; and in response to the modification operation on the modification page for the result set to be modified, modify the data corresponding to the modification operation in the result set to be modified, wherein the modification operation includes operations constrained by the modification attributes. By traversing the columns to be modified in the data set to be modified, the modification attributes of each column to be modified are clarified, the probability of logical errors and other problems in data modification is reduced, and the convenience of data modification is improved. When modifying data, modification operations can only be performed on the data in the columns to be modified that the modification attributes indicate can be modified, reducing the occurrence of modification errors and other problems during data modification, and optimizing the method for modifying data in the result set to be modified.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 This is a flow chart of a data modification method provided according to the first embodiment of the present invention;
[0023] Figure 2 is a schematic diagram of a modification execution method provided according to embodiment 1 of the present invention;
[0024] Figure 3 This is a flowchart of a method for determining a modified attribute according to a second embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of a method for determining a modified attribute according to a second embodiment of the present invention;
[0026] Figure 5 This is a structural diagram of a data modification device provided according to a third embodiment of the present invention;
[0027] Figure 6 This is a block diagram of an electronic device provided according to a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] Example 1
[0031] Figure 1 A flowchart of a data modification method is provided for the first embodiment of the present invention. This embodiment is applicable to the case where data in a set of modified results is modified. The method can be executed by a data modification device, which can be implemented in the form of hardware and / or software. The data modification device can be configured in an electronic device, which can be a mobile terminal, a PC, or a server. Figure 1 As shown, the method includes:
[0032] S110: Determine a result set to be modified, where the result set to be modified consists of columns to be modified.
[0033] In this embodiment, the result set to be modified can be understood as a data set consisting of data from the table to be queried indicated by the query statement. A multi-table join operation (for example, JOIN) can be performed on at least two tables to be queried, and the rows of the tables to be queried can be merged to obtain data from at least two tables to be queried and stored in the result set to be modified. The table to be queried can be understood as a table stored in a database, and the table to be queried can be used to store data. The multi-table join operation acts on the data columns between at least two tables to be queried to obtain data from at least two tables to be queried. The multi-table join operation can combine the data from at least two tables to be queried together through the conditions indicated by the query statement. The query statement can be understood as a statement input by the user that indicates relevant information of the table to be queried, and the query statement includes the conditions required to query the table to be queried. The column to be modified can be understood as the column where the basic information of the data in the result set to be modified is located. Each column to be modified can store basic information of a type of data.
[0034] Specifically, a database often contains multiple tables to be queried, some of which may be related. A multi-table join operation can be used to query at least two tables. Based on the query statement, the query table is retrieved, along with the data required for the query, and the retrieved data is placed in the result set to be modified. The query statement can specify columns in the table to be queried, which are then placed in the result set to be modified.
[0035] For example, in a database, a Java program can connect to the database, execute queries, update data in the database, and process result sets through the Java Database Connectivity (JDBC) interface. JDBC is a set of application programming interfaces provided by the Java language for accessing and operating databases. It defines a set of standard interfaces that enable Java programs to interact with various databases. In a database, suppose a multi-table join operation involves k tables to be queried, T1, T2, ..., T k Let CN(i) represent the number of columns in the i-th table to be queried, where 1≤i≤k, and C(i,j) represent the j-th column in the i-th table to be queried, where 1≤i≤k and 1≤j≤CN(i). Then, using JDBC, you can execute the query statement SELECT T1.NAME, T2.GRADE FROM SYSDBA.T1, SYSDBA.T2 WHERET 1.ID = T2.ID to perform a multi-table join query on the first table to be queried, T1, and the second table to be queried, T2. The data columns where the query results indicate that the IDs of T1 and T2 are equal are placed in the result set to be modified.
[0036] S120: traverse the column to be modified and determine a modification attribute of the column to be modified, where the modification attribute indicates whether the column to be modified can be modified.
[0037] In this embodiment, the modification attribute can be understood as information indicating whether the data in the column to be modified can be modified. The modification attribute of the column to be modified is related to the information indicated by the query statement.
[0038] Specifically, a result set to be modified includes multiple columns to be modified, which may be from different tables to be queried. The modification attribute of each column to be modified is determined based on information indicated by the query statement. The number of row identifier columns in the query statement can be determined, and the modification attribute of each column to be modified in the result set to be modified is determined based on the number of row identifier columns.
[0039] The row identifier column is a unique identifier automatically generated by the database to identify each row in a table. This identifier can be used to quickly locate and access rows. The row identifier column can be represented by ROWID. ROWID is a pseudo-column in the database that uniquely identifies each row in a table and indicates the physical storage location of each row's data.
[0040] For example, when executing the query "SELECT T1.ROWID, T1.NAME, T2.GRADE FROM SYSDBA.T1, SYSDBA.T2 WHERE T1.ID = T2.ID," the modification attributes of the columns to be modified in the corresponding result set are first determined. Assuming the result set contains M rows and N columns of data, the N columns to be modified are traversed to determine their modification attributes.
[0041] S130. In response to a modification operation on the to-be-modified result set on the modification page, modify data corresponding to the modification operation in the to-be-modified result set, wherein the modification operation includes an operation constrained by the modification attribute.
[0042] In this embodiment, a modification page can be understood as a page for receiving user operations. On this modification page, users can modify columns to be modified whose modification attributes indicate that they can be modified. The modification page can be located at the client level. A modification operation can be understood as an operation in which a user modifies data in a result set to be modified according to the modification attribute instructions. Modification operations can only be performed on columns to be modified whose modification attributes indicate that they can be modified.
[0043] Specifically, for each column to be modified in the result set to be modified, the modification attribute of each column to be modified is determined. For a column to be modified, if the modification attribute of the column to be modified indicates that it can be modified, the user can modify the data in the column to be modified on the modification page. After the user completes the modification operation on the result set to be modified on the modification page, the user-modified result set to be modified is obtained. Finally, the user-modified result set to be modified is mapped to the database, completing the modification of the result set to be modified.
[0044] For example, after the user completes the modification operation on the modification page for the result set to be modified, the modification operation and the data corresponding to the modification operation can be converted into an SQL statement of the database. By executing the SQL statement in the database, the modified result set to be modified is mapped to the database.
[0045] The technical solution of the embodiment of the present invention is to determine the result set to be modified; traverse the columns to be modified to determine the modification attributes of the columns to be modified; and in response to the modification operation on the modification page for the result set to be modified, modify the data corresponding to the modification operation in the result set to be modified, wherein the modification operation includes operations constrained by the modification attributes. By traversing the columns to be modified in the data set to be modified, the modification attributes of each column to be modified are clarified, the probability of logical errors and other problems in data modification is reduced, and the convenience of data modification is improved. When modifying data, modification operations can only be performed on the data in the columns to be modified that the modification attributes indicate can be modified, reducing the occurrence of modification errors and other problems during data modification, and optimizing the method for modifying data in the result set to be modified.
[0046] Based on the above embodiment, a modified embodiment of the above embodiment is proposed. It should be noted that, in order to simplify the description, only the differences from the above embodiment are described in the modified embodiment.
[0047] In one embodiment, in response to a modification operation on the modification page for the result set to be modified, modifying data corresponding to the modification operation in the result set to be modified includes:
[0048] In a case where the modification attribute indicates that the column to be modified can be modified, in response to a modification operation on the modification page for the result set to be modified, modifying the data corresponding to the modification operation in the result set to be modified where the column to be modified is located;
[0049] When the modification attribute indicates that the column to be modified cannot be modified, the data in the result set to be modified is not modified.
[0050] Specifically, for each column to be modified in a result set to be modified, the modification attribute of each column to be modified is determined. If the modification attribute indicates that the column to be modified cannot be modified, the user cannot modify the data in the result set to be modified through the modification page. If the modification attribute indicates that the column to be modified can be modified, the user can modify the data in the column to be modified through the modification page.
[0051] After the user completes the modification operation on the modification page for the result set to be modified, the modified result set is used as the dataset to be updated, and the data in the dataset to be updated needs to be saved in the database. The dataset to be updated can be the dataset obtained after the modification operation is performed on the result set to be modified. The dataset to be updated stores the data corresponding to the modification operation and the unmodified data in the result set to be modified. Each row of data corresponding to the modification operation in the dataset to be updated can be converted into an SQL statement that can be executed by the database. Finally, the SQL statement corresponding to each row of data in the dataset to be updated is obtained. All SQL statements corresponding to the dataset to be updated are executed uniformly to complete the operation of mapping the data in the dataset to be updated to the database.
[0052] Optionally, modifying the data corresponding to the modification operation in the result set to be modified where the column to be modified is located includes:
[0053] Acquire a data set to be updated, the data set to be updated including a data set obtained after performing the modification operation on the result set to be modified, the data set to be updated including data corresponding to the modification operation;
[0054] Traversing the data to be updated in the data set to be updated, determining the statements to be updated corresponding to the data to be updated, and storing the statements to be updated in a to-be-executed list;
[0055] Execute the transactions corresponding to the to-be-executed list.
[0056] In this embodiment, the data to be updated can be understood as the data corresponding to the modification operation on the dataset to be updated, that is, the data modified by the user. The statement to be updated can be understood as the string corresponding to each row of the data to be updated in the dataset to be updated. The pending list can be understood as a list for storing pending update statements, which is the list corresponding to the dataset to be updated.
[0057] Specifically, a dataset to be modified that has undergone modification operations is obtained as a dataset to be updated. The dataset to be updated contains data to be updated that has undergone modification operations, as well as data that has not undergone modification operations. For each row of data to be updated in the dataset to be updated, each row of data to be updated is converted into a statement to be updated, in sequence, according to the position of the columns in the dataset to be updated. Each row of data to be updated in the dataset to be updated is traversed to obtain the statement to be updated corresponding to each row of data to be updated. The multiple statements to be updated corresponding to the dataset to be updated are stored in a pending execution list. When the pending execution list is executed, the multiple statements to be updated in the pending execution list are converted into transactions that can be executed by the database, and the transactions corresponding to all the pending update statements in the pending execution list are executed uniformly.
[0058] For example, Figure 2FIG. 1 is a schematic diagram of a modification execution method provided according to the first embodiment of the present invention. Figure 2 As shown, the dataset to be updated consists of R rows and N columns. A pending list L is initialized. The data set is traversed from the first row to row R. For row i, a string S = "UPDATE SNAME.TNAME SET" is initialized, and traversal of N columns begins. For the data in row i, column j (1≤i≤R, 1≤j≤N) in the dataset to be updated, if it is data to be updated, the current column name is D, and the value of the data to be updated in row i, column j is V. Considering the parameter binding format, the statement S = S + "D = ?," is executed, where ? is replaced by V when the update statement is executed. After traversing N columns in row i, the last "," is removed from S, resulting in S = S + "WHERE ROWID = ?;," where ? is replaced by T when the update statement is executed. The string S is stored in the pending list L. At this point, S is a pending update statement, and traversal continues to the next row, row i+1. After traversing R rows, a pending list L is obtained, corresponding to the pending update statements that modify the dataset to be updated. After starting a database transaction, the pending update statements in pending list L are traversed and executed. If the execution succeeds, the transaction is committed; if the execution fails, the transaction is rolled back. Database transactions ensure the consistency of updated data, that is, all updates are successful, or none are updated.
[0059] In one embodiment, determining the result set to be modified includes:
[0060] In response to an input operation of a query statement on the input page, obtaining at least two tables to be queried, wherein the tables to be queried consist of at least one column of data;
[0061] Determining a query condition in the query statement, wherein the query condition includes a condition for querying the at least two tables to be queried;
[0062] For each table to be queried, extract the data column to be queried corresponding to the table to be queried according to the query condition;
[0063] For each table to be queried, the data column to be queried corresponding to the table to be queried is stored in the result set to be modified.
[0064] In this embodiment, the input page can be understood as a page for entering a query statement. On the input page, the user can enter a query statement according to their needs. The query condition can be understood as a condition used to filter data that meets the user's requirements from at least two query tables in the database. The query condition is included in the query statement and is the condition entered by the user on the input page. The query data column can be understood as a data column in the query table that meets the query condition. Each query data column can store a type of data.
[0065] Specifically, the query statement entered by the user on the input page is obtained. The query statement is a query statement corresponding to a multi-table connection operation. Therefore, the query statement includes at least two tables to be queried. Each table to be queried is a table in the database, and each table to be queried can be composed of at least one column of data. The query condition contained in the query statement is obtained. The query condition can indicate the data in the table to be queried required by the user. The data can be a column of data in the table to be queried, which is recorded as the data column to be queried. For any one of the at least two tables to be queried, the data column to be queried corresponding to any one of the tables to be queried can be determined according to the indication of the table to be queried. Each table to be queried can correspond to at least one data column to be queried. Finally, all the data columns to be queried corresponding to the at least two tables to be queried are stored in a set, and the result set to be modified is obtained.
[0066] For example, assume that a multi-table join operation involves k tables to be queried T1, T2, ..., T k , use C(i,j) to represent the jth column of the i-th table to be queried, where 1≤i≤k, 1≤j≤CN(i). Then a multi-table join operation can be expressed as: SELECT∪T i .C(i,j)FROM∪T i WHERE∪CON(C(a,b),C(x,y)). Where ∪T i .C(i,j) represents the enumeration of a data column in a table to be queried, such as T1.C(1,1), T1.C(1,2), T2.C(2,1); ∪T i represents an enumeration of all tables to be queried, such as T1 and T2; ∪CON(C(a,b),C(x,y)) represents the set of query conditions for each table to be queried based on its own data columns, such as T1.C(1,3) = T2.C(2,4) AND T2.C(2,1) > 10. Through the above multi-table join operation, a result set consisting of the queried data columns can be obtained from at least two tables to be queried according to the query statement.
[0067] Example 2
[0068] Figure 3 This is a flowchart of a method for determining modification attributes provided by the second embodiment of the present invention. This embodiment is based on the method for determining the modification attributes of the column to be modified in the above embodiment. Figure 3 As shown, the method includes:
[0069] S210: Determine the result set to be modified.
[0070] S220 . For each column to be modified in the data set to be modified, determine a column name of the column to be modified.
[0071] In this embodiment, the column name can be understood as an identifier indicating a column to be modified in the data set to be modified. The column name can be used to uniquely identify a column to be modified.
[0072] For each column in the result set to be modified, the column name CNAME of the column to be modified is obtained using the getColumnName method of the ResultSetMetaData class. The ResultSetMetaData class can be obtained using the getMetaData method of the result set to be modified. The ResultSetMetaData class identifies metadata about the columns in the result set to be modified. The metadata contains descriptive information about the result set to be modified. The getColumnName method can be used to obtain the name of a specified column in the result set to be modified.
[0073] S230: Obtain the row identifier column corresponding to the result set to be modified in the query statement and the number of the row identifier columns.
[0074] Exemplarily, the row identifier column ROWID and the number of row identifier columns corresponding to the result set to be modified in the query statement input by the user are obtained. For example, for the following query statement: SELECT T1.ROWID, T1.NAME, T2.GRADE FROM SYSDBA.T1, SYSDBA.T2 WHERE T1.ID = T2.ID, the result set to be modified is obtained by combining the data columns to be queried of the table to be queried T1 and the table to be queried T2. In this query statement, the row identifier column corresponding to the result set to be modified is T1.ROWID, and the number of row identifier columns is single.
[0075] S240: Determine a modification attribute of the column to be modified according to the column name, the row identifier column, and the number of the row identifier columns.
[0076] Specifically, the method for obtaining the modification properties of the column to be modified can be determined based on the number of row identifier columns. When there is only one row identifier column, the modification properties of the column to be modified need to be determined based on the column name and the row identifier column. When there are multiple row identifier columns, the modification properties of the column to be modified can be determined directly without using the column name and the row identifier column.
[0077] Optionally, determining the modification attribute of the column to be modified according to the column name, the row identifier column, and the number of row identifier columns includes:
[0078] If the number of the row identifier column is single, the modification attribute of the column to be modified is determined according to the matching result of the row identifier column and the column name; otherwise, it is determined that the modification attributes of all the columns to be modified in the result set to be modified cannot be modified.
[0079] In this embodiment, the matching result can be understood as the result of performing a matching operation on the column name of the column to be modified and the row identifier column. The matching result can determine whether the table to be queried where the column to be modified is located is the table to be queried corresponding to the row identifier column.
[0080] Specifically, if there is only one row identifier column, indicating that the query statement contains modification operations on only one table to be queried, the modification attributes of each column in the result set to be modified can be determined based on the matching result between the row identifier column and the column name. Otherwise, if there are multiple row identifier columns and the query statement contains modification operations on multiple tables to be queried, to prevent logical errors, the modification attributes of all columns in the result set to be modified must be set to non-modifiable.
[0081] For example, Figure 4 FIG. 1 is a schematic diagram of a modified attribute determination method according to the second embodiment of the present invention. Figure 4 As shown, initialize the variables ROWID_SNAME and ROWID_TNAME to empty strings. ROWID_SNAME indicates the identifier of the schema name of the table to be queried, and ROWID_TNAME indicates the identifier of the table name of the table to be queried. Initialize an associative container Map named M, with the key being a string type and the value being a string list type. MAP stores key-value pairs. The key and value can be of any type, where each key is unique. The corresponding value can be quickly searched, inserted, and deleted through the key. The definition of MAP is map<key_type,value_type> Variable name. For a result set with M rows and N columns to be modified, iterate through the N columns to be modified. For each column to be modified, use the getSchemaName and getTableName methods on the metadata to obtain the schema name (SNAME) and table name (TNAME) of the table to be queried. Then use the getColumnName method of the ResultSetMetaData class to obtain the column name (CNAME) of the column to be modified. Using SNAME.TNAME as the key-value pair, obtain a list of column names in Map M and add the column name (CNAME) of the column to be modified to this list.
[0082] If there is a single row identifier column ROWID, the column name CNAME is matched against the row identifier column ROWID to obtain a matching result, and the modification attribute of the column to be modified is determined based on the matching result. If there are multiple row identifier columns ROWID, the column name CNAME is the row identifier column ROWID, and ROWID_SNAME ≠ SNAME and ROWID_TNAME ≠ TNAME. Since a ROWID cannot exist from multiple tables to be queried, the modification attribute of all columns to be modified in the result set to be unmodifiable is set, and the loop ends immediately.
[0083] Optionally, determining the modification attribute of the column to be modified according to the matching result between the row identifier column and the column name includes:
[0084] Obtaining first metadata corresponding to the row identifier column;
[0085] For each of the column names, second metadata of the column to be modified corresponding to the column name is determined, the second metadata is matched with the first metadata, and a matching result between the column name and the row identifier column is determined; if the matching result indicates a match, the modification attribute of the column to be modified corresponding to the column name is determined to be modifiable; otherwise, the modification attribute of the column to be modified corresponding to the column name is determined to be non-modifiable.
[0086] In this embodiment, the first metadata can be understood as the descriptive information corresponding to the row identifier column, and the first metadata can indicate the table to be queried corresponding to the row identifier column. The second metadata can be understood as the descriptive information of the column to be modified corresponding to the column name, and the second metadata can indicate the table to be queried corresponding to the column to be modified.
[0087] For example, the description information corresponding to the row identifier column ROWID is obtained, which can be the information of the table to be queried indicated by the row identifier column ROWID in the query statement, as the first metadata. For each column name, the description information of the column to be modified corresponding to the column name CNAME is obtained, which can be the information of the table to be queried where the column to be modified corresponding to the column name CNAME in the query statement is located, as the second metadata. For each second metadata, the second metadata is matched with the first metadata to determine the matching result of each column name and the row identifier column. Figure 4As shown, if the matching result indicates that the second metadata matches the first metadata, it means that the table to be queried corresponding to the column name CNAME is the table to be queried corresponding to the row identifier column ROWID, and ROWID_SNAME and ROWID_TNAME are empty strings, that is, the column name matches the row identifier column successfully, then the assignment ROWID_SNAME = SNAME, ROWID_TNAME = TNAME is executed, and the modification attribute of the column to be modified is set to be modifiable. Otherwise, it means that the table to be queried corresponding to the column name CNAME is not the table to be queried corresponding to the row identifier column ROWID, then the modification attribute of the column to be modified corresponding to the column name is set to be non-modifiable.
[0088] S250. In response to a modification operation on the to-be-modified result set on the modification page, modify data corresponding to the modification operation in the to-be-modified result set, wherein the modification operation includes an operation constrained by the modification attribute.
[0089] The technical solution of an embodiment of the present invention determines the column name of each column to be modified in the data set to be modified; obtains the row identifier column and the number of row identifier columns corresponding to the result set to be modified in the query statement; and determines the modification properties of the column to be modified based on the column name, the row identifier column, and the number of row identifier columns. The method for determining the modification properties of the column to be modified is refined by using the column name of the column to be modified, the row identifier column corresponding to the result set to be modified, and the number of row identifier columns. This allows for accurate determination of the modification properties of the column to be modified in the data set to be modified, ensures stability when modifying the data set to be modified, and reduces the likelihood of modification errors.
[0090] Example 3
[0091] Figure 5 This is a structural diagram of a data modification device provided by the third embodiment of the present invention. Figure 5 As shown, the device includes:
[0092] A determination module 310 is configured to determine a result set to be modified, wherein the result set to be modified is composed of columns to be modified;
[0093] A traversal module 320 is configured to traverse the column to be modified and determine a modification attribute of the column to be modified, where the modification attribute indicates whether the column to be modified can be modified;
[0094] The modification module 330 is configured to modify data corresponding to a modification operation on the result set to be modified on the modification page, wherein the modification operation includes an operation constrained by the modification attribute.
[0095] The data modification device provided by the embodiment of the present invention determines the result set to be modified through a determination module; traverses the columns to be modified through a traversal module to determine the modification attributes of the columns to be modified; and responds to the modification operation on the modification page for the result set to be modified through a modification module to modify the data corresponding to the modification operation in the result set to be modified, wherein the modification operation includes an operation constrained by the modification attributes. Through the mutual cooperation between the modules, the columns to be modified in the data set to be modified are traversed, the modification attributes of each column to be modified are clarified, the probability of problems such as logical errors in data modification is reduced, and the convenience of data modification is improved. When modifying data, modification operations can only be performed on the data in the columns to be modified that the modification attributes indicate can be modified, reducing the occurrence of modification errors and other problems during data modification, and optimizing the method for modifying data in the result set to be modified.
[0096] In one embodiment, the traversal module 320 includes:
[0097] A first determining unit is configured to determine, for each column to be modified in the data set to be modified, a column name of the column to be modified;
[0098] An acquiring unit, configured to acquire a row identifier column corresponding to the result set to be modified in a query statement and the number of the row identifier columns;
[0099] The second determining unit is configured to determine a modification attribute of the column to be modified according to the column name, the row identifier column, and the number of the row identifier columns.
[0100] In one embodiment, the second determining unit includes:
[0101] The determination subunit is used to determine the modification attribute of the column to be modified based on the matching result of the row identifier column and the column name if the number of the row identifier column is single; otherwise, determine that the modification attributes of all the columns to be modified in the result set to be modified cannot be modified.
[0102] In one embodiment, the subunit is determined to be specifically configured to:
[0103] Obtaining first metadata corresponding to the row identifier column;
[0104] For each of the column names, second metadata of the column to be modified corresponding to the column name is determined, the second metadata is matched with the first metadata, and a matching result between the column name and the row identifier column is determined; if the matching result indicates a match, the modification attribute of the column to be modified corresponding to the column name is determined to be modifiable; otherwise, the modification attribute of the column to be modified corresponding to the column name is determined to be non-modifiable.
[0105] In one embodiment, the modification module 330 includes:
[0106] a first modifying unit configured to modify, in response to a modification operation on the result set to be modified on the modification page, data corresponding to the modification operation in the result set to be modified where the column to be modified is located, when the modification attribute indicates that the column to be modified can be modified;
[0107] The second modification unit is configured to not modify the data in the result set to be modified if the modification attribute indicates that the column to be modified cannot be modified.
[0108] In one embodiment, the first modifying unit is specifically configured to:
[0109] Acquire a data set to be updated, the data set to be updated including a data set obtained after performing the modification operation on the result set to be modified, the data set to be updated including data corresponding to the modification operation;
[0110] Traversing the data to be updated in the data set to be updated, determining the statements to be updated corresponding to the data to be updated, and storing the statements to be updated in a to-be-executed list;
[0111] Execute the transactions corresponding to the to-be-executed list.
[0112] In one embodiment, the determination module 310 is specifically configured to:
[0113] In response to an input operation of a query statement on the input page, obtaining at least two tables to be queried, wherein the tables to be queried consist of at least one column of data;
[0114] Determining a query condition in the query statement, wherein the query condition includes a condition for querying the at least two tables to be queried;
[0115] For each table to be queried, extract the data column to be queried corresponding to the table to be queried according to the query condition;
[0116] For each table to be queried, the data column to be queried corresponding to the table to be queried is stored in the result set to be modified.
[0117] The data modification device provided in the embodiment of the present invention can execute the data modification method provided in any embodiment of the present invention, completes the modification of data through the mutual cooperation and collaboration between the modules, and has the functional modules and beneficial effects corresponding to the execution method.
[0118] Example 4
[0119] According to an embodiment of the present invention, the present invention further provides an electronic device, a computer-readable storage medium, and a computer program product.
[0120] Figure 6 is a block diagram of an electronic device provided according to embodiment four of the present invention, which can implement the data modification method described in the embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0121] like Figure 6 As shown, the electronic device 410 includes at least one processor 411, and a memory connected to the at least one processor 411 in communication, such as a read-only memory (ROM) 412, a random access memory (RAM) 413, etc., wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 411 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 412 or the computer program loaded from the storage unit 418 to the random access memory (RAM) 413. Various programs and data required for the operation of the electronic device 410 can also be stored in the RAM 413. The processor 411, ROM 412 and RAM 413 are connected to each other via a bus 414. An input / output (I / O) interface 415 is also connected to the bus 414.
[0122] Multiple components in the electronic device are connected to the I / O interface 415, including an input unit 416, such as a keyboard, mouse, etc.; an output unit 417, such as various types of displays, speakers, etc.; a storage unit 418, such as a magnetic disk, optical disk, etc.; and a communication unit 419, such as a network card, modem, wireless communication transceiver, etc. The communication unit 419 allows the electronic device to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0123] Processor 411 can be various general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of processor 411 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. Processor 411 executes the various methods and processes described above, such as the data modification method.
[0124] In some embodiments, the data modification method can be implemented as a computer program that is tangibly contained in a computer-readable storage medium, such as storage unit 418. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 410 via ROM 412 and / or communication unit 419. When the computer program is loaded into RAM 413 and executed by processor 411, one or more steps of the data modification method described above can be performed. Alternatively, in other embodiments, processor 411 can be configured to perform the data modification method in any other appropriate manner (e.g., by means of firmware).
[0125] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0126] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0127] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0128] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0129] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0130] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0131] In some embodiments, the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the data modification method provided by the embodiment of the present invention.
[0132] The technical solution of the embodiment of the present invention is provided through a data modification method, device, electronic device, storage medium and program product. Determine the result set to be modified; traverse the columns to be modified to determine the modification attributes of the columns to be modified; in response to the modification operation on the modification page for the result set to be modified, modify the data corresponding to the modification operation in the result set to be modified, wherein the modification operation includes operations constrained by the modification attributes. By traversing the columns to be modified in the data set to be modified, the modification attributes of each column to be modified are clarified, the probability of problems such as logical errors in data modification is reduced, and the convenience of data modification is improved. When modifying data, modification operations can only be performed on the data of the columns to be modified that the modification attributes indicate can be modified, reducing the occurrence of modification errors and other problems during data modification, and optimizing the method for modifying data in the result set to be modified.
[0133] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0134] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A data modification method, characterized in that: include: Determine a result set to be modified, wherein the result set to be modified consists of columns to be modified; Traversing the to-be-modified column, determining a modification attribute of the to-be-modified column, the modification attribute indicating whether the to-be-modified column can be modified; In response to a modification operation on the to-be-modified result set on a modification page, data corresponding to the modification operation in the to-be-modified result set is modified, wherein the modification operation includes an operation constrained by the modification attribute.
2. The method according to claim 1, characterized in that The traversing the to-be-modified column and determining the modification attribute of the to-be-modified column includes: For each to-be-modified column in the to-be-modified data set, determine the column name of the to-be-modified column; Obtaining the row identifier column corresponding to the result set to be modified in the query statement and the number of the row identifier columns; Determine a modification attribute of the column to be modified according to the column name, the row identifier column, and the number of the row identifier columns.
3. The method according to claim 2, characterized in that The determining the modification attribute of the column to be modified according to the column name, the row identifier column, and the number of the row identifier columns includes: If the number of the row identifier column is single, the modification attribute of the column to be modified is determined according to the matching result of the row identifier column and the column name; otherwise, it is determined that the modification attributes of all the columns to be modified in the result set to be modified cannot be modified.
4. The method according to claim 3, characterized in that The determining the modification attribute of the column to be modified according to the matching result between the row identifier column and the column name includes: Obtaining first metadata corresponding to the row identifier column; For each of the column names, second metadata of the column to be modified corresponding to the column name is determined, the second metadata is matched with the first metadata, and a matching result between the column name and the row identifier column is determined; if the matching result indicates a match, the modification attribute of the column to be modified corresponding to the column name is determined to be modifiable; otherwise, the modification attribute of the column to be modified corresponding to the column name is determined to be non-modifiable.
5. The method according to claim 1, wherein In response to the modification operation on the modification page for the result set to be modified, modifying the data corresponding to the modification operation in the result set to be modified includes: In a case where the modification attribute indicates that the column to be modified can be modified, in response to a modification operation on the modification page for the result set to be modified, modifying the data corresponding to the modification operation in the result set to be modified where the column to be modified is located; When the modification attribute indicates that the column to be modified cannot be modified, the data in the result set to be modified is not modified.
6. The method according to claim 5, characterized in that The data corresponding to the modification operation in the result set to be modified where the column to be modified is located includes: Acquire a data set to be updated, the data set to be updated including a data set obtained after performing the modification operation on the result set to be modified, the data set to be updated including data corresponding to the modification operation; Traversing the data to be updated in the data set to be updated, determining the statements to be updated corresponding to the data to be updated, and storing the statements to be updated in a to-be-executed list; Execute the transactions corresponding to the to-be-executed list.
7. The method according to claim 1, characterized in that Determining the result set to be modified includes: In response to an input operation of a query statement on the input page, obtaining at least two tables to be queried, wherein the tables to be queried consist of at least one column of data; Determining a query condition in the query statement, wherein the query condition includes a condition for querying the at least two tables to be queried; For each table to be queried, extract the data column to be queried corresponding to the table to be queried according to the query condition; For each table to be queried, the data column to be queried corresponding to the table to be queried is stored in the result set to be modified.
8. A data modification device, characterized in that: include: A determination module, configured to determine a result set to be modified, wherein the result set to be modified is composed of columns to be modified; A traversal module, configured to traverse the column to be modified and determine a modification attribute of the column to be modified, wherein the modification attribute indicates whether the column to be modified can be modified; The modification module is configured to modify data corresponding to a modification operation on the result set to be modified on a modification page, wherein the modification operation includes an operation constrained by the modification attribute.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the data modification method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data modification method according to any one of claims 1 to 7 when executed.
11. A computer program product, characterized in that The computer program product comprises a computer program, which, when executed by a processor, implements the data modification method according to any one of claims 1 to 7.
Citation Information
Patent Citations
SQL statement generation method and device
CN110019266A
Data processing method and device, storage medium and electronic equipment
CN115905267A
Data modification method and device applied to database, equipment and medium
CN118820203A
Updatable result set for multiple joined tables
US20090100002A1
Method and apparatus for updating data about multiple user in database management system
US20240168943A1