Database table structure repairing method and device, equipment, medium and product
By acquiring database connection information and using a large language model analysis model to automatically identify and repair differences in database table structures, the problem caused by differences in table structures between the test environment and the production environment was solved, achieving efficient and accurate maintenance of database table structure consistency.
Patent Information
- Application Number
- CN202511946229.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-04-14
AI Technical Summary
In systems such as finance, e-commerce, and enterprise applications, differences in database table structures between the test environment and the production environment can lead to distorted test results, abnormal data migration, or system malfunctions. Traditional manual repair methods are time-consuming and error-prone, making it difficult to guarantee repair efficiency and accuracy.
By acquiring the connection information between the source and target databases and utilizing a difference analysis model built from a large language model, the system automatically identifies and generates table structure repair suggestions, achieving automated and intelligent repair processing.
It significantly improves the efficiency and accuracy of maintaining database table structure consistency, reduces errors caused by manual operations, and ensures system stability and data security.
Smart Images

Figure CN121858545A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data, and in particular to a method, apparatus, device, medium and product for repairing database table structures. Background Technology
[0002] In systems requiring multi-environment database collaboration, such as those in finance, e-commerce, and enterprise applications, maintaining consistency in database table structures between the testing and production environments is crucial for ensuring system stability, data security, and business continuity. For example, in banking systems, the testing environment needs to simulate real-world business scenarios from the production environment to verify the compatibility of new features or system upgrades.
[0003] However, the database table structure in the test environment often differs from that in the production environment due to development iterations, version updates, or differences in environment configuration, such as added fields, changes in data types, or missing indexes. These differences can lead to distorted test results, abnormal data migration, or system malfunctions.
[0004] Traditional methods rely on developers or operations personnel to manually compare table structures and write repair scripts. However, as system complexity increases, the number of database tables and the size of fields grow exponentially. Manual operation is not only time-consuming but also prone to errors. Especially in scenarios involving multi-table joins and cross-environment data synchronization, the repair efficiency and accuracy are difficult to guarantee. Summary of the Invention
[0005] This application provides a method, apparatus, device, medium, and product for repairing database table structures, which solves the problem that existing database table structure repair relies on manual operation, resulting in low repair efficiency and accuracy.
[0006] Firstly, this application provides a method for repairing database table structures, including:
[0007] Obtain connection information between the source and target databases from the database management system;
[0008] Based on the connection information, the source database and the target database are accessed respectively to obtain the first table structure metadata of the data table in the source database and the second table structure metadata of the data table in the target database.
[0009] By comparing the metadata of the first table structure with the metadata of the second table structure, the table structure difference information between the source database and the target database is obtained;
[0010] Based on the table structure difference information, a difference analysis model based on a large language model is used to obtain table structure repair suggestions for the target database;
[0011] Based on the repair recommendations, the table structure of the target database is repaired.
[0012] Secondly, this application provides a database table structure repair device, comprising:
[0013] The first acquisition module is used to obtain connection information between the source database and the target database from the database management system;
[0014] The second acquisition module is used to access the source database and the target database respectively based on the connection information, and acquire the first table structure metadata of the data table in the source database, and the second table structure metadata of the data table in the target database.
[0015] The determination module is used to compare the first table structure metadata with the second table structure metadata to obtain the table structure difference information between the source database and the target database;
[0016] The third acquisition module is used to obtain table structure repair suggestions for the target database based on the table structure difference information and using a difference analysis model built on a large language model.
[0017] The processing module is used to repair the table structure of the target database according to the repair suggestions.
[0018] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0019] The memory stores computer-executed instructions;
[0020] The processor executes computer execution instructions stored in the memory to implement the database table structure repair method as described in the first aspect and various possible implementations of the first aspect.
[0021] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions thereon, which, when executed by a processor, are used to implement the database table structure repair method as described in the first aspect and various possible implementations of the first aspect.
[0022] Fifthly, this application provides a program product, including a computer program, which, when executed by a processor, implements the database table structure repair method described above.
[0023] The database table structure repair method, apparatus, device, medium, and product provided in this application obtain connection information between a source database and a target database. Based on the connection information, the first table structure metadata of the data tables in the source database and the second table structure metadata of the data tables in the target database are obtained. Then, the first and second table structure metadata are compared to determine the table structure differences between the source and target databases. Based on these differences, a difference analysis model constructed using a large language model is employed to obtain repair suggestions for the target database table structure. Finally, the table structure of the target database is repaired according to the repair suggestions. This method can automatically and intelligently identify and repair differences in database table structures, significantly improving the efficiency and accuracy of maintaining database table structure consistency and reducing errors that may occur due to manual operation. Attached Figure Description
[0024] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0025] Figure 1 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 1 ;
[0026] Figure 2 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 2 ;
[0027] Figure 3 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 3 ;
[0028] Figure 4 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 4 ;
[0029] Figure 5 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 5 ;
[0030] Figure 6 A schematic diagram of a database table structure repair device provided in this application;
[0031] Figure 7 This is a schematic diagram of the structure of an electronic device provided in this application.
[0032] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0033] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0034] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of the relevant data all comply with relevant laws, regulations, and standards, necessary confidentiality measures have been taken, they do not violate public order and good morals, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0035] Furthermore, the technical solution involved in this application, which involves big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.) and the use of artificial intelligence technology for automated decision-making, and makes decisions that have a significant impact on personal rights based on the results of automated decision-making, provides users with corresponding operation entry points for users to choose to agree to or reject the results of automated decision-making; if the user chooses to reject, the process will proceed to the expert decision-making process.
[0036] It should be noted that the database table structure repair method, apparatus, equipment, medium and product provided in this application can be used in the field of big data, or in any field other than big data. The application field of the database table structure repair method, apparatus, equipment, medium and product in this application is not limited.
[0037] In systems requiring multi-environment database collaboration, such as those in finance, e-commerce, and enterprise applications, maintaining consistency in database table structures between the testing and production environments is crucial for ensuring system stability, data security, and business continuity. For example, in banking systems, the testing environment needs to simulate real-world business scenarios from the production environment to verify the compatibility of new features or system upgrades.
[0038] However, the database table structure in the test environment often differs from that in the production environment due to development iterations, version updates, or differences in environment configuration, such as added fields, changes in data types, or missing indexes. These differences can lead to distorted test results, abnormal data migration, or system malfunctions.
[0039] Traditional methods rely on developers or operations personnel manually comparing table structures and writing remediation scripts. Developers or operations personnel manually extract table structure information between the test and target environments using SQL statements or database management tools, comparing differences field by field. Finally, based on the difference report, developers manually write SQL scripts or use database migration tools to perform remediation operations.
[0040] However, as system complexity increases, the number of database tables and the size of fields grow exponentially. Manual comparison and repair operations are not only time-consuming but also prone to errors, especially in scenarios involving multi-table joins and cross-environment data synchronization, where repair efficiency and accuracy are difficult to guarantee. Furthermore, frequent changes and version iterations in the test environment require traceability and auditability for repair operations to meet compliance requirements. Therefore, there is an urgent need for a technical solution that can automatically identify table structure differences, intelligently generate repair plans, and support full-process auditing to address the table structure repair needs in large-scale database environments.
[0041] To address the aforementioned issues, this application proposes a database table structure repair method. This method uses database table structure metadata as the processing object, leverages a large-scale model to perform semantic analysis of discrepancies and generate repair suggestions, executes the repair operations through automated scripts, and incorporates access control and auditing mechanisms to form a closed-loop process from discrepancy identification to repair execution. This transforms the traditional repair process, which relies on human experience, into an intelligent process based on data-driven and model-generated methods. The automated extraction and comparison processes significantly reduce manual operation time, and the large-scale model analysis, combined with business rules, generates repair suggestions, avoiding errors caused by insufficient human experience.
[0042] This application applies to complex system scenarios involving multi-environment database collaboration, such as those in the financial industry (e.g., core banking systems) and e-commerce platforms. In these scenarios, the test environment needs to maintain table structure consistency with the production environment to verify the correctness of business logic. For example, in a banking system, the test environment needs to simulate the structure of customer information tables in the production environment to ensure compatibility before new features are deployed. In terms of network architecture, the test environment and production environment are typically connected through database middleware. The system needs to obtain metadata of the database instance through an environment ledger system and interact with the large model service through application programming interfaces (APIs) or script interfaces.
[0043] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0044] Figure 1 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 1 .like Figure 1 As shown, the database table structure repair method provided in this embodiment is applied to a database repair system and includes:
[0045] S101: Obtain connection information between the source database and the target database from the database management system.
[0046] As is understandable, a database management system (DBMS) is a system used to store and manage database connection parameters, such as an environment ledger system or a database configuration center. For example, in a banking system, the DBMS stores the IP address, port, username, and password of a MySQL instance in the test environment.
[0047] To obtain connection information, pre-stored connection parameters can be read from the database management system. Connection information is a set of elements required to establish a database connection, which may include, for example, IP address, port, username, and password. The IP address identifies the database server's location on the network; different IP addresses correspond to different network nodes, and requests can be sent to the target database server through it.
[0048] A port is a specific channel monitored by the database service on a server. A server may run multiple services simultaneously, and these services can be distinguished by different ports. A specific port can receive and process client connection requests. Usernames and passwords are credentials used for authentication, ensuring that only authorized users can access the database.
[0049] S102: Based on the connection information, access the source database and the target database respectively, and obtain the first table structure metadata of the data table in the source database, and the second table structure metadata of the data table in the target database.
[0050] Understandably, after obtaining the connection information, a connection relationship between the two databases can be established based on that information. And based on this connection relationship, the table structure metadata of both databases can be retrieved.
[0051] Table structure metadata is a collection of information describing the structure of a database table. This may include, for example, field names, data types, indexes, and constraints. Field names are the names of each data item. Data types specify the type of data stored in each field. Indexes are data structures that allow for quick location of specific data. Constraints refer to the restrictions imposed on a field.
[0052] The metadata of the above table structure can be obtained by calling the interfaces or commands provided by the database management tools. Different database repair systems may have specific tools and methods, which are not limited here.
[0053] S103: Compare the metadata of the first table structure with the metadata of the second table structure to obtain the table structure difference information between the source database and the target database.
[0054] Understandably, after obtaining the metadata of the two table structures, one can use professional tools or write specific scripts to conduct a comprehensive and detailed comparative analysis of the metadata of the two table structures, accurately identify the differences between the source database and the target database in terms of table structure. These differences can include the addition or removal of fields, changes in data types, different constraints, inconsistencies in index settings, etc., thus providing a strong basis and guidance for subsequent database repair.
[0055] S104: Based on table structure difference information, use a difference analysis model built on a large language model to obtain table structure repair suggestions for the target database.
[0056] Understandably, a large language model is a powerful language processing model built on deep learning technology and trained on a large amount of text data. It can understand natural language, generate natural language, and perform logical reasoning, and can simulate the human language thinking process.
[0057] The difference analysis model built on the large language model applies the capabilities of the large language model to the field of database table structure difference analysis. Through specific algorithms and rules, it can understand the difference information of table structure and generate targeted repair suggestions based on the database design practice process, business rules and knowledge of similar past cases.
[0058] Specifically, the database repair system can input table structure discrepancies into a discrepancy analysis model. Leveraging its powerful language understanding and reasoning capabilities, combined with a built-in database knowledge base and rule engine, the model analyzes and judges the discrepancies. The model can reference database design standards and specifications, as well as the specific needs of the business system, to generate a series of repair suggestions for the target database table structure.
[0059] S105: Based on the repair recommendations, repair the table structure of the target database.
[0060] Understandably, repair suggestions may include modifying the data type of a field to match the source database, adjusting the field length to meet data storage requirements, adding or removing constraints to ensure data accuracy and integrity, and rebuilding indexes to improve query performance.
[0061] The database repair system can understand and analyze repair suggestions, clarifying the specific fields targeted by each suggestion and the potential impact after implementation. After fully understanding the suggestions, a repair plan can be developed. Because the repair of different table structure elements may have dependencies, the repair plan should clearly specify the order of repairs. Finally, the database repair system can implement the repair operations step by step according to the plan. During execution, the system's operating procedures and syntax rules must be strictly followed.
[0062] The database table structure repair method provided in this embodiment obtains connection information between the source and target databases from the database management system. Based on the connection information, it accesses both the source and target databases to obtain the first table structure metadata of the data tables in the source database and the second table structure metadata of the data tables in the target database. By comparing the first and second table structure metadata, the table structure difference information between the source and target databases is obtained. Based on the table structure difference information, a difference analysis model built based on a large language model is used to obtain table structure repair suggestions for the target database. According to the repair suggestions, the table structure of the target database is repaired. This method achieves automated and intelligent identification and repair of database table structure differences, greatly improving the efficiency and accuracy of maintaining database table structure consistency and reducing errors that may be caused by manual operation.
[0063] In some embodiments, the table structure differences between the source database and the target database can be determined by comparing the field names, data types, index information, and constraints in the metadata of the first table structure and the metadata of the second table structure item by item.
[0064] Understandably, table structure metadata includes multiple key elements. Comparison tools or specific algorithms can be used to conduct a detailed, item-by-item comparison and analysis of each item in the metadata of the first and second table structures, following predetermined rules and order. Through this item-by-item comparison process, the database repair system can identify differences in table structure between the source and target databases.
[0065] Specifically, Figure 2 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 2 .like Figure 2 As shown, in Figure 1 Based on the embodiments, the process of determining table structure difference information is described in detail, including:
[0066] S201: Perform a match check on the field names in the first table structure metadata and the second table structure metadata to detect whether there are any newly added or deleted fields in the target database.
[0067] Understandably, the first and second table structure metadata represent the table structure information of the source and target databases, respectively. By comparing the field names in these two metadata sets one by one, the database repair system can detect changes in the fields of the target database relative to the source database.
[0068] For example, if a field name exists in the metadata of the second table structure but cannot be found in the metadata of the first table structure, it means that the field has been added to the target database. Conversely, if a field exists in the metadata of the first table structure but not in the metadata of the second table structure, it means that the field has been deleted from the target database. This field name matching check ensures the integrity and consistency of the database table structure, avoiding errors in data storage, querying, and business logic caused by missing or added fields.
[0069] S202: Perform a consistency check on the data types in the metadata of the first table structure and the metadata of the second table structure to detect whether the data types in the target database have changed.
[0070] Understandably, performing consistency checks on the data types of the first and second table structure metadata ensures that the data types of fields in the target database are consistent with those in the source database. Different data types have different storage ranges and precisions; for example, integers, floating-point numbers, and strings have different data storage and calculation methods.
[0071] If the data type of a field in the target database changes, it may lead to data storage errors, inaccurate calculation results, or incompatibility with the application. Through data type consistency verification, the database repair system can ensure the correctness and consistency of data in different database environments, avoiding various data anomalies and business failures caused by data type changes.
[0072] S203: Verify the index types and positions in the metadata of the first table structure and the metadata of the second table structure to detect whether the indexes in the target database are missing or have been adjusted.
[0073] Understandably, indexes are used to accelerate data querying and retrieval in a database, improving database performance. Index information includes the index type and index location. Verifying the index type and location in the metadata of both the first and second table structures ensures that the index structure of the target database is consistent with that of the source database. Index types include primary key indexes, unique indexes, etc., and different index types are suitable for different query scenarios.
[0074] The location of an index determines which field it is created on, which also affects query efficiency. If an index is missing in the target database, it may degrade the performance of related queries; if the index location is adjusted, it may alter query execution, thus impacting query efficiency. By validating the index type and location, the system can promptly detect missing or adjusted indexes in the target database and take appropriate measures to repair or optimize them, ensuring database query performance.
[0075] S204: Perform integrity checks on the constraints in the first table structure metadata and the second table structure metadata to detect whether the constraints in the target database are invalid or newly added.
[0076] Understandably, constraints are rules used in a database to ensure data integrity and consistency. Constraints can include, for example, unique constraints and NOT NULL constraints. Unique constraints ensure that data values in a field are unique; NOT NULL constraints require that a field cannot contain null values. If constraints in the target database fail, data duplication, inconsistency, or violations of business rules may occur. Adding new constraints may restrict related data operations. By validating the integrity of constraints, changes to constraints can be detected promptly, ensuring the integrity and consistency of database data and preventing data errors and business logic confusion caused by constraint issues.
[0077] S205: Based on the above detection results, obtain the table structure difference information between the source database and the target database.
[0078] Understandably, after verifying field names, data types, index types and locations, constraints, etc., the system can perform a comprehensive analysis based on the results of multiple checks to obtain information on the differences in table structure between the source and target databases. This difference information can be presented in a clear and detailed manner, showing the changes in table structure between the target and source databases.
[0079] The database table structure repair method provided in this embodiment can obtain multi-faceted table structure difference information by comparing and analyzing the metadata of the two table structures in turn. This difference information can clearly show in which aspects the target database table structure differs from the source database table structure, providing a clear direction for subsequent repair work.
[0080] Figure 3 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 3 .like Figure 3 As shown, in Figure 1 Based on the examples, the process of obtaining table structure repair suggestions is described in detail, including:
[0081] S301: Based on the table structure difference information, the difference analysis model is used to analyze the table structure difference information to obtain the difference analysis results.
[0082] Understandably, inputting table structure differences into a difference analysis model allows the model to utilize its learned knowledge and algorithms to perform a comprehensive and detailed analysis of these differences. It compares each field and constraint individually, not only identifying existing differences but also classifying and assessing their type and severity. For example, the model can distinguish between simple field name changes and complex differences involving data type incompatibility. After a series of analysis processes, it ultimately outputs detailed and accurate difference analysis results, providing a solid foundation for subsequent remediation work.
[0083] S302: Based on the difference analysis results, use the difference analysis model to generate table structure repair suggestions.
[0084] The repair suggestions include: repairing scripts and / or repairing operation steps.
[0085] Understandably, based on the results of difference analysis, the model can comprehensively consider multiple factors to generate remediation suggestions. For simple differences, such as misspelled field names or minor adjustments to constraints, the model can directly generate corresponding remediation scripts. These remediation scripts are typically written in a database-supported scripting language, such as SQL statements. The remediation scripts are highly efficient and can run directly in the database environment, quickly completing the remediation work.
[0086] For complex discrepancies, the model can generate detailed remediation steps. These steps describe the entire remediation process in a clear and easy-to-understand way, including the necessary preparations, precautions to take when executing the remediation script, and how to verify the remediation after completion.
[0087] Optionally, table structure repair suggestions can also be generated using a difference analysis model, based on the difference analysis results and the business rule base of the business system to which the target database belongs.
[0088] Understandably, the business rule base is a concentrated embodiment of the core logic of a business system, encompassing various rules, constraints, and processes followed during business operations. When generating table structure repair suggestions based on the results of difference analysis and the business rule base, the difference analysis results can point out problems in the table structure, and the business rule base is happy to provide directions and boundaries for repairing these problems.
[0089] Alternatively, the repair suggestions can be validated based on the business rule base of the business system to which the target database belongs.
[0090] Understandably, after generating table structure repair suggestions, they should be validated to ensure the feasibility and effectiveness of the repair solution. Validation using the business rule base of the business system to which the target database belongs allows for a comprehensive review of the repair suggestions from a business logic perspective. The rules in the business rule base are the foundation for the normal operation of the business; any changes to the table structure require adherence to these rules.
[0091] Validation based on a business rule base allows for the early detection of potential problems. The validation process checks each item in the suggested repairs against rules in the business rule base. If a conflict is found, it is marked for further analysis and processing. This validation method ensures that the suggested repairs do not disrupt the normal operation of the business system and guarantees that the corrected table structure can be seamlessly integrated into business processes.
[0092] If the validation fails, the discrepancy analysis model is used to generate table structure repair suggestions based on the discrepancy analysis results and the reasons for the validation failure.
[0093] Understandably, if the validation fails, it indicates that the current repair suggestions are inconsistent with business rules and need to be adjusted and optimized. The difference analysis model has already conducted an in-depth analysis and understanding of the differences in the table structure during the previous difference analysis process. Combined with the specific reasons for the validation failure, it can more accurately pinpoint the problem.
[0094] Based on the analysis of the reasons for the validation failure, the model can readjust the repair suggestions, taking into account both the difference analysis results and the reasons for the validation failure, and generate more compliant repair suggestions from the perspective of business rules.
[0095] The database table structure repair method provided in this embodiment analyzes table structure differences to obtain results. Based on this analysis, it not only generates accurate and business-compliant table structure repair suggestions by combining a business rule base, ensuring that the repaired table structure meets business operation requirements, but also verifies the repair suggestions using the business rule base. This method improves the accuracy and efficiency of database repair and effectively ensures a high degree of compatibility between the database and the business system.
[0096] Figure 4 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 4 .like Figure 4 As shown, in Figure 1 Based on the embodiments, the process of obtaining connection information between the source database and the target database is described in detail, including:
[0097] S401: Receives a user-triggered differential repair request for the target database.
[0098] Understandably, users may encounter discrepancies between the target database and their expectations during database usage, such as differences in table structure. These discrepancies can be caused by various reasons, such as incorrect table structure updates during database upgrades or errors during data migration leading to inconsistencies between the table structure and the source database.
[0099] Once users notice these issues, they can proactively trigger a difference repair request for the target database. This request explicitly informs the system that the target database has table structure differences and requires repair. Triggering this request could be achieved by the user selecting and submitting a repair request through the database repair system's interface.
[0100] S402: In response to the request, authenticate the user's repair permissions.
[0101] Understandably, when the database repair system receives a differential repair request triggered by a user, it first needs to authenticate the user's repair permissions. The system needs to ensure that the user initiating the repair request has the appropriate permissions to guarantee the security of the data in the database. Permission authentication can include identity authentication and permission authentication.
[0102] The system can first check the user's identity information, such as username and password, to confirm that the user has legitimately registered and logged into the system. It then further examines the user's permission level to determine if they have the authority to perform differential repair on the target database.
[0103] The database repair system can only proceed with the next step if the user's authorization is successful, meaning the system confirms that the user has sufficient permissions to perform the repair operation. If the authorization fails, the system can reject the user's request and send the user the corresponding error message, informing them that their permissions are insufficient or the authorization failed.
[0104] S403: If the repair permission authentication is successful, obtain the connection information between the source database and the target database from the database management system.
[0105] Understandably, the source database serves as a data standard and reference, containing correct and complete table structure information. The target database, on the other hand, is the database that needs repair, and its table structure differs. Once repair authorization is successful, the repair system can obtain connection information from the database management system to establish a connection between the source and target databases.
[0106] The database table structure repair method provided in this embodiment, after a user triggers a difference repair request for the target database, authenticates the user's repair permissions by responding to the request, ensuring that only authorized users can continue to operate and protecting data security. After successful authentication, the connection information between the source and target databases is obtained, laying the foundation for accurate comparison of table structure differences and the formulation of repair strategies. This process standardizes the processing of database difference repair requests, effectively preventing unauthorized users from arbitrarily modifying the database and reducing data security risks.
[0107] Figure 5 A flowchart illustrating a database table structure repair method provided in this application embodiment. Figure 5 .like Figure 5 As shown, in Figure 1 Based on the examples, the process of repairing the table structure is described in detail, including:
[0108] S501: Output repair suggestions.
[0109] Understandably, after generating specific remediation suggestions, these structured suggestions can be delivered to users through channels such as user interfaces, email, or application programming interfaces (APIs). The delivered content can include a problem description, remediation solutions, and expected results, ensuring users fully understand the remediation logic and can determine its feasibility.
[0110] S502: In response to the user's repair confirmation command based on the repair recommendations, generate a repair script based on the repair recommendations.
[0111] Understandably, after receiving a repair suggestion, users can authorize the repair system to perform the repair operation by giving explicit instructions (such as clicking the "Confirm Repair" button, replying with specific keywords, etc.). After receiving the confirmation instruction, the repair system can convert the repair suggestion into an executable script.
[0112] The script generation needs to follow the repair logic in the repair suggestions, and also needs to consider the database type and the languages supported by the database to avoid execution failure due to syntax differences.
[0113] S503: Execute a repair script on the target database to repair the table structure of the target database.
[0114] Understandably, after the script is generated, the repair system can execute the repair script in the target database. Before execution, the database status needs to be verified and the relevant table structure and data need to be backed up to prevent data loss due to unexpected situations.
[0115] During execution, the system needs to monitor the script output in real time, capture and handle exceptions. After execution, the data table structure can be verified to confirm that it has been repaired to the target state.
[0116] Optionally, after repairing the table structure of the target database, record the details of the target database repair operation, including at least one of the following: operation time, operator, difference details, and repair content.
[0117] Understandably, after the repair operation is completed, the repair system can automatically generate a detailed operation log, recording key information throughout the repair lifecycle. The log content may include:
[0118] Operation Time: Start and end times of the repair, accurate to the second, facilitating the determination of operation timeliness and the investigation of time-related issues. Operator: The user account that performed the repair operation. Difference Details: Comparison of table structures before and after the repair; a visual report can be automatically generated using a difference analysis tool. Repair Content: The actual script content, parameter configurations, and execution results, facilitating review or rollback operations.
[0119] The generated logs must be stored securely and support retrieval by time, operation type, or keyword to meet compliance auditing and troubleshooting needs.
[0120] The database table structure repair method provided in this embodiment automatically generates structured repair suggestions and clearly outputs them to the user. After user confirmation, these suggestions are converted into repair scripts. The system can safely and accurately execute table structure repair operations and record detailed information about the repair operations, achieving full traceability of the repair process. For example, in a bank system test environment, auditors can locate the specific person responsible for the repair and the time of the operation through the operation log, significantly reducing the difficulty of troubleshooting.
[0121] Figure 6 This is a schematic diagram of a database table structure repair device provided in this application. Figure 6 As shown, this application provides a database table structure repair device, the database table structure repair device 600 including:
[0122] The first acquisition module 601 is used to obtain connection information between the source database and the target database from the database management system;
[0123] The second acquisition module 602 is used to access the source database and the target database respectively based on the connection information, and to acquire the first table structure metadata of the data table in the source database and the second table structure metadata of the data table in the target database.
[0124] The module 603 is used to compare the metadata of the first table structure with the metadata of the second table structure to obtain the table structure difference information between the source database and the target database.
[0125] The third acquisition module 604 is used to obtain table structure repair suggestions for the target database based on the table structure difference information and using the difference analysis model built based on the large language model.
[0126] Processing module 605 is used to repair the table structure of the target database according to the repair suggestions.
[0127] Optionally, module 603 is specifically used to compare the field names, data types, index information, and constraints in the metadata of the first table structure with those of the second table structure to obtain the table structure difference information between the source database and the target database.
[0128] Optionally, module 603 is specifically used to perform a matching degree check on the field names in the first table structure metadata and the second table structure metadata to detect whether there are any newly added or deleted fields in the target database; and to perform a consistency check on the data types in the first table structure metadata and the second table structure metadata to detect whether the data types in the target database have changed.
[0129] The determination module 603 is specifically used to verify the index type and position in the metadata of the first table structure and the metadata of the second table structure to detect whether the indexes in the target database are missing or adjusted; and to perform integrity verification on the constraints in the metadata of the first table structure and the metadata of the second table structure to detect whether the constraints in the target database are invalid or added.
[0130] The determination module 603 is specifically used to obtain the table structure difference information between the source database and the target database based on the above detection results.
[0131] Optionally, the third acquisition module 604 is specifically used to analyze the table structure difference information using a difference analysis model based on the table structure difference information to obtain the difference analysis results; and to generate table structure repair suggestions based on the difference analysis results using the difference analysis model, the repair suggestions including: repair scripts and / or repair operation steps.
[0132] Optionally, the third acquisition module 604 is specifically used to generate table structure repair suggestions based on the difference analysis results and the business rule base of the business system to which the target database belongs, using the difference analysis model;
[0133] Alternatively, the device may also include: a generation module 606;
[0134] Processing module 605 is also used to verify the repair suggestions based on the business rule base of the business system to which the target database belongs;
[0135] The generation module 606 is used to regenerate table structure repair suggestions based on the difference analysis results and the reasons for the failure of the validation when the validation fails.
[0136] Optionally, the first acquisition module 601 is specifically used to receive a user-triggered differential repair request for the target database; in response to the request, authenticate the user's repair permission; and if the repair permission authentication is successful, obtain the connection information between the source database and the target database from the database management system.
[0137] Optionally, the processing module 605 is specifically used to output repair suggestions; in response to the user's repair confirmation command based on the repair suggestions, generate a repair script based on the repair suggestions; and execute the repair script on the target database to repair the table structure of the target database.
[0138] Optionally, the generation module 606 is also used to record the details of the target database repair operation after the table structure of the target database is repaired. The details include at least one of the following: operation time, operator, difference details, and repair content.
[0139] The database table structure repair device provided in this application embodiment has a similar implementation principle and technical effect to the implementation of each part of the aforementioned database table structure repair method, and will not be described again here.
[0140] Figure 7 This is a schematic diagram of the structure of an electronic device provided in this application. Figure 7 This application provides an electronic device 700, which includes a receiver 701, a transmitter 702, a processor 703, and a memory 704.
[0141] Receiver 701 is used to receive instructions and data;
[0142] Transmitter 702 is used to send commands and data;
[0143] Memory 704 is used to store instructions executed by the computer;
[0144] The processor 703 is used to execute computer execution instructions stored in the memory 704 to implement the various steps of the database table structure repair method in the above embodiments. For details, please refer to the relevant descriptions in the foregoing embodiments of the database table structure repair method.
[0145] Optionally, the memory 704 described above can be either standalone or integrated with the processor 703.
[0146] When the memory 704 is set up independently, the electronic device also includes a bus for connecting the memory 704 and the processor 703.
[0147] The implementation principle and technical effects of the electronic device provided in this embodiment can be found in the foregoing embodiments, and will not be repeated here.
[0148] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the method of any of the foregoing embodiments.
[0149] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the method of any of the foregoing embodiments.
[0150] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0151] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0152] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.
[0153] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.
[0154] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.
[0155] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 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 application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0156] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0157] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0158] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for repairing database table structures, characterized in that, include: Obtain connection information between the source and target databases from the database management system; Based on the connection information, the source database and the target database are accessed respectively to obtain the first table structure metadata of the data table in the source database and the second table structure metadata of the data table in the target database. By comparing the metadata of the first table structure with the metadata of the second table structure, the table structure difference information between the source database and the target database is obtained; Based on the table structure difference information, a difference analysis model based on a large language model is used to obtain table structure repair suggestions for the target database; Based on the repair recommendations, the table structure of the target database is repaired.
2. The method according to claim 1, characterized in that, The comparison of the first table structure metadata with the second table structure metadata to obtain the table structure difference information between the source database and the target database includes: The field names, data types, index information, and constraints in the first table structure metadata and the second table structure metadata are compared item by item to obtain the table structure difference information between the source database and the target database.
3. The method according to claim 2, characterized in that, The step of comparing the field names, data types, index information, and constraints in the metadata of the first table structure and the metadata of the second table structure item by item to obtain the table structure difference information between the source database and the target database includes: The matching degree of the field names in the first table structure metadata and the second table structure metadata is checked to detect whether there are any newly added or deleted fields in the target database; A consistency check is performed on the data types in the metadata of the first table structure and the metadata of the second table structure to detect whether the data types of the target database have changed. The index types and positions in the metadata of the first table structure and the metadata of the second table structure are verified to detect whether the indexes of the target database are missing or have been adjusted. Integrity checks are performed on the constraints in the first table structure metadata and the second table structure metadata to detect whether the constraints in the target database are invalid or newly added. Based on the above detection results, the table structure difference information between the source database and the target database is obtained.
4. The method according to any one of claims 1-3, characterized in that, Based on the table structure difference information, the method utilizes a difference analysis model built on a large language model to obtain table structure repair suggestions for the target database, including: Based on the table structure difference information, the difference analysis model is used to analyze the table structure difference information to obtain the difference analysis results; Based on the difference analysis results, the difference analysis model is used to generate table structure repair suggestions, which include repair scripts and / or repair operation steps.
5. The method according to claim 4, characterized in that, The step of generating table structure repair suggestions based on the difference analysis results using the difference analysis model includes: Using the aforementioned difference analysis model, and based on the difference analysis results and the business rule base of the business system to which the target database belongs, the table structure repair suggestion is generated. Alternatively, the method may further include: The repair suggestions are verified based on the business rule base of the business system to which the target database belongs; If the validation fails, the table structure repair suggestions are regenerated based on the difference analysis results and the reasons for the validation failure using the difference analysis model.
6. The method according to any one of claims 1-3, characterized in that, The step of obtaining the connection information between the source database and the target database from the database management system includes: Receive a user-triggered differential repair request for the target database; In response to the request, the user is granted repair permission authentication; If the repair permission authentication is successful, the connection information between the source database and the target database is obtained from the database management system.
7. The method according to any one of claims 1-3, characterized in that, The step of repairing the table structure of the target database according to the repair suggestions includes: Output the repair suggestions; In response to the user's confirmation instruction based on the repair suggestion, a repair script is generated based on the repair suggestion; The repair script is executed on the target database to repair the table structure of the target database.
8. The method according to any one of claims 1-3, characterized in that, The method further includes: After repairing the table structure of the target database, record the details of the repair operation. The details include at least one of the following: operation time, operator, difference details, and repair content.
9. A database table structure repair device, characterized in that, include: The first acquisition module is used to obtain connection information between the source database and the target database from the database management system; The second acquisition module is used to access the source database and the target database respectively based on the connection information, and acquire the first table structure metadata of the data table in the source database, and the second table structure metadata of the data table in the target database. The determination module is used to compare the first table structure metadata with the second table structure metadata to obtain the table structure difference information between the source database and the target database; The third acquisition module is used to obtain table structure repair suggestions for the target database based on the table structure difference information and using a difference analysis model built on a large language model. The processing module is used to repair the table structure of the target database according to the repair suggestions.
10. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 8.
11. 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 to 8.
12. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 8.
Citation Information
Cited By
Table structure consistency checking and repairing method and system for GoldenDB database
CN122086673A