Data processing method and device, equipment, storage medium and program product
By determining the memory structure based on table variable names and associating temporary tables for data processing, the inefficiency and high maintenance costs of traditional databases in complex data storage and management are solved, achieving more efficient data processing and resource management, and improving the database's work efficiency and accuracy.
Patent Information
- Application Number
- CN202511300808.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-11
- Publication Date
- 2026-01-02
AI Technical Summary
Traditional database design patterns are inefficient and costly to maintain when faced with complex and ever-changing data storage and management needs. They are unable to meet the flexible needs of business development, especially in the area of temporary data storage, where there are problems such as complex constraint definitions, strict restrictions on index creation, and incomplete sequence support.
By determining the memory structure based on the table variable name upon receiving the target operation statement, associating a temporary table, and performing data processing operations, the system reduces data lookup and matching time, avoids redundant operations, and achieves rapid location and accurate execution of data processing.
It improves database efficiency, reduces maintenance costs, ensures that operations directly affect the corresponding temporary tables, enhances data processing speed and accuracy, and reduces resource consumption.
Smart Images

Figure CN121255801A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, and particularly relates to a data processing method and device, equipment, a storage medium and a program product. BACKGROUND
[0002] In the process of continuous development of database technology, with the continuous expansion of enterprise business and the increasing diversification of application scenarios, databases face increasingly complex data storage and management requirements. Traditional database design patterns gradually reveal some limitations when dealing with these complex and variable scenarios, making it difficult to efficiently and flexibly meet the requirements of business development. In conventional database use, for data storage, a fixed table structure usually needs to be defined in advance to store specific types of data. Each new data storage requirement often requires the creation of a corresponding table, and the definition of corresponding fields, constraints, indexes and other attributes in the table. However, the current scheme has the problems of low efficiency and high database maintenance cost.
[0003] Therefore, how to improve the efficiency of database and reduce the maintenance cost of database is a problem to be solved. SUMMARY
[0004] The data processing method, device, equipment, storage medium and program product provided by the embodiments of the present application can improve the efficiency of database and reduce the maintenance cost of database.
[0005] In a first aspect, the embodiments of the present application provide a data processing method, which comprises:
[0006] In the case of receiving a target operation statement, the memory structure of the table variable is determined according to the table variable name in the target operation statement;
[0007] The temporary table corresponding to the table variable is determined according to the table identifier included in the memory structure;
[0008] The data processing operation included in the target operation statement is performed on the temporary table.
[0009] Optionally, the temporary table corresponding to the table variable is determined according to the table identifier included in the memory structure, comprising:
[0010] The memory structure of the table variable is determined in the system table according to the table variable name;
[0011] The table identifier corresponding to the table variable is extracted from the memory structure;
[0012] The temporary table is determined in the system table according to the table identifier.
[0013] Optionally, the method further comprises:
[0014] In a case where the table variable declaration statement is received, the table variable declaration statement is parsed to obtain a table type referenced by the table variable and to construct an initial table variable;
[0015] According to table definition information corresponding to the table type, the temporary table corresponding to the table type is created;
[0016] The temporary table is associated with the initial table variable to generate the table variable.
[0017] Optionally, the association of the temporary table with the initial table variable to generate the table variable comprises:
[0018] The table identifier of the temporary table and the memory structure of the initial table variable are obtained;
[0019] The table identifier of the temporary table is stored in the memory structure of the table variable to associate the initial table variable with the temporary table and to generate the table variable.
[0020] Optionally, the method further comprises:
[0021] At the end of the declaration cycle of the table variable, the table variable and the temporary table corresponding to the table variable are destroyed.
[0022] Optionally, the destruction of the table variable and the temporary table corresponding to the table variable at the end of the declaration cycle of the table variable comprises:
[0023] At the end of the declaration cycle of the table variable, all target variables in an execution statement in which the table variable is located are determined;
[0024] All the target variables are traversed to determine variable types of the target variables, the variable types comprising table variables and non-table variables;
[0025] If the target variable is a table variable, the table variable is destroyed and the temporary table corresponding to the table variable is deleted;
[0026] If the target variable is a non-table variable, the target variable is destroyed.
[0027] In a second aspect, an embodiment of the present application provides a data processing apparatus, comprising:
[0028] A first processing module is configured to, in a case where a target operation statement is received, determine a memory structure of a table variable according to a table variable name in the target operation statement;
[0029] A second processing module is configured to determine a temporary table corresponding to the table variable according to a table identifier included in the memory structure.
[0030] a control module configured to perform a data processing operation included in the target operation statement on the temporary table.
[0031] In a third aspect, an electronic device is provided, including: a memory, a processor;
[0032] The memory stores computer-executable instructions.
[0033] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the first aspect and / or various possible implementation manners of the first aspect.
[0034] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a processor, the computer-executable instructions are configured to implement the first aspect and / or various possible implementation manners of the first aspect.
[0035] In a fifth aspect, a computer program product is provided, and the computer program product includes a computer program. When the computer program is executed by a processor, the computer program implements the first aspect and / or various possible implementation manners of the first aspect.
[0036] The data processing method, device, equipment, storage medium, and program product provided by the embodiments of the present application can realize fast positioning and accurate execution of data processing by determining the memory structure of the table variable according to the table variable name in the target operation statement when the target operation statement is received, determining the temporary table corresponding to the table variable according to the table identifier included in the memory structure, and performing the data processing operation included in the target operation statement on the temporary table. This ensures that the operation can directly act on the corresponding temporary table, reduces the data searching and matching time, avoids performance loss caused by misoperation or redundant operation, enables the database to respond to various data processing requests more efficiently, improves the data processing speed and accuracy, and thus improves the database work efficiency and reduces the database maintenance cost. BRIEF DESCRIPTION OF DRAWINGS
[0037] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0038] Figure 1 A flowchart of a data processing method provided by the embodiments of the present application is shown in the figure.
[0039] Figure 2 A flowchart of another data processing method provided by the embodiments of the present application is shown in the figure.
[0040] Figure 3A flowchart of another data processing method provided by an embodiment of the present application is shown in FIG. 6.
[0041] Figure 4 A flowchart of another data processing method provided by an embodiment of the present application is shown in FIG. 6.
[0042] Figure 5 A structural diagram of a data processing apparatus provided by an embodiment of the present application is shown in FIG. 7.
[0043] Figure 6 A structural diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 8.
[0044] The specific embodiments of the present application have been shown in the above-described drawings, and will be described in more detail hereinafter. These drawings and the written description are not intended to restrict 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
[0045] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The following description is made with reference to the accompanying drawings in which like reference numerals refer to like elements, and the term "exemplary" is used herein to mean "serving as an example, instance, or illustration." The following description is not intended to limit the scope of the present application in any way, but rather to provide an example of how the present application can be implemented. The following description includes specific details for the purpose of providing a thorough understanding of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form in order to avoid obscuring the concepts of the present application.
[0046] In the field of database applications, as the continuous expansion of enterprise business and the increasing diversification of application scenarios, database systems are facing increasingly complex data processing and management requirements. Among them, there is a class of data processing scenarios with special requirements. For example, in the real-time transaction risk control system of the financial industry, a large amount of transaction intermediate state data needs to be temporarily stored, and these data are only valid in the current risk assessment process and lose their value after the assessment is completed. For example, during the promotion activities of e-commerce platforms, a large amount of user order temporary grouping information needs to be processed in real time, which is used for accurate promotion of promotional content, and these information is no longer needed after the activities are completed. For example, in large-scale data simulation experiments in the field of scientific research, a large number of intermediate state data are generated during the experiment process, which only serve the current experimental steps and can be discarded after the experiment is completed.
[0047] Currently, the storage requirement of temporary data in the above scenarios is generally met by creating temporary tables. Database administrators (DBAs) need to design and create temporary table structures according to specific business scenarios, and define the required fields to store data. For example, in the financial risk control scenario, a temporary table containing transaction amount, risk score, etc. fields is created, and the transaction intermediate state data is inserted into it for subsequent risk control analysis; in the e-commerce platform promotion scenario, a temporary table containing user ID, grouping type, etc. fields is created to store user order temporary grouping information, etc.
[0048] However, the existing temporary table implementation has many problems.
[0049] In terms of constraint definition, to ensure data accuracy and consistency, constraints need to be set on stored data in business, such as ensuring that the risk score in the financial risk control temporary table is within a reasonable range, and ensuring that the user ID in the e-commerce platform temporary table is unique. However, different database systems have great differences in temporary table constraint definition syntax and rules, and the operation is complex and prone to errors, which leads to incomplete or inaccurate constraint definition and affects data quality.
[0050] In terms of index creation, indexes need to be created to improve data query efficiency, but some database systems have strict restrictions on temporary table index creation, such as only allowing a limited number of indexes to be created for specific types of temporary tables. At the same time, creating indexes may affect the performance of temporary table creation and use. When dealing with large-scale temporary data, the creation time of temporary tables may be prolonged due to high system resource occupation, and the efficiency of business process execution may be reduced.
[0051] In terms of sequence support, some business scenarios need to generate unique sequence numbers for stored data to ensure uniqueness and traceability, such as intermediate state data records in scientific research. However, the existing temporary table implementation is not perfect in terms of sequence support, and many database systems do not provide a convenient temporary table sequence generation mechanism. When using sequences, complex configuration and operation are required, which increases development difficulty and cost.
[0052] In summary, the existing database table definition and management method has the problems of low work efficiency, high maintenance cost, and difficulty in meeting the storage requirements of temporary data when dealing with business expansion and diversified application scenarios.
[0053] Therefore, the application provides a data processing method. In the method, when a target operation statement is received, the memory structure of a table variable is determined according to a table variable name in the target operation statement, a temporary table corresponding to the table variable is determined according to a table identifier included in the memory structure, and a data processing operation included in the target operation statement is performed on the temporary table, so that the data processing is quickly positioned and accurately executed. The operation can directly act on the corresponding temporary table, the data searching and matching time is reduced, the performance loss caused by misoperation or redundant operation is avoided, the database can more efficiently respond to various data processing requests, and the data processing speed and accuracy are improved. Moreover, the temporary table does not need to be redefined each time, the temporary table with the same structure can be directly reused by creating a table variable belonging to the table type, and therefore the database working efficiency is improved and the database maintenance cost is reduced.
[0054] The execution subject of the data processing method provided in the application can be an electronic device with data processing capability, for example, a database server, a distributed computing node, a data processing instance in a cloud computing platform, etc. The database management system or related data processing program is deployed on the electronic device, the temporary table corresponding to the table variable included in the target operation statement is determined by analyzing the target operation statement, the same operation is performed on the temporary table according to the data processing operation on the table variable, and the data processing operation on the temporary table is implemented. Alternatively, the execution subject of the data processing method can be a database processing system, for example, an enterprise-level database management system, a real-time data processing system, a big data analysis platform, etc. The system integrates the functions of table type definition, variable declaration and operation execution, and efficiently processes the temporary data. The database can be a structured query language (SQL) database, an Oracle database, a Kingbase database, etc., and the types of the database are not limited in the embodiments of the application.
[0055] The technical solutions of the application and how the technical solutions solve the above technical problems will be described in detail in the embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the application will be described in detail with reference to the drawings.
[0056] Figure 1 A flowchart of a data processing method provided in the embodiments of the application is shown in FIG. 1. Figure 1 As shown in the figure, the method comprises the following steps.
[0057] S101, when a target operation statement is received, the memory structure of a table variable is determined according to a table variable name in the target operation statement.
[0058] The target operation statement is a statement containing a table variable and used for processing data corresponding to the table variable, and is input by a database user to implement a specific operation on the table variable. For example, the target operation statement can be "SELECT FROM @tv …;", which can be a data manipulation language (DML) or a data query language (DQL), and the application does not limit this. The "@tv" is the name of the table variable to be operated, i.e., the table variable name.
[0059] The table variable name is a character sequence used to uniquely identify the table variable, which needs to comply with the naming rules preset by the database system to ensure that it is distinguished from other variable names in the same execution context. The memory structure is a structured data set stored in the system memory of the table variable, which includes variable type identification, creation time, execution context identification, associated table identification, and data storage address, and the memory structures of different table variables are independent of each other and can be uniquely corresponded through the table variable name.
[0060] In this step, the target operation statement can be first subjected to lexical analysis to split the statement into multiple lexical units, and then the table variable name therein can be recognized through syntax analysis. Subsequently, a variable management system table of the database system is accessed, which stores the mapping relationship between the names of all declared variables and the corresponding memory structures, and the variable name field is a unique key. The table variable name can be used as a query key to perform a matching query in the variable management system table, and after a matching record is found, the content of the "memory structure description" field in the record can be extracted to determine the memory structure of the table variable.
[0061] S102, determine a temporary table corresponding to the table variable according to a table identification included in the memory structure.
[0062] The table identification is a unique string automatically generated by the database system when creating a temporary table, which is used to uniquely identify the temporary table in the system to avoid confusion between different temporary tables. The temporary table is a structured storage structure associated with the table variable and used to actually store the data of the table variable, and its field definition, constraint condition, and index information are consistent with the table type referenced by the table variable. The temporary table can exist only within the life cycle of the table variable, and after the life cycle of the table variable ends, the temporary table is destroyed.
[0063] In this step, the table identifier corresponding to the table variable can be extracted from the memory structure of the table variable, and the temporary table corresponding to the table identifier in the system table (such as a temporary table management system table) of the database system is determined as the temporary table corresponding to the table variable. For example, all temporary table identifiers stored in the system table can be traversed to determine the temporary table identifier that is the same as the table identifier extracted from the memory structure. After determining the temporary table corresponding to the table variable, the structure information (such as field definition, constraint record, index record, storage address, etc.) of the temporary table can be determined from the system table.
[0064] S103, performing a data processing operation included in the target operation statement on the temporary table.
[0065] The data processing operation is a processing behavior of the table variable data specified in the target operation statement, which needs to be executed based on the actual data and structure of the temporary table. The constraint rules of the temporary table may include, for example, non-empty constraint, primary key constraint, unique constraint, CHECK constraint, DEFAULT constraint, etc., for guaranteeing data integrity. The index configuration of the temporary table may include, for example, clustered index, non-clustered index, etc., for improving data positioning and query efficiency. The data processing operation complies with the above constraint rules and index configuration to avoid data anomalies or low efficiency of operation.
[0066] When it is determined that the data processing operation needs to be performed on the temporary table, the core information (such as data items, query conditions, update fields and values, deletion conditions, etc.) related to the operation in the target operation statement can be parsed first, and then combined with the field definition, constraint record, index record and storage address of the temporary table stored in the temporary table management system table, the corresponding operation logic is executed, and the constraint verification is performed synchronously during the operation process. If there is a violation, it will be handled according to the preset rules (such as terminating the operation, returning error information, rolling back the executed steps, etc.).
[0067] For example, if the data processing operation is an insertion operation, the data items in the target operation statement can be parsed first, and according to the field definition of the temporary table (such as field name, data type, length, whether to allow null, etc.), each data item is converted into a data type format matching the corresponding field to ensure that the data format is consistent with the field requirements. Then, according to the storage address of the temporary table, the storage position of the corresponding field is located, and the converted data items are written in sequence. Optionally, it can also be checked one by one whether the data items meet the constraint rules of the temporary table. If a data item violates the constraint, an error message is immediately generated, which can include the constraint type violated, the field and data item involved, etc., and the insertion operation is terminated, no data is written to the temporary table, and the data integrity of the temporary table is avoided.
[0068] If the data processing operation is a query operation, first parse the query conditions (such as field-value matching relationships, logical operation relationships, etc.) and the list of fields to be returned in the target operation statement. Then, check if there is an index related to the query conditions in the temporary table. If it exists, use the index (such as the mapping relationship between field values in indexed records and record storage addresses) to quickly locate data records that may meet the conditions. If not, traverse all records from the beginning of the temporary table's storage address. For each located record, extract the field values involved in the query conditions, compare them precisely with the query conditions, and filter out the records that meet the conditions. Finally, based on the parsed returned field list, extract the corresponding field values from the records that meet the conditions, and organize them into a result set according to a preset structured format (such as the association form between field names and field values) to ensure that the result set can be read normally by subsequent processes or users.
[0069] If the data processing operation is an update operation, the update fields, update values, and update conditions in the target operation statement can be parsed first. Then, based on the temporary table's index configuration, records that meet the update conditions are located. According to the temporary table's field definitions, the update value is converted to a data type format matching the update field, and the current value of the update field in the located record is replaced with the converted update value. Optionally, after the replacement, it can also be checked whether the update value conforms to the temporary table's constraint rules for that field. If the constraint is violated, the update operation is immediately terminated, the executed replacement action is rolled back, and an error message is generated. The error message must include the violating constraint type, the updated field, and the update value to ensure that the temporary table data is not affected by the violating update.
[0070] If the data processing operation is a deletion operation, the deletion conditions in the target operation statement can be parsed first, and then, in conjunction with the temporary table's index configuration, the records that meet the deletion conditions can be located. Then, the located records are removed from the temporary table's storage area, the storage space occupied by these records is marked as reclaimable, and the record count of the temporary table is updated to ensure that the temporary table's metadata is consistent with the actual data volume.
[0071] The method provided in this application, upon receiving a target operation statement, determines the memory structure of the table variable based on the table variable name in the target operation statement, identifies the temporary table corresponding to the table variable based on the table identifier included in the memory structure, and performs the data processing operations included in the target operation statement on the temporary table. This achieves rapid location and accurate execution of data processing, ensuring that the operation can directly affect the corresponding temporary table, reducing data lookup and matching time, avoiding performance loss caused by misoperation or redundant operation, enabling the database to respond to various data processing requests more efficiently, improving data processing speed and accuracy, thereby improving database efficiency and reducing database maintenance costs.
[0072] The following section provides a detailed explanation of how, in step S102, the temporary table corresponding to the table variable is determined based on the table identifier included in the memory structure. Figure 2 This is a flowchart illustrating another data processing method provided in an embodiment of this application. Figure 2 As shown, the aforementioned step S102 may specifically include:
[0073] S201. Determine the memory structure of the table variable based on its name in the system table.
[0074] The system table here could be, for example, a variable management system table. This table is a structured collection in the database system used to centrally manage all declared variables. Its field design needs to meet the requirements of efficient storage and retrieval of variable information. For example, it could include fields such as variable name, memory structure description, variable type, creation time, and context ID. Specifically, the variable name field stores the unique name of the variable, ensuring that each variable corresponds to only one record in the table; the memory structure description stores detailed information about the variable's memory structure, which can be presented as a structured character sequence; the variable type stores the variable's type identifier (such as table type, character type, etc.); the creation time stores the variable's creation time; and the context ID stores the execution context identifier of the variable, used to associate it with the execution environment.
[0075] In this step, the table variable names parsed from the target operation statement can be used as query conditions to access the variable management system table and determine the memory structure corresponding to the table variable name. For example, assuming the system table has an index built with the variable name as the primary key, a query can be performed using this index: starting from the root node of the index, the index key values are compared according to the character order of the table variable name, locating layer by layer to the leaf node. This leaf node directly points to the record in the variable management system table that matches the table variable name. After finding the matching record, the memory structure description in that record is read. This description fully describes the memory structure of the table variable, and the memory structure of the table variable can be determined based on this description.
[0076] S202. Extract the table identifier corresponding to the table variable from the memory structure.
[0077] The table identifier is stored in a memory structure, for example, in the format "TABLE_ID=[table identifier value]", separated from other fields (such as variable type, creation time, etc.) by commas to ensure that the table identifier can be accurately distinguished from other information during parsing and to avoid confusion.
[0078] In this step, the string in the memory structure can be split using commas as delimiters to obtain multiple independent field key-value pairs (such as "VAR_TYPE=TABLE_VAR", "TABLE_ID=TMP_TB_001", "DATA_ADDR=0x00A1B2C3"). These key-value pairs are then iterated through, and each pair is split (using "=" as the delimiter) to obtain the key and value. The key-value pair with the key "TABLE_ID" is then searched for, and the value in that key-value pair is extracted; this value is the table identifier corresponding to the table variable.
[0079] S203. Determine the temporary table in the system table based on the table identifier.
[0080] In this step, the table identifier extracted in S202 is used as a query condition to access the temporary table management system table. A matching process is performed within the temporary table management system table to determine the temporary table corresponding to the table identifier.
[0081] Figure 3 This is a flowchart illustrating another data processing method provided in an embodiment of this application. Figure 3 As shown, the method may further include:
[0082] S301. Upon receiving a table variable declaration statement, parse the table variable declaration statement to obtain the table type referenced by the table variable and construct the initial table variable.
[0083] The table variable declaration statement is used to declare table variables and specify the table type they reference, for example, it can be "DECLARE @tv as table_type". The table variable declaration statement clearly defines the name of the table variable and the associated table type, ensuring that the database system knows the source of the table variable's data structure.
[0084] Table types are special types that combine the characteristics of tables and types. They include table features such as field definitions, constraints, and indexes. These features define the data structure and data rules of table variables. Their complete definition information (table type identifier, table definition information) is stored in the table type system table and can be referenced by table variables.
[0085] Initial table variables form the basic framework of table variables, and can contain basic table variable attributes (such as variable name, referenced table type identifier, creation time, execution context identifier, etc.). They can then be associated with temporary tables to enable data processing capabilities.
[0086] In this step, the table variable declaration statement is first lexically analyzed, breaking it down into multiple lexical units (such as "DECLARE", "@tv", "AS", "table_type"). Then, syntax analysis identifies the table variable name (e.g., "@tv") and the referenced table type name (e.g., "table_type"). Next, the table type system table is accessed. This system table stores the mapping relationship between the names of all defined table types and their table type identifiers and definition information. Using the table type name as the query key, an exact match query is performed in the table type system table. After finding the corresponding record, the "table type identifier" and "table definition information" (such as field definitions, constraint definitions, index definitions, etc.) are extracted to determine the table type referenced by the table variable.
[0087] Initial table variables are generated by constructing an initial table variable memory structure framework. For example, constructing an initial table variable memory structure framework may include: generating variable type identifiers, such as the identifier corresponding to a table variable being fixed as "TABLE_VAR"; recording a character sequence whose creation time is the current time of the database system (such as "202406151030"); and having the database system generate the execution context identifier to which the table variable belongs based on the context of the currently executed statement.
[0088] This information, combined with the table type identifier, forms the initial memory structure description, completing the construction of the initial table variables. Finally, the names of the initial table variables and the initial memory structure description are stored in the variable management system table, forming a new record to ensure that the information of the initial table variables can be retrieved by their names later.
[0089] S302. Based on the table definition information corresponding to the table type, create a temporary table corresponding to the table type.
[0090] Among them, the table definition information is the core information describing the table structure in the table type. It is obtained from the table type system table and includes field definitions (such as field name, data type, length, whether null is allowed, etc.), constraint definitions (such as constraint type, involved fields, constraint condition expression, etc.), and index definitions (such as index name, index type, involved fields, sorting method, etc.). This information is the basis for creating temporary tables and ensures that the structure of the temporary table is consistent with the table type.
[0091] In this step, we first parse the field definitions in the table definition information, assigning a data type identifier and storage length to each field. Then, we calculate the total storage requirements of the temporary table; for example, total storage length = sum of field storage lengths + constraint information storage length + index information storage length + record control information length. Based on the total storage requirements, we send a memory request to the system memory manager, requesting a contiguous memory region. After successful allocation, the memory manager returns the starting address of that region, which is the data storage address for the temporary table.
[0092] Then, the constraint definitions are processed: for each constraint, a constraint record can be generated. Each record can contain, for example, a constraint identifier, constraint type, field identifiers involved, constraint condition expressions, etc. All constraint records are stored in the constraint information area of the temporary table storage area (for example, it can be located at the beginning of the data storage area and has a clear boundary with the data storage area).
[0093] Further process the index definition: For each index, an index record can be generated. The index record may contain, for example, an index identifier, an index name, an index type, field identifiers involved, an index sorting method, an index storage structure description, etc. All index records are stored in the index information area of the temporary table storage area (for example, it may be located after the constraint information area and have a clear boundary with the data storage area).
[0094] After completing the above operations, the temporary table is created. At the same time, the table identifier, structure information and storage address of the temporary table are stored in the temporary table management system table to form the temporary table management record, which facilitates subsequent association and query.
[0095] S303. Associate the temporary table with the initial table variable to generate the table variable.
[0096] Linking a temporary table with an initial table variable binds their information, allowing the initial table variable to acquire the association information from the temporary table, thus enabling it to store and process data, ultimately generating a usable table variable. This step is achieved through the following sub-steps:
[0097] S3031. Obtain the table identifier of the temporary table and the memory structure of the initial table variables.
[0098] In this step, the temporary table management system tables can be accessed to locate the target temporary table based on its creation record. For example, the system can filter the temporary table by at least one of the following: creation time, associated table type identifier, etc. After finding the corresponding temporary table record, the table identifier of the temporary table can be extracted from it.
[0099] Then, by accessing the variable management system table, the corresponding variable record is found according to the name of the initial table variable (such as "@tv"), and the content of the memory structure description in the record is read. This content is the memory structure description information of the initial table variable, and the memory structure of the initial table variable is determined according to the description.
[0100] S3032. Store the table identifier of the temporary table in the memory structure of the table variable to associate the initial table variable with the temporary table and generate the table variable.
[0101] Add a table identifier for the temporary table to the memory structure description of the initial table variable. For example, you can add a field "TABLE_ID=[temporary table identifier]" so that the memory structure of the initial table variable contains key information associated with the temporary table.
[0102] The updated memory structure description is stored in the variable management system table, overwriting the original initial memory structure description record. For example, the corresponding record can be located by the name of the initial table variable, and the value of the "Memory Structure Description" field is updated to a new description containing the table identifier. At this point, the initial table variable and the temporary table are successfully associated, and the initial table variable is upgraded to a table variable that can be used to store and process data. Subsequently, the corresponding temporary table can be quickly located through the table identifier in the memory structure of the table variable to perform data processing operations.
[0103] The method provided in this application, upon receiving a table variable declaration statement, parses the table type referenced by the table variable and constructs an initial table variable. Then, a temporary table is created based on the table definition information of the table type. Finally, the temporary table and the initial table variable are associated to generate the final table variable, thus realizing a complete process from table variable declaration to usability. This process ensures that the structure of the table variable is consistent with the table type and provides data storage capability to the table variable by associating it with a temporary table. This avoids redundant operations of repeatedly creating table structures. Furthermore, the temporary table only exists within the lifecycle of the table variable, reducing system resource consumption, thereby improving database flexibility and resource utilization, and lowering maintenance costs.
[0104] In one possible implementation, the table variable and its corresponding temporary table can be destroyed at the end of the table variable's lifecycle to release system resources and avoid performance degradation caused by long-term resource occupation. Specifically, this implementation is achieved through the following... Figure 4 The steps shown are to be followed. Figure 4 This is a flowchart illustrating another data processing method provided in an embodiment of this application. Figure 4 As shown, the method may further include:
[0105] S401. At the end of the declaration period of a table variable, determine all target variables in the execution statement containing the table variable.
[0106] The lifecycle of a table variable is determined by the execution scope of the statement in which it is executed. Usually, the lifecycle of a table variable ends when the execution statement (such as a batch statement, stored procedure, or function) is completed. At this point, the table variable is no longer used and can be destroyed.
[0107] The target variable refers to all variables declared in the executed statement, including both table variables and non-table variables. It needs to be located through the execution statement context information recorded by the system to ensure that no variable that needs to be destroyed is missed.
[0108] In this step, the execution context management table of the database system can be accessed. This table is a structured collection that stores the context information of each execution statement, and may contain fields such as execution context identifier, execution statement identifier, execution status of the user, and a list of associated variables. The execution context identifier field is the primary key, storing a unique identifier for the execution context; the list of associated variables field stores the names of all variables associated with this execution context.
[0109] Based on the execution context identifier stored in the table variable's memory structure, the corresponding execution statement record is located in the execution context management table, and the contents of the associated variable list in that record are read. The strings in the associated variable list are split using semicolons as delimiters to obtain multiple variable names. The variables corresponding to these variable names are all the target variables in the execution statement where the table variable is located.
[0110] S402. Traverse all target variables and determine the variable type of the target variables.
[0111] The variable types include table variables and non-table variables.
[0112] Non-table variables refer to variables using basic data types (such as character, numeric, and date types) or ordinary composite types (such as structure types and array types). The core difference between non-table variables and table variables is that non-table variables are temporary tables without any association and do not have table structure features (such as fields, constraints, and indexes). They are only used to store single or simple combinations of data.
[0113] Table variables are associated with temporary tables, possess table structure characteristics, and are used to store structured data.
[0114] In this step, we can iterate through each target variable determined by S401 and perform the following operations for each target variable: access the variable management system table, find the corresponding variable record based on the target variable name, and read the variable type in the record.
[0115] If the variable type is a preset table variable identifier (such as "TABLE_VAR"), then the target variable is determined to be a table variable; if the variable type is another type identifier (such as "CHAR_VAR" for character type variable, "INT_VAR" for integer type variable, and "STRUCT_VAR" for structure type variable), then the target variable is determined to be a non-table variable.
[0116] By traversing and determining the type, all target variables are divided into table variables and non-table variables so that the destruction logic can be executed separately later.
[0117] If the target variable is a table variable, it means that the variable is associated with a temporary table. When destroying the table, the variable itself and the associated temporary table need to be processed simultaneously to avoid the temporary table remaining and occupying memory or storage resources. Then, proceed to step S403. If the target variable is a non-table variable, it means that the variable is not associated with a temporary table. Only the variable itself needs to be destroyed to release memory. There is no need to process other associated structures. Then, proceed to step S404.
[0118] S403. Destroy the table variable and delete the temporary table corresponding to the table variable.
[0119] In this step, the variable management system tables can be accessed, the corresponding variable record can be located based on the table variable name, and a deletion operation can be performed to remove the record from the table, ensuring that the management information for that table variable no longer exists in the system. Simultaneously, based on the data storage address stored in the table variable's memory structure, a memory release request is sent to the system memory manager to release the memory space occupied by the table variable's memory structure and temporary data, ensuring that memory resources are reclaimed.
[0120] Then, based on the table identifier stored in the table variable's memory structure, the temporary table management system table can be accessed to find the corresponding temporary table record. A deletion operation is then performed to remove the record from the table and clear the management information of the temporary table from the system. Next, based on the temporary table's storage address, a memory release request is sent to the system memory manager to release the memory space occupied by the temporary table's data storage area, constraint information area, and index information area, ensuring that all storage resources related to the temporary table are reclaimed.
[0121] S404, Destroy the target variable.
[0122] In this step, the variable management system tables can be accessed directly. The corresponding variable record can be located based on the non-table variable name, and a deletion operation can be performed to remove the record from the table, clearing the management information of the non-table variable from the system. Then, based on the data storage address in the non-table variable's memory structure, a memory release request is sent to the system memory manager to release the memory space occupied by the non-table variable's memory structure and data.
[0123] The method provided in this application automatically reclaims resources by batch determining all target variables in the execution statement at the end of the table variable declaration period, distinguishing between table variables and non-table variables, and executing destruction logic separately for each. This method not only destroys the table variables and non-table variables themselves, but also simultaneously deletes the temporary tables associated with the table variables, avoiding resource residue, reducing the maintenance costs of manual cleanup, and ensuring the resource utilization and long-term stable operation of the database system.
[0124] Figure 5 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. Figure 5As shown, the device may include: a first processing module 11, a second processing module 12, and a control module 13.
[0125] The first processing module 11 is used to determine the memory structure of the table variable based on the table variable name in the target operation statement when the target operation statement is received.
[0126] The second processing module 12 is used to determine the temporary table corresponding to the table variable based on the table identifier included in the memory structure.
[0127] Control module 13 is used to perform data processing operations on the temporary table as included in the target operation statement.
[0128] Optionally, the second processing module 12 is specifically used to determine the memory structure of a table variable based on its name in the system table. It then extracts the table identifier corresponding to the table variable from the memory structure and determines a temporary table in the system table based on the table identifier.
[0129] Optionally, the first processing module 11 is further configured to, upon receiving a table variable declaration statement, parse the table variable declaration statement to obtain the table type referenced by the table variable and construct an initial table variable. The control module 13 is further configured to, based on the table definition information corresponding to the table type, create a temporary table corresponding to the table type. The temporary table is then associated with the initial table variable to generate the table variable.
[0130] Optionally, control module 13 is specifically used to obtain the table identifier of the temporary table and the memory structure of the initial table variable. The table identifier of the temporary table is stored in the memory structure of the table variable to associate the initial table variable with the temporary table, thereby generating the table variable.
[0131] Optionally, the control module 13 is also used to destroy the table variable and the temporary table corresponding to the table variable at the end of the table variable's lifecycle.
[0132] Optionally, control module 13 is specifically used to determine all target variables in the execution statement containing the table variable at the end of the table variable's lifecycle.
[0133] Iterate through all target variables to determine their variable types, which include table variables and non-table variables.
[0134] If the target variable is a table variable, then destroy the table variable and delete the temporary table corresponding to the table variable.
[0135] If the target variable is not a table variable, then destroy the target variable.
[0136] The data processing apparatus provided in this application embodiment can execute the data processing method in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described again here.
[0137] Figure 6 This is a schematic diagram of an electronic device provided in an embodiment of this application. The electronic device is used to execute the aforementioned data processing method. Figure 6 As shown, the electronic device 600 may include at least one processor 601, a memory 602, and a communication interface 603.
[0138] The memory 602 is used to store programs. Specifically, the program may include program code, which includes computer operation instructions.
[0139] The memory 602 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0140] The processor 601 is used to execute computer execution instructions stored in the memory 602 to implement the methods described in the foregoing method embodiments. The processor 601 may be a CPU, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0141] The processor 601 can communicate and interact with external devices through the communication interface 603. These external devices can be, for example, the client device mentioned earlier. In specific implementations, if the communication interface 603, memory 602, and processor 601 are implemented independently, they can be interconnected via a bus to complete communication. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc., but this does not imply that there is only one bus or one type of bus.
[0142] Optionally, in a specific implementation, if the communication interface 603, memory 602, and processor 601 are integrated on a single chip, then the communication interface 603, memory 602, and processor 601 can communicate through an internal interface.
[0143] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0144] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0145] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0146] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0147] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0148] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0149] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0150] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0151] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0152] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A data processing method, characterized in that, The method includes: Upon receiving a target operation statement, the memory structure of the table variable is determined based on the table variable name in the target operation statement; Based on the table identifiers included in the memory structure, determine the temporary table corresponding to the table variable; Perform the data processing operations included in the target operation statement on the temporary table.
2. The method according to claim 1, characterized in that, The step of determining the temporary table corresponding to the table variable based on the table identifier included in the memory structure includes: The memory structure of the table variable is determined in the system table based on the table variable name; Extract the table identifier corresponding to the table variable from the memory structure; The temporary table is determined in the system table based on the table identifier.
3. The method according to claim 2, characterized in that, The method further includes: Upon receiving a table variable declaration statement, the table variable declaration statement is parsed to obtain the table type referenced by the table variable and an initial table variable is constructed. Based on the table definition information corresponding to the table type, create the temporary table corresponding to the table type; The temporary table is associated with the initial table variable to generate the table variable.
4. The method according to claim 3, characterized in that, The process of associating the temporary table with the initial table variable to generate the table variable includes: Obtain the table identifier of the temporary table and the memory structure of the initial table variable; The table identifier of the temporary table is stored in the memory structure of the table variable to associate the initial table variable with the temporary table, thereby generating the table variable.
5. The method according to claim 2, characterized in that, The method further includes: At the end of the lifecycle of the table variable, the table variable and the temporary table corresponding to the table variable are destroyed.
6. The method according to claim 5, characterized in that, The step of destroying the table variable and the temporary table corresponding to the table variable at the end of its lifecycle includes: At the end of the declaration period of the table variable, determine all target variables in the execution statement containing the table variable; Iterate through all the target variables to determine the variable type of the target variables, including table variables and non-table variables; If the target variable is a table variable, then destroy the table variable and delete the temporary table corresponding to the table variable; If the target variable is a non-table variable, then the target variable is destroyed.
7. A data processing apparatus, characterized in that, The device includes: The first processing module is used to determine the memory structure of the table variable based on the table variable name in the target operation statement when a target operation statement is received. The second processing module is used to determine the temporary table corresponding to the table variable based on the table identifier included in the memory structure; The control module is used to perform data processing operations on the temporary table as included in the target operation statement.
8. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-6.