Method and system for unified management and operation across databases

By adopting a unified management and operation method, the complexity of cross-database operations in heterogeneous database systems has been solved, enabling unified description and operation conversion of different databases, improving management efficiency and security, and lowering the technical threshold.

CN120492529BActive Publication Date: 2025-12-12北京科杰科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510940840.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-09
Publication Date
2025-12-12
Estimated Expiration
2045-07-09

AI Technical Summary

Technical Problem

In existing technologies, heterogeneous database systems have significant differences in data types, syntax rules, and operation interfaces, which leads to complex cross-database management and operation, large amount of repetitive development work, high maintenance costs, poor scalability, and lack of unified data structure description and standardized operation conversion mechanism, making it difficult to guarantee the accuracy and consistency of cross-database operations.

Method used

This paper provides a unified management and operation method across databases. It establishes a connection by obtaining database type identifier and access credential information, extracts metadata using a dialect policy processor and maps it to a unified structure description, parses operation instructions and converts them into standard statements, encapsulates transaction units for execution and monitors connection status, and provides visual result feedback.

Benefits of technology

It enables unified management of multiple heterogeneous databases, reduces technology migration costs, improves data management efficiency and system scalability, enhances the security and reliability of cross-database operations, and optimizes the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492529B_ABST
    Figure CN120492529B_ABST
Patent Text Reader

Abstract

The application provides a unified management and operation method and system across databases, relates to the technical field of databases, and comprises the following steps: establishing a connection by acquiring database connection information; extracting a database structure and mapping the database structure into a unified description by using a dialect strategy processor; converting an operation instruction into a standard intermediate statement; converting the intermediate statement into a target database execution statement by using a syntax analysis module and conversion rules; and executing and monitoring in a transaction unit mode. The application realizes unified management and operation of different types of databases, improves the consistency and reliability of database operation, and reduces the development difficulty of cross-database operation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to database technology, in particular to a unified management and operation method and system across databases. BACKGROUND

[0002] With the continuous deepening of enterprise informatization, the coexistence of various heterogeneous database systems has become the norm. There are significant differences between different database systems in data types, syntax rules and operation interfaces, which brings great challenges to database management and operation.

[0003] In the prior art, the way of developing management tools for different databases is usually adopted, or a simple string replacement method is used to process cross-database operations. These solutions have problems such as large repeated development workload, high maintenance cost, poor scalability, etc. At the same time, due to the lack of unified data structure description and standardized operation conversion mechanism, it is difficult to ensure the accuracy and consistency of cross-database operations.

[0004] Traditional solutions cannot effectively handle complex database dialect conversion, and lack reliable transaction control mechanisms, making it difficult to discover and recover in a timely manner once an exception occurs during execution. Therefore, there is an urgent need for a cross-database management and operation method that can uniformly manage heterogeneous databases, automatically perform dialect conversion, and have a perfect transaction control and state monitoring mechanism. SUMMARY

[0005] The embodiments of the present application provide a unified management and operation method and system across databases, which can solve the problems in the prior art.

[0006] In a first aspect, the embodiments of the present application provide a unified management and operation method across databases, comprising:

[0007] Obtaining database type identification, database access address and access credential information, establishing a database connection, and generating connection identification information;

[0008] Obtaining a dialect strategy processor corresponding to the database type identification from a preset dialect strategy registry and instantiating it, calling a metadata extraction method of the dialect strategy processor to extract database structure information from the target database, mapping the database structure information to a unified structure description according to a preset metadata mapping rule, and generating a structure mapping file;

[0009] Parsing the database operation instruction sent by the visual interface and converting it into a standard operation description object, and generating a standardized intermediate operation statement after checking according to the structure mapping file;

[0010] The syntax analysis module of the dialect strategy processor parses the intermediate operation statement to generate a syntax tree node sequence, acquires a conversion rule set matched with the database type identifier from a syntax conversion rule library, and converts the syntax tree node sequence into an execution statement of the target database;

[0011] The execution statement is encapsulated as a transaction unit with a rollback mechanism, submitted to the target database for execution, the connection state corresponding to the connection identifier information is monitored, the execution state information is received, the operation result report is generated according to the execution state information, and returned to the visual interface for display.

[0012] In an optional embodiment,

[0013] The database type identifier, the database access address and the access credential information are acquired, the database connection is established, and the connection identifier information is generated, including:

[0014] The database connection information including the database type identifier, the database access address and the access credential information is acquired, and the database type identifier is determined from a preset database type mapping table;

[0015] The corresponding connection parameter verification rule is acquired according to the database type identifier, the database connection information is verified for legality based on the connection parameter verification rule, when the database connection information verification passes, the idle connection matched with the database type identifier and the database access address is searched from the preset database connection pool, if the matched idle connection is not found, the database connection is established based on the database connection information;

[0016] The established database connection is tested for connectivity, after the test passes, the database connection is added to the database connection pool for unified management, and the connection identifier information containing the database type identifier, the database access address and the connection timestamp is generated;

[0017] The corresponding relationship between the connection identifier information and the database connection is established, the corresponding relationship is stored in the connection mapping table, and the connection monitoring thread is started, the connection monitoring thread periodically detects the connectivity state of the database connection, when the connection exception is detected, the automatic reconnection and the update of the connection mapping table are performed.

[0018] In an optional embodiment,

[0019] The dialect strategy processor corresponding to the database type identifier is acquired from a preset dialect strategy registry and instantiated, the metadata extraction method of the dialect strategy processor is called to extract the database structure information from the target database, the database structure information is mapped into a unified structure description according to a preset metadata mapping rule, and the structure mapping file is generated, including:

[0020] Obtain dialect strategy processor type information corresponding to the database type identifier from a preset dialect strategy registry, the dialect strategy processor type information including a class name and a class path;

[0021] Load a bytecode file of the dialect strategy processor according to the class path, obtain a class object of the dialect strategy processor based on the class name through a reflection mechanism, call a constructor method of the class object to generate a dialect strategy processor instance, the dialect strategy processor instance implementing a predefined metadata extraction interface, and extract database structure information from the target database through the metadata extraction interface;

[0022] Perform a preset sampling rule on field values in the database structure information to obtain numerical distribution characteristics, perform intelligent inference on data types in the database structure information based on the numerical distribution characteristics, output inferred type information and an inference confidence, compare the inference confidence with a preset confidence threshold, and when the inference confidence is greater than the preset confidence threshold, update a data type mapping relationship in the preset metadata mapping rule library using the inferred type information to obtain an optimized metadata mapping rule;

[0023] Input the database structure information into the optimized metadata mapping rule for conversion, and output a structure mapping file of a unified structure description.

[0024] In an optional embodiment,

[0025] Perform a preset sampling rule on field values in the database structure information to obtain numerical distribution characteristics, perform intelligent inference on data types in the database structure information based on the numerical distribution characteristics, output inferred type information and an inference confidence, and the outputting of the inferred type information and the inference confidence includes:

[0026] Divide the field values in the database structure information into a plurality of numerical intervals, randomly extract sample values in each numerical interval, sort the sample values according to numerical size, calculate a difference value sequence of adjacent sample values, and generate numerical distribution characteristics based on the difference value sequence;

[0027] Statistically obtain a decimal place distribution characteristic of numerical data from the sample values, and statistically obtain a length distribution characteristic of character data, combine the decimal place distribution characteristic and the length distribution characteristic to generate a character structure characteristic, and match the character structure characteristic with a preset format template to generate a data pattern characteristic;

[0028] The numerical distribution feature, the character structure feature and the data pattern feature are combined to generate a numerical distribution feature vector, a similarity between the numerical distribution feature vector and a standard feature vector in a preset data type library is calculated, a data type with the highest similarity is selected as inferred type information, a feature matching score is obtained by calculating a matching degree between the numerical distribution feature vector and a feature rule set corresponding to the inferred type information, an inferred confidence is generated based on a comparison result between the feature matching score and a preset matching threshold, and finally the inferred type information and the inferred confidence are output.

[0029] In an alternative embodiment,

[0030] The database operation instruction sent by the visualization interface is parsed and converted into a standard operation description object, and a standardized intermediate operation statement is generated after verification according to a structure mapping file, including:

[0031] The database operation instruction sent by the visualization interface is received, and the database operation instruction is subjected to lexical analysis, and an operation type, a target object and a filtering condition are extracted;

[0032] Based on the operation type, the target object and the filtering condition, a weighted abstract syntax tree is constructed, a priority weight is set for a node in the abstract syntax tree according to an operation complexity, and an operation dependency graph is generated by connecting nodes with a directed edge according to a dependency relationship;

[0033] An execution path is obtained by rearranging an operation sequence based on the priority weight of the node in the operation dependency graph, and the execution path is converted into a standard operation description object;

[0034] Table structure information and field attribute information are obtained from a structure mapping file, a type check is performed on the standard operation description object, when type incompatibility is detected, an optimal type conversion path is identified from a preset conversion template library, and a type conversion code segment is generated according to the type conversion path;

[0035] The standard operation description object is split into a plurality of atomic operation units according to an execution cost, each atomic operation unit is reorganized based on the type conversion code segment, and a standardized intermediate operation statement is generated.

[0036] In an alternative embodiment,

[0037] A syntax analysis module of the dialect strategy processor is called to analyze the intermediate operation statement, a syntax tree node sequence is generated, a conversion rule set matched with the database type identifier is obtained from a syntax conversion rule library, and an execution statement of the target database is converted from the syntax tree node sequence, including:

[0038] The syntax analysis module of the dialect strategy processor is called, and the intermediate operation statement is parsed into an initial syntax unit containing an operation identifier and a parameter identifier;

[0039] a dependency index table is established for the initial syntax units, the dependency index table records upstream call nodes and downstream reference nodes of each syntax unit, a directed dependency graph is constructed based on the dependency index table, reference depth and call breadth of each syntax unit are calculated, and node weight values are generated;

[0040] the initial syntax units are divided into different processing priorities according to the node weight values, syntax unit clustering is performed based on semantic similarity within the same priority, a hierarchical syntax tree containing multiple semantic clusters is constructed, and a syntax tree node sequence is generated;

[0041] a rule template matching the database type identifier is obtained from a syntax conversion rule library, a rule chain table is constructed based on the rule template, an execution order is set for rule items in the rule chain table, the syntax tree node sequence is traversed, execution cost and resource consumption of nodes are calculated, nodes with execution cost exceeding a preset cost threshold are marked as performance sensitive nodes, and the rule chain table is applied to the performance sensitive nodes for structure optimization and syntax conversion;

[0042] Based on the converted performance sensitive nodes, determine the associated processing range, and convert the syntax tree nodes in the associated processing range according to the execution order to generate the execution statement of the target database.

[0043] In an optional embodiment,

[0044] The execution statement is encapsulated as a transaction unit with a rollback mechanism, submitted to the target database for execution, the connection state corresponding to the connection identifier information is monitored, the execution state information is received, the operation result report is generated according to the execution state information, and returned to the visual interface for display, including:

[0045] The data table access identifier, data operation type and associated field information in the execution statement are parsed, the association relationship table between the data tables is established according to the associated field information, and the execution statement with field reference is organized into a transaction unit group based on the association relationship table;

[0046] An operation order chain is constructed for the transaction unit group, a corresponding compensation operation is generated for each operation in the operation order chain according to the data operation type, and the operation order chain and the compensation operation are encapsulated as a transaction unit with a rollback mechanism;

[0047] The execution statement in the transaction unit is subjected to syntax checking and data consistency checking, and after the checking is passed, the database connection is obtained and submitted to the target database for execution;

[0048] Record the identification information of the database connection, collect the network connection state and the database session state corresponding to the connection identification information in real time, obtain the checkpoint information of the last successful execution when an abnormal state is detected, determine the operation range that needs to be rolled back according to the checkpoint information, execute the rollback in the reverse order of the compensation operation, and reinitiate the execution request after completion.

[0049] Record the operation serial number, execution time, affected row number and error information during execution, and arrange them into a structured operation result report, and return the operation result report to the visual interface for display.

[0050] The second aspect of the embodiment of the application provides a unified management and operation system across databases, comprising:

[0051] The first unit is configured to obtain database type identification, database access address and access credential information, establish a database connection, and generate connection identification information;

[0052] The second unit is configured to obtain the dialect strategy processor corresponding to the database type identification from a preset dialect strategy registry and instantiate it, call the metadata extraction method of the dialect strategy processor to extract database structure information from the target database, map the database structure information into a unified structure description according to a preset metadata mapping rule, and generate a structure mapping file;

[0053] The third unit is configured to parse the database operation instruction sent by the visual interface and convert it into a standard operation description object, and generate a standardized intermediate operation statement after checking according to the structure mapping file;

[0054] The fourth unit is configured to call the syntax analysis module of the dialect strategy processor to analyze the intermediate operation statement, generate a syntax tree node sequence, obtain the conversion rule set matched with the database type identification from a syntax conversion rule library, and convert the syntax tree node sequence into an execution statement of the target database;

[0055] The fifth unit is configured to encapsulate the execution statement into a transaction unit with a rollback mechanism, submit it to the target database for execution, monitor the connection state corresponding to the connection identification information, receive the execution state information, generate an operation result report according to the execution state information, and return it to the visual interface for display.

[0056] The third aspect of the embodiment of the application provides an electronic device, comprising:

[0057] A processor;

[0058] A memory for storing processor-executable instructions;

[0059] The processor is configured to call the instructions stored in the memory to execute the method described above.

[0060] In a fourth aspect, the present application provides a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the method described above.

[0061] In the embodiment, the complexity of the management of multiple heterogeneous databases is effectively solved by establishing a unified database operation interface, so that the user can complete cross-database operation without understanding the specific syntax of different databases, greatly improving the data management efficiency. The dialect strategy processing mechanism and the metadata mapping technology are adopted to realize the unified description and operation conversion of the database structures of different types, so that the system can automatically adapt to various database products, enhance the expansibility and compatibility of the system, and reduce the technology migration cost. Through the transaction management and state monitoring mechanism, the safety and reliability of the cross-database operation are guaranteed, and an intuitive visual interface and detailed operation result feedback are provided, which optimizes the user experience, reduces the technical threshold of database management, and is suitable for various complex enterprise-level data environments. BRIEF DESCRIPTION OF DRAWINGS

[0062] Figure 1 FIG. 1 is a flowchart of the cross-database unified management and operation method according to an embodiment of the present application.

[0063] Figure 2 FIG. 4 is a feature matching score and inference confidence relationship bar chart according to an embodiment of the present application.

[0064] Figure 3 FIG. 5 is a system architecture diagram of the cross-database unified management and operation method according to an embodiment of the present application. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme of the embodiments of the present application will be described clearly and completely below in combination with the drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0066] The technical scheme of the present application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in some embodiments.

[0067] Figure 1 FIG. 1 is a flowchart of the cross-database unified management and operation method according to an embodiment of the present application, as shown in the figure, the method comprises: Figure 1

[0068] ​Obtaining database type identification, database access address and access credential information, establishing database connection, and generating connection identification information;

[0069] Obtaining the dialect strategy processor corresponding to the database type identification from the preset dialect strategy registry and instantiating, calling the metadata extraction method of the dialect strategy processor to extract database structure information from the target database, mapping the database structure information into a unified structure description according to the preset metadata mapping rule, and generating a structure mapping file;

[0070] Parsing the database operation instruction sent by the visualization interface and converting it into a standard operation description object, and generating a standardized intermediate operation statement after checking according to the structure mapping file;

[0071] Calling the syntax analysis module of the dialect strategy processor to analyze the intermediate operation statement and generate a syntax tree node sequence, obtaining the conversion rule set matched with the database type identification from the syntax conversion rule library, and converting the syntax tree node sequence into an execution statement of the target database;

[0072] Encapsulating the execution statement into a transaction unit with a rollback mechanism, submitting it to the target database for execution, monitoring the connection state corresponding to the connection identification information, receiving execution state information, generating an operation result report according to the execution state information, and returning it to the visualization interface for display.

[0073] In an optional embodiment,

[0074] Obtaining database type identification, database access address and access credential information, establishing database connection, and generating connection identification information includes:

[0075] Obtaining database connection information including database type identification, database access address and access credential information, and determining the database type identification from the preset database type mapping table;

[0076] According to the database type identification, obtain the corresponding connection parameter verification rule, verify the legality of the database connection information based on the connection parameter verification rule, when the database connection information is verified, find the idle connection matched with the database type identification and database access address from the preset database connection pool, if no matched idle connection is found, establish the database connection based on the database connection information;

[0077] Testing the established database connection for connectivity, and after the test is passed, adding the database connection into the database connection pool for unified management, and generating connection identification information containing database type identification, database access address and connection timestamp;

[0078] The connection identification information and the database connection are corresponded, the corresponding relation is stored in the connection mapping table, and the connection monitoring thread is started. The connection monitoring thread periodically detects the connection state of the database connection, and automatically reconnects and updates the connection mapping table when detecting connection exception.

[0079] Exemplarily, the database connection information acquisition process includes receiving user input or reading database type identification, database access address and access credential information from a configuration file. The database type identification can be a "MySQL", "Oracle", "SQLServer", "PostgreSQL" or the like string, the database access address includes a host address and a port number, such as "192.168.1.100:3306", and the access credential information includes a username and a password, such as a username "dbadmin" and a password "pass123". A preset database type mapping table is maintained for converting the database type identification provided by the user into an internal standardized identification. For example, different forms of input such as "mysql", "MySQL" and "MYSQL" are uniformly mapped to "MYSQL". The mapping table is stored in the form of key-value pairs, the key is the various forms of database type names that the user may input, and the value is the standardized identification used internally.

[0080] The connection parameter verification rules set different verification rules for different types of databases. For a MySQL database, the host address must be a valid IP address or domain name, the port number must be an integer between 1024 and 65535, and the default is 3306; the username length must not exceed 32 characters and cannot contain special characters; and the password length must not be less than 6 characters. For an Oracle database, the host address must be a valid IP address or domain name, the port number must be an integer between 1024 and 65535, and the default is 1521; the username must start with a letter and can only contain letters, numbers and underscores, and the length must not exceed 30 characters; and the password length must not be less than 8 characters and must contain at least one uppercase letter, one lowercase letter and one number. After receiving the database connection information, the corresponding verification rule is selected according to the database type identification for verification. If the verification fails, specific error information such as "port number exceeds the valid range" or "password does not meet the complexity requirements" will be returned.

[0081] The management of the database connection pool adopts a double-layer hash table structure. The first layer hash table takes the database type identifier as the key and the second layer hash table as the value. The second layer hash table takes the database access address as the key and the connection object list as the value. When a new database connection needs to be established, it is first checked whether there is a matching idle connection in the connection pool. According to the database type identifier, the corresponding second layer hash table is found in the first layer hash table, and then the connection object list is found in the second layer hash table according to the database access address. If the connection object list is found and the list is not empty, a connection object will be taken out from the list for reuse; if the list is empty or no matching list is found, a new database connection will be created. For example, when a user requests to connect to a database of type "MYSQL" and address "192.168.1.100:3306", the first layer hash table item with the key "MYSQL" is first found, and then the second layer hash table item with the key "192.168.1.100:3306" is found. If the connection object list is not empty, a connection object is taken out for reuse; otherwise, a new connection is created.

[0082] The establishment process of the database connection adopts different connection methods according to different database types. For MySQL databases, the JDBC driver is used, the connection URL is constructed as "jdbc:mysql: / / host address:port number / database name", and connection attributes such as automatic commit, connection timeout, character set, etc. are set. For Oracle databases, the connection URL is constructed as "jdbc:oracle:thin:@host address:port number:service name", and Oracle-specific connection attributes such as NLS_LANG, NLS_DATE_FORMAT, etc. are set. When establishing the connection, possible exceptions such as connection timeout, authentication failure, network error, etc. are captured and handled, and corresponding error handling and retry logic are performed according to the exception type. For example, when a connection timeout exception is encountered, error information is recorded in the log, and after waiting for a period of time, it is retried; when an authentication failure exception is encountered, the provided credential information is checked and the user is asked to re-enter.

[0083] The connectivity test verifies whether the database connection is working properly by executing a simple SQL query. For a MySQL database, the "SELECT 1" query is executed; for an Oracle database, the "SELECT 1 FROM DUAL" query is executed; and for a SQLServer database, the "SELECT 1" query is executed. The query timeout is set to 5 seconds, and if the query can be successfully executed and the result is obtained within the timeout, the connectivity test is considered passed; otherwise, the test is considered failed. For the connection that fails the test, the connection is closed and the related resources are released, and then it is decided whether to retry establishing the connection according to the configuration. For example, when trying to connect to a MySQL database and execute the "SELECT 1" query, if the result "1" is successfully returned within 5 seconds, the connectivity test is passed; if the result is not returned or an error is returned within 5 seconds, the test fails.

[0084] The generation of the connection identification information adopts a specific format, including database type identification, database access address, and connection timestamp, and the parts are separated by underscores. For example, for a database connection with a type of "MYSQL", an address of "192.168.1.100:3306", and a connection time of "2023-06-20 15:30:45", the generated connection identification is "MYSQL_192.168.1.100:3306_20230620153045". The correspondence between the connection identification information and the database connection is stored in a connection mapping table, which adopts a hash table structure, taking the connection identification as the key and the database connection object as the value. An interface is provided to obtain the database connection object according to the connection identification, so that the upper-layer application does not need to care about the specific database connection details, and only needs to perform database operations through the connection identification.

[0085] The connection monitoring thread is responsible for periodically detecting the connectivity state of the database connection, with a default detection period of 60 seconds. The monitoring thread iterates through all connections in the connection mapping table and performs a connectivity test for each connection. If the test fails, the monitoring thread attempts to close the current connection and re-establish a database connection based on the information in the connection identifier. If the reconnection is successful, the monitoring thread updates the corresponding entry in the connection mapping table; if the reconnection fails, the monitoring thread records error information in the log and attempts to reconnect again at the next detection period. The monitoring thread is also responsible for detecting the idle time of the connection. If the idle time of a connection exceeds the pre-set threshold (default is 30 minutes), the monitoring thread will mark the connection as recyclable. Recycling operations will be performed periodically to close and remove connections in recyclable state to release system resources. For example, when the monitoring thread detects that the connection "MYSQL_192.168.1.100:3306_20230620153045" cannot be connected, it will attempt to close the connection and re-establish a connection using the same database type identifier and access address, generating a new connection identifier such as "MYSQL_192.168.1.100:3306_20230620154545", and then updating the connection mapping table.

[0086] In this embodiment, through the unified connection management mechanism, non-discriminatory access to different types of databases is achieved, reducing the coupling degree of application programs and specific database types, improving the scalability and maintainability of the system; through the connection pool technology, the database connection resources are effectively reused, reducing the overhead of frequent connection establishment and closure, improving the system performance; through the connection parameter verification mechanism, illegal connection requests are detected and prevented in advance, enhancing the security and stability of the system; through the connection monitoring and automatic reconnection mechanism, connection exceptions are detected and repaired in a timely manner, improving the reliability and fault tolerance of the system; through the connection identifier and mapping table, the unified management and efficient access of connection resources are achieved, simplifying the development complexity of the upper layer application. These technical effects collectively promote efficient, stable and secure data access and management in a cross-database environment.

[0087] In an alternative embodiment,

[0088] The dialect strategy processor corresponding to the database type identifier is obtained from the pre-set dialect strategy registry and instantiated, the metadata extraction method of the dialect strategy processor is called to extract database structure information from the target database, the database structure information is mapped to a unified structure description according to the pre-set metadata mapping rule, and a structure mapping file is generated, including:

[0089] The dialect strategy processor type information corresponding to the database type identifier is obtained from the pre-set dialect strategy registry; the dialect strategy processor type information includes class name and class path;

[0090] According to the class path loading dialect strategy processor bytecode file, the class object of the dialect strategy processor is obtained based on the class name through a reflection mechanism, the construction method of the class object is called to generate a dialect strategy processor instance, the dialect strategy processor instance implements a predefined metadata extraction interface, and the database structure information is extracted from the target database through the metadata extraction interface;

[0091] The preset sampling rule is performed on the field value in the database structure information to obtain a numerical distribution feature, the intelligent inference is performed on the data type in the database structure information based on the numerical distribution feature, the inferred type information and the inferred confidence are output, the inferred confidence is compared with a preset confidence threshold, when the inferred confidence is greater than the preset confidence threshold, the inferred type information is used to update the data type mapping relationship in the preset metadata mapping rule library, and the optimized metadata mapping rule is obtained;

[0092] The database structure information is input into the optimized metadata mapping rule for conversion, and the structure mapping file of the unified structure description is output.

[0093] The dialect strategy registry is a configuration mapping structure, and is used to store dialect strategy processor information corresponding to different database types. The registry adopts a key-value pair form, the key is a database type identifier, such as "MYSQL", "ORACLE", "SQLSERVER" and the like, and the value is corresponding dialect strategy processor type information, including a class name and a class path. For example, the dialect strategy processor type information corresponding to the MySQL database may be a class name "MySQLDialectProcessor" and a class path "com.database.dialect.mysql.MySQLDialectProcessor"; and the dialect strategy processor type information corresponding to the Oracle database may be a class name "OracleDialectProcessor" and a class path "com.database.dialect.oracle.OracleDialectProcessor". The dialect strategy registry can be initialized through a configuration file, or can be dynamically registered through a program. When a specific type of database needs to be processed, the corresponding dialect strategy processor type information is found from the dialect strategy registry through the database type identifier.

[0094] The instantiation process of dialect strategy processor is implemented using Java reflection mechanism. First, the corresponding bytecode file is loaded using class loader according to the class path obtained from dialect strategy registry. For example, for MySQL database, the bytecode file corresponding to "com.database.dialect.mysql.MySQLDialectProcessor" is loaded. After loading, the class object of dialect strategy processor is obtained through Class.forName() method, and then the newInstance() method of class object or the newInstance() method of Constructor object is called to create processor instance. If the constructor method of dialect strategy processor needs parameters, the corresponding parameters will be read from configuration and passed in. For example, some processors may need database connection information as a construction parameter, and the database connection established in the previous step will be passed into the constructor method. The exceptions that may occur during instantiation include ClassNotFoundException (class not found), InstantiationException (instantiation exception), and IllegalAccessException (illegal access exception), etc. These exceptions will be captured and corresponding error handling will be performed, such as logging, trying alternative processor or reporting error to user.

[0095] The dialect strategy processor implements a predefined metadata extraction interface, which defines standard methods for extracting structural information from different types of databases. The metadata extraction interface includes methods such as extractDatabases() (extracting database list), extractTables(String database) (extracting table list of specified database), extractColumns(String database, String table) (extracting column information of specified table), extractPrimaryKeys(String database, String table) (extracting primary key information), extractForeignKeys(String database, String table) (extracting foreign key information), etc. The dialect strategy processor of each database type provides metadata extraction logic for specific databases by implementing these interface methods. For example, when implementing the extractTables method, the MySQL dialect strategy processor may execute the SQL query "SHOW TABLES FROM database_name"; while the Oracle dialect strategy processor may query the system table "ALL_TABLES" and filter the OWNER condition when implementing the same method.

[0096] The extraction process of database structure information is performed by the instantiated dialect strategy processor. The processor first acquires the list of all databases or schemas in the target database by invoking the extractDatabases() method. For MySQL databases, this can be achieved by executing the "SHOW DATABASES" query; for Oracle databases, this can be achieved by querying the "ALL_USERS" system table. After obtaining the database list, the processor iterates through each database and invokes the extractTables() method to extract table information. The table information includes table name, table type (e.g., normal table, view, temporary table, etc.), table comment, etc. The processor continues to iterate through each table and invokes the extractColumns() method to extract column information, including column name, data type, length / precision, whether NULL is allowed, default value, column comment, etc.; invokes the extractPrimaryKeys() method to extract primary key information, including primary key name, columns that make up the primary key; invokes the extractForeignKeys() method to extract foreign key information, including foreign key name, referenced table and column, constraint behavior, etc. In addition, the processor can also extract index information, trigger information, stored procedure information, etc., depending on system requirements and the functions supported by the database type.

[0097] After the extraction of database structure information is complete, the field values therein are subjected to pre-defined sampling rules to obtain the value distribution characteristics. The sampling rules define how to select sample data from the database for analysis. For example, for large tables, a random sampling strategy can be used to randomly select a certain proportion (e.g., 10%) or a fixed number (e.g., 1000) of records from the table for analysis; for small tables, all data can be analyzed. The sampled data is used to analyze the value distribution characteristics of each field, including data type, value range, unique value proportion, null value proportion, numerical value distribution (e.g., mean, median, standard deviation, etc.), text length distribution, date and time distribution, etc. For example, for a field defined as VARCHAR type, if the sampled data shows that 99% of the values are in numerical form and all within a specific range, it can be inferred that the field should actually use INTEGER or DECIMAL type.

[0098] Based on the numerical distribution characteristics, intelligent inference is performed on the data types in the database structure information, and the inferred type information and inferred confidence are output. The intelligent inference algorithm considers multiple factors, including the current definition of the data type of the field, the field name (such as containing keywords such as "id", "date", "amount", etc.), the pattern of the field value (such as all numbers, date format, email format, etc.), the statistical characteristics of the field value, etc. Calculate the confidence score for each possible data type, and select the type with the highest confidence as the inference result. For example, for a field named "create_time" defined as VARCHAR(20), if its value mostly conforms to the "YYYY-MM-DD HH:MM:SS" format, it is possible to infer that its actual type should be DATETIME or TIMESTAMP, and give a higher confidence (such as 0.95). The inference result includes the inferred type information (such as data type, length / precision, whether nullable, etc.) and the inferred confidence (a value between 0 and 1, indicating the credibility of the inference).

[0099] The inferred confidence is compared with the pre-set confidence threshold, and when the inferred confidence is greater than the pre-set confidence threshold, the inferred type information is used to update the data type mapping relationship in the pre-set metadata mapping rule library. The pre-set confidence threshold is usually set to a high value (such as 0.9) to ensure that only highly reliable inference results are adopted. The metadata mapping rule library is a set of rules maintained by the system, used to map various database-specific data types to a unified standard type. For example, the INT type of MySQL, the NUMBER(10) type of Oracle, and the INT type of SQLServer may all be mapped to the INTEGER type in the unified standard. When the result of intelligent inference is adopted, the corresponding mapping relationship in the metadata mapping rule library will be updated. For example, if it is inferred that a certain TINYTEXT type field in MySQL actually stores date and time data, and the confidence exceeds the threshold, a rule may be added to map TINYTEXT to DATETIME for this specific scenario. These optimized mapping rules will be applied to subsequent structure mapping processes.

[0100] The database structure information is input into the optimized metadata mapping rule for conversion, and a structure mapping file of a unified structure description is output. The conversion process follows a predefined mapping rule to convert various database-specific structure characteristics into a unified standard format. The conversion involves multiple aspects: data type conversion (such as converting MySQL's TINYINT to the standard INTEGER type), length precision conversion (such as adjusting the precision representation of numerical types), constraint conversion (such as handling differences in foreign key implementation in different databases), naming specification conversion (such as unified case handling), etc. The converted unified structure description is usually stored in JSON or XML format, containing database, table, column, primary key, foreign key, index, and other levels of structure information, as well as detailed attributes of each structure element. For example, the description of a table may include table name, table type, storage engine, character set, comment, etc. The description of a column may include column name, data type, length / precision, whether it can be empty, default value, comment, etc. The generated structure mapping file can be used for subsequent database operations, such as generating cross-database query statements, performing data migration, and comparing database structures.

[0101] In this embodiment, through the dialect strategy processor mechanism, a unified interface for extracting metadata of different types of databases is realized, and the differences in metadata acquisition of various databases are shielded, simplifying the complexity of cross-database operations; through the reflection mechanism, the dialect strategy processor is dynamically loaded and instantiated, improving the scalability of the system, and supporting the addition of new database types without modifying the core code; through data sampling and intelligent type inference, type mismatch problems in database design can be found, data type mapping rules can be optimized, and the accuracy and efficiency of data processing can be improved; by generating a structure mapping file in a unified format, a structure description independent of the specific database type is provided for the upper layer application, enabling the application program to process data from different databases in a unified manner, thereby realizing true cross-database unified management and operation.

[0102] In an optional embodiment,

[0103] A preset sampling rule is performed on the field values in the database structure information to obtain a numerical distribution feature, and an intelligent inference is performed on the data types in the database structure information based on the numerical distribution feature, to output inferred type information and an inferred confidence level, including:

[0104] The field values in the database structure information are divided into a plurality of numerical intervals, sample values are randomly extracted in each numerical interval, the sample values are sorted by numerical size, and a difference sequence of adjacent sample values is calculated, and a numerical distribution feature is generated based on the difference sequence;

[0105] The decimal place distribution feature is obtained by counting the decimal places of the numerical value type data of the sample values, and the length distribution feature is obtained by counting the character lengths of the character type data. The character structure feature is generated by combining the decimal place distribution feature and the length distribution feature; the character structure feature is matched with a preset format template to generate a data mode feature;

[0106] The numerical distribution feature vector is generated by combining the numerical distribution feature, the character structure feature, and the data mode feature. The similarity between the numerical distribution feature vector and a standard feature vector in a preset data type library is calculated. The data type with the highest similarity is selected as the inferred type information. The feature matching score is obtained by calculating the matching degree between the numerical distribution feature vector and the feature rule set corresponding to the inferred type information. The inferred confidence is generated based on the comparison result between the feature matching score and a preset matching threshold. Finally, the inferred type information and the inferred confidence are output.

[0107] In the present embodiment, the process of dividing the field values in the database structure information into multiple numerical intervals adopts an adaptive interval division algorithm. First, the minimum and maximum values of the field are obtained, the numerical range is calculated, and then the number of intervals is determined according to the number and distribution characteristics of the field values. For numerical fields such as integer or floating point, they are usually divided into equal-width intervals; for fields with uneven distribution, quantile method is used to divide the intervals to ensure that the number of samples in each interval is relatively balanced. For example, for an integer field with a value range of 0 to 10000, if the sample distribution is relatively uniform, it can be divided into 10 equal-width intervals, each with a width of 1000; if the samples are mainly concentrated in the range of 0 to 100, a non-linear division such as 0-10, 10-50, 50-100, 100-500, 500-1000, 1000-10000, etc. can be used. After the interval division is completed, sample values are randomly extracted in each interval. The number of samples is determined in proportion to the number of values in the interval to ensure that the total number of samples does not exceed the preset upper limit (such as 1000 samples).

[0108] The process of calculating the difference sequence of adjacent sample values after sorting the sample values by numerical size provides the fine-grained characteristics of data distribution. The extracted sample values are sorted in ascending order, and then the difference between adjacent sample values is calculated to form a difference sequence. The difference sequence reflects the density and distribution pattern of the data. By analyzing the difference sequence, it can be identified whether the data is uniformly distributed, clustered, or presents other patterns. For example, for an auto-increment primary key, the difference sequence may mainly contain 1 or a small fixed value; for a timestamp field, the difference sequence may reflect the time pattern of data entry; for randomly distributed numerical values, the difference sequence may not have obvious rules. Calculate the statistical characteristics of the difference sequence, including the average difference, difference standard deviation, ratio of maximum difference to minimum difference, etc., which together constitute part of the numerical distribution characteristics. For example, a small standard deviation of the difference sequence may indicate that the data is growing at a fixed step, such as an auto-increment ID; periodic difference distribution may indicate that the data is related to time, such as the number of records per day or week.

[0109] The process of obtaining the decimal place distribution characteristics by counting the decimal places of sample values for numerical data analyzes fields that may be floating-point numbers. Check if each sample value contains a decimal part and count the number of decimal places. Calculate the proportion of samples containing decimals, the average number of decimal places, the maximum number of decimal places, etc. to form the decimal place distribution characteristics. For example, if about 95% of the values of a field contain two decimal places, this field is likely to use the DECIMAL(x, 2) type; if the field values almost never contain decimals, it may be appropriate to use an integer type. At the same time, it is also analyzed whether the decimal places have a fixed pattern, such as always two decimal places (possibly currency amounts) or scientific notation (possibly precise scientific data).

[0110] The process of obtaining length distribution characteristics by counting the character length of character type data is suitable for string type fields. Calculate the character length of each sample value to generate length distribution characteristics, including average length, maximum length, minimum length, length standard deviation, etc. These characteristics help determine the best storage type and length of the string field. For example, if the character length distribution is mainly concentrated between 50 and 200, it may be appropriate to use the VARCHAR(255) type; if the length is fixed, such as 36 characters, it may be appropriate to use the CHAR(36) type (possibly UUID); if the length often exceeds 255 characters, it may need to use the TEXT type. In addition, it is also analyzed whether the characters are all digits, letters, special characters, or mixed characters, which helps determine the specific use of the field and the most suitable data type.

[0111] The process of combining the decimal distribution features and the length distribution features to generate the character structure features creates a structured description of the field content. The features obtained from the previous analysis are combined to form a multi-dimensional feature vector that describes the structural pattern of the field value. For numerical data, the features include the bit distribution of the integer part and the decimal part; for character data, the features include the character length distribution and the character type distribution (e.g., the proportion of letters, numbers, and special characters). For example, a field that stores phone numbers may exhibit features such as all-numeric characters and a length distribution concentrated between 10 and 15. A field that stores email addresses may exhibit features such as the presence of the "@" symbol, a mix of letters and numbers, and an average length between 20 and 30. The character structure features provide a basis for subsequent format template matching.

[0112] The process of matching the character structure features with pre-defined format templates to generate data pattern features identifies common patterns in the field values. A set of pre-defined format templates is maintained, covering common data type patterns such as date and time ("YYYY-MM-DD", "YYYY / MM / DD", etc.), email addresses (containing "@" and domain suffixes), phone numbers (specific combinations of numbers and separators), IP addresses (four groups of 0-255 numbers separated by dots), UUIDs (specific format of 16-bit hexadecimal strings), etc. The field values are attempted to be matched with these templates, and the proportion of samples that match successfully is calculated. If the matching proportion exceeds a certain threshold (e.g., 90%), the field is considered to conform to the corresponding data pattern. For example, if the values of a field mostly conform to the "YYYY-MM-DD" format, it is identified as a date type; if they conform to the "name@domain.com" format, it is identified as an email type. The identification results form the data pattern features, including the pattern type and the matching degree.

[0113] The process of combining the numerical distribution features, the character structure features, and the data pattern features to generate the numerical distribution feature vector creates a comprehensive representation of the field characteristics. The various features obtained from the previous analysis are integrated into a multi-dimensional feature vector, with each dimension corresponding to a characteristic. The feature vector contains information such as basic statistical features (e.g., mean, standard deviation, maximum, minimum, etc.), distribution features (e.g., difference sequence features, distribution skewness, etc.), structure features (e.g., decimal place features, character length features, etc.), and pattern features (e.g., format template matching results). This comprehensive feature vector fully describes the data characteristics of the field and provides a basis for subsequent type inference. For example, a field that represents age may have a feature vector with a mean of about 30, a standard deviation of about 15, a minimum value of 0, a maximum value of 120, almost all integers, no decimal places, and no specific format template.

[0114] The process of calculating the similarity between the numerical distribution feature vector and the standard feature vector in the preset data type library is the core link of type inference. The preset data type library contains standard feature vectors of various common data types, such as integer, floating point, string, date, time, and Boolean. Each type can also contain multiple subtypes (such as TINYINT, SMALLINT, INTEGER, etc.). The similarity between the sample feature vector and each standard feature vector is calculated using cosine similarity or Euclidean distance. The similarity calculation considers the weight of each dimension feature, and different features have different importance for type judgment. For example, for judging whether it is a date type, the weight of the format template matching result is higher; for judging the numerical precision, the weight of the decimal place feature is higher. The data type with the highest similarity is selected as the inferred type information, and the similarity value is recorded as the preliminary confidence.

[0115] The process of calculating the matching degree between the numerical distribution feature vector and the feature rule set corresponding to the inferred type information to obtain the feature matching score further verifies the inference result. Each data type is associated with a set of feature rules in addition to the standard feature vector, which is used to verify the key features of a specific type. For example, the rules for date type can include: the value must conform to the date format, the month value must be between 1-12, the date value must be within the valid range, etc. Check if the sample value meets these rules, calculate the proportion of samples that meet the rules, and get the feature matching score. This step can filter out some cases that are similar in form but do not meet the semantics of a specific type. For example, a string composed entirely of numbers may be similar in form to an integer, but if it is actually a product code or phone number, it should not be inferred as an integer.

[0116] The process of generating inference confidence based on the comparison result of feature matching score and preset matching threshold determines the final inference confidence. Compare the feature matching score with the preset matching threshold. If the score is significantly higher than the threshold, it indicates that the inference result is highly reliable; if the score is close to or slightly higher than the threshold, it indicates that the inference result may have uncertainty; if the score is lower than the threshold, it indicates that the inference result may not be accurate. Based on the comparison result, generate the final inference confidence, usually represented as a value between 0 and 1. For example, if the feature matching score is 0.95 and the preset matching threshold is 0.8, the inference confidence may be 0.9; if the feature matching score is 0.82, close to the threshold, the inference confidence may be 0.7. Finally, output the inferred type information and the inference confidence for subsequent processing.

[0117] In the prior art, database type inference usually relies on simple rule matching or pattern recognition, lacking in-depth analysis of the actual distribution characteristics of data, resulting in low accuracy of inference. For example, traditional methods may only make inferences based on field names or simple value checks, such as inferring a field name containing "date" as a date type or inferring a numerical value containing a decimal point as a floating-point type. Such methods are prone to misjudgment when faced with complex data, cannot adapt to type differences between different databases, and cannot discover type mismatch problems in database design. In the present embodiment, through multi-dimensional data sampling and feature analysis, combined with matching verification of preset data type templates and rule sets, more accurate intelligent data type inference is achieved. Specifically, the present application performs multi-interval sampling on field values, analyzes numerical distribution and structural characteristics, identifies data patterns, generates a comprehensive feature vector, and obtains a high-confidence type inference result through similarity calculation with a standard feature vector and matching verification of a feature rule set. This inference method based on actual data characteristics greatly improves the accuracy of type judgment, can adapt to type differences between different databases, and can discover and correct type mismatch problems.

[0118] Figure 2 For the feature matching score and inference confidence relationship bar chart of the embodiment of the present application, as shown in Figure 2 , it presents how the feature matching score affects the final inference confidence in the present technical solution. The feature matching score is divided into five intervals (0.5-0.6, 0.6-0.7, 0.7-0.8, 0.8-0.9, 0.9-1.0), and the average inference confidence corresponding to each interval is counted. As can be clearly seen from the figure, with the increase of the feature matching score, the inference confidence presents a significant growth trend. When the feature matching score is in the 0.5-0.6 interval, the average inference confidence is only 0.62; when the feature matching score reaches the 0.9-1.0 interval, the average inference confidence is as high as 0.97, almost close to complete confidence. It is particularly noteworthy that the confidence threshold 0.8 (red dashed line) is marked in the figure, when the feature matching score exceeds the 0.7-0.8 interval, the inference confidence begins to exceed this threshold, indicating that the inference result has high reliability, providing more accurate type judgment basis for the data processing system, especially when processing data with fuzzy boundaries or multiple types, it can provide more valuable decision support.

[0119] In an alternative embodiment,

[0120] The database operation instruction sent by the analysis visualization interface is parsed and converted into a standard operation description object, and a standardized intermediate operation statement is generated after verification according to the structure mapping file, including:

[0121] receive the database operation instruction sent by the visualization interface, perform lexical analysis on the database operation instruction, extract an operation type, a target object, and a filter condition;

[0122] construct a weighted abstract syntax tree based on the operation type, the target object, and the filter condition, set a priority weight for a node in the abstract syntax tree according to an operation complexity, and generate an operation dependency graph by connecting nodes having a dependency relationship through a directed edge;

[0123] rearrange an operation sequence based on the priority weight of the node in the operation dependency graph to obtain an execution path, and convert the execution path into a standard operation description object;

[0124] obtain table structure information and field attribute information from a structure mapping file, perform type checking on the standard operation description object, identify an optimal type conversion path from a preset conversion template library when type incompatibility is detected, and generate a type conversion code segment according to the type conversion path;

[0125] split the standard operation description object into a plurality of atomic operation units according to an execution cost, recombine each atomic operation unit based on the type conversion code segment, and generate a standardized intermediate operation statement.

[0126] Exemplarily, the process of receiving the database operation instruction sent by the visualization interface is implemented through a preset communication interface. A dedicated instruction receiving module is set to listen to operation requests from the visualization interface. These operation requests can be encapsulated in a JSON or XML format and contain an operation type (such as query, insertion, update, or deletion), a target object (such as a database name, a table name, or a field name), a filter condition (such as the content of a WHERE clause), a sorting rule, and paging information. For example, a JSON format instruction of a query operation can be: {"operationType":"query", "targetObject":"user_info", "fields":["user_id", "user_name", "age"], "conditions":{"age":{"gt":18}}, "orderBy":{"user_id":"asc"}, "limit":10}. After receiving the operation instruction, the integrity and legality of the instruction format are first verified to ensure that the necessary operation information is included, and then the instruction is passed to a lexical analysis module for further processing.

[0127] The process of lexical analysis of database operation instructions, extracting operation type, target object and filter condition, is implemented by a custom lexical analyzer. The lexical analyzer decomposes the operation instruction into a sequence of tokens, identifying keywords, identifiers, operators, constants, etc. For JSON or XML format instructions, first parse them into internal data structures, and then extract the key information. The operation type is usually obtained directly from the operation type field in the instruction; the target object is obtained from the target object field, which may include multiple levels of structure such as database name, schema name, table name, etc.; the filter condition is obtained from the condition field, which needs to parse various comparison operators (such as equal, greater than, less than, LIKE, etc.) and logical operators (such as AND, OR, NOT, etc.). For example, after lexical analysis of the above JSON instruction, the extracted operation type is "query", the target object is the "user_info" table, and the filter condition is "age > 18". The results of lexical analysis are saved in a structured form, providing input for subsequent syntax analysis.

[0128] The process of building a weighted abstract syntax tree based on operation type, target object and filter condition is to convert linear instructions into tree structure representation. Using a bottom-up construction method, first construct leaf nodes, and then gradually construct upper layer nodes. Leaf nodes usually represent basic operation elements, such as field names, constant values, etc.; intermediate nodes represent operators or composite conditions; the root node represents the entire operation. Set priority weights for each node in the abstract syntax tree, and the weight value is determined according to the complexity of the operation. Operation complexity considers multiple factors: the basic complexity of the operation type (such as the complexity of the delete operation is higher than that of the query operation), the number of tables and fields involved, the complexity of the condition expression, the amount of data that may be affected, etc. For example, a simple field query node may set a low weight value such as 1; a node involving multi-table join may set a high weight value such as 5; a delete operation node that may affect a large amount of data may set a very high weight value such as 10. Nodes with dependency relationships are connected through directed edges to generate an operation dependency graph. Dependency relationships represent the order constraints of operation execution, such as a query operation on a certain table may depend on the query result of another table.

[0129] The process of rearranging the operation sequence based on the priority weight of nodes in the operation dependency graph to obtain the execution path is to determine the optimal operation order. The operation dependency graph is analyzed using optimization algorithms such as topological sorting combined with priority queues. The sorting process takes into account the priority weight and dependency relationship of the nodes, ensuring that the dependency relationship is satisfied while preferentially executing operations with lower weights. The rearranged operation sequence forms the execution path, indicating the order in which each operation step will be executed. The execution path is converted into a standard operation description object, which is a unified internal representation containing information such as operation type, target object, field list, condition expression, and execution order, independent of the specific database type. The standard operation description object uses a structured format, facilitating subsequent processing and conversion.

[0130] The process of obtaining table structure information and field attribute information from the structure mapping file is to prepare data for subsequent type checking. According to the target object information in the standard operation description object, the corresponding table structure information is found from the previously generated structure mapping file, including the table's field list, field data type, length / precision, constraint conditions, etc. Type checking is performed on the standard operation description object to verify whether the field types involved in the operation are compatible with the expected operation. Type checking mainly checks the following aspects: whether the comparison operations in the condition expression are type-compatible (such as not being able to directly compare strings and numbers); whether the values in the insert or update operation are compatible with the target field type; whether the types of sorting or grouping fields support the corresponding operations, etc. When type incompatibility is detected, the optimal type conversion path is identified from the preset conversion template library. The conversion template library contains conversion rules between various types, such as string to number, date to string, etc. Considering the feasibility of conversion, precision loss, and performance impact, the optimal conversion path is selected. For example, converting the string "123" to the integer 123 may be safe, but converting "abc" to an integer may result in an error. According to the selected type conversion path, type conversion code segments are generated, which will be embedded in the final operation statement to ensure type compatibility.

[0131] The process of splitting the standard operation description object into multiple atomic operation units according to the execution cost is to decompose complex operations into basic steps. The complexity of the standard operation description object is analyzed, and factors such as operation type, number of tables and fields involved, and condition complexity are considered to split it into multiple atomic operation units. Atomic operation units are indivisible basic operation steps, such as single-table queries, single-field updates, etc. The principle of splitting is to balance execution efficiency and resource consumption, and to avoid overly complex single operations leading to low execution efficiency. Based on the type conversion code segment generated in the previous step, the atomic operation units are reorganized to ensure that type conversion is performed at the appropriate location, and standardized intermediate operation statements are generated. The intermediate operation statements use a unified format and are independent of the specific database type, and can be converted into SQL statements or API calls for specific databases by subsequent translation modules.

[0132] In this embodiment, through lexical analysis and abstract syntax tree construction, accurate understanding of the semantics of operation instructions is achieved, avoiding errors that may be caused by simple string replacement; through the operation dependency graph with weights and priority sorting, the operation execution order is optimized, and the execution efficiency of complex operations is improved; through type checking and intelligent conversion, the type compatibility problem between different databases is solved, and the reliability of cross-database operations is enhanced; through atomic operation splitting and reorganization, the execution efficiency and resource consumption are balanced, and the operation requirements of databases of different sizes and complexities are adapted. These technical effects collectively promote the unified processing and optimized execution of operation instructions in a cross-database environment, simplify application development and database management, and improve the overall performance and user experience of the system.

[0133] In an alternative embodiment,

[0134] The syntax analysis module of the dialect strategy processor parses the intermediate operation statement to generate a syntax tree node sequence, obtains a set of conversion rules matched with the database type identifier from the syntax conversion rule library, and converts the syntax tree node sequence into an execution statement of the target database, including:

[0135] The syntax analysis module of the dialect strategy processor parses the intermediate operation statement into initial syntax units containing operation identifiers and parameter identifiers;

[0136] A dependency index table is established for the initial syntax units, which records the upstream calling nodes and downstream referencing nodes of each syntax unit. A directed dependency graph is constructed based on the dependency index table, the reference depth and calling breadth of each syntax unit are calculated, and a node weight value is generated;

[0137] The initial syntax units are divided into different processing priorities according to the node weight values, and syntax unit clustering is performed based on semantic similarity within the same priority to construct a hierarchical syntax tree containing multiple semantic clusters, and a syntax tree node sequence is generated.

[0138] obtain a rule template matched with the database type identifier from a syntax conversion rule library, construct a rule chain table based on the rule template, set an execution order for rule items in the rule chain table, traverse the syntax tree node sequence, calculate an execution cost and resource consumption of the nodes, mark nodes with an execution cost exceeding a preset cost threshold as performance sensitive nodes, and apply the rule chain table to the performance sensitive nodes for structure optimization and syntax conversion;

[0139] determine an associated processing range based on the converted performance sensitive nodes, and sequentially perform syntax structure conversion on syntax tree nodes in the associated processing range according to the execution order to generate an execution statement of the target database.

[0140] The process of calling the syntax analysis module of the dialect strategy processor to parse the intermediate operation statement into initial syntax units containing operation identifiers and parameter identifiers is the starting point of syntax conversion. The syntax analysis module receives the standardized intermediate operation statement generated in the previous step, performs lexical analysis and syntax analysis on it, and identifies operation identifiers (such as SELECT, INSERT, UPDATE, DELETE, etc.) and parameter identifiers (such as table names, field names, condition expressions, etc.). For example, for the intermediate operation statement "QUERY:TABLE(user_info)|FIELDS(user_id, user_name, age)|WHERE(age>18)|ORDER_BY(user_id, ASC)|LIMIT(10)", the syntax analysis module parses it into operation identifier "QUERY" and parameter identifiers "TABLE(user_info)", "FIELDS(user_id, user_name, age)", "WHERE(age>18)", "ORDER_BY(user_id, ASC)", "LIMIT(10)", etc. initial syntax units. The parsing process uses a recursive descent or table-driven analysis method to identify statement structures and constituent elements according to predefined syntax rules.

[0141] The process of building dependency index table for initial syntax units is to analyze the relationship between syntax units. The dependency index table records the upstream calling nodes and downstream referenced nodes of each syntax unit, reflecting the calling and referencing relationship between syntax units. The upstream calling node refers to other units that call the current syntax unit, and the downstream referenced node refers to other units referenced by the current syntax unit. For example, the WHERE syntax unit may reference the field name in the FIELDS syntax unit, so FIELDS is the upstream calling node of WHERE, and WHERE is the downstream referenced node of FIELDS. A directed dependency graph is constructed based on the dependency index table, where the nodes represent syntax units and the directed edges represent calling or referencing relationships. The reference depth and calling breadth of each syntax unit are calculated, where the reference depth represents the longest path length from the root node to the current node, and the calling breadth represents the number of other nodes directly referenced by the current node. The node weight value is generated by considering the reference depth and calling breadth. For example, the weight value of a node with a reference depth of 3 and a calling breadth of 2 may be calculated as 3 x 2 = 6.

[0142] The process of dividing initial syntax units into different processing priorities according to node weight values is to determine the order for subsequent processing. Syntax units are grouped according to node weight values, with higher weight values being processed first. Within the same priority, syntax units are clustered based on semantic similarity, grouping syntax units with similar functions into a group. Semantic similarity is calculated by analyzing factors such as operation type, parameter type, and object of action. For example, although the contents of multiple field filtering conditions are different, they are all part of the WHERE clause in terms of semantics and can be processed in clusters. Based on priority grouping and semantic clustering, a hierarchical syntax tree containing multiple semantic clusters is constructed, with each layer containing syntax units of a specific priority and the same layer being organized according to semantic clusters. Starting from the root node of the syntax tree, the syntax tree is traversed in depth-first or breadth-first order to generate a syntax tree node sequence, which is used as input for subsequent conversion.

[0143] The process of obtaining a rule template matching the database type identifier from the syntax conversion rule library is preparing the conversion rule. The syntax conversion rule library stores syntax conversion rules for different database types, and each database type corresponds to a set of rule templates. Rule templates define how to convert standardized syntax structures into specific database syntax structures. For example, the rule template for MySQL database may contain the rule "LIMIT x, y is converted to LIMIT y OFFSET x"; the rule template for Oracle database may contain the rule "LIMIT x is converted to WHERE ROWNUM<=x". According to the type identifier of the target database, the corresponding rule template set is obtained from the rule library. Based on the rule template, a rule chain table is constructed, each table node corresponds to a conversion rule, and the nodes are connected by pointers. The execution order of the rule items in the rule chain table is set, considering the dependency and conflict between rules to ensure the correctness of the conversion process.

[0144] Traverse the syntax tree node sequence, calculate the execution cost and resource consumption of each node. The execution cost reflects the complexity and performance impact of the node corresponding operation, considering factors such as operation type (such as query, update, etc.), data volume involved, condition complexity, etc. Resource consumption reflects the system resource occupation during operation execution, including memory usage, CPU occupation, IO operation, etc. Nodes with execution cost exceeding the preset cost threshold are marked as performance sensitive nodes, which need to be specially optimized in the conversion process. For example, query nodes involving large table joins, filter nodes containing complex conditions may be marked as performance sensitive nodes. Apply rule chain table to structure optimization and syntax conversion for performance sensitive nodes, optimization includes rewriting query conditions, adjusting join order, adding index hints, etc., conversion includes converting standard syntax to target database specific syntax structure.

[0145] The process of determining the associated processing range based on the converted performance sensitive nodes is to extend the optimization range. Analyze the context dependency of the performance sensitive node to determine the associated node range that needs to be processed together. The associated processing range may include direct dependent nodes, indirect dependent nodes or function related nodes. Syntax tree nodes in the associated processing range are converted in execution order, applying the rule chain table constructed earlier, converting standardized syntax structures into specific syntax structures of the target database. For example, convert MySQL's "DATE_ADD(date, INTERVAL 1 DAY)" to Oracle's "date + 1". The conversion process considers the syntax characteristics, function support, type system, etc. of the target database to ensure that the generated execution statement is correctly executed in the target database. Finally, the converted syntax tree nodes are reorganized to generate complete execution statements of the target database, such as SQL query statements or API call sequences.

[0146] In this embodiment, the semantic structure and component relationship of the operation statement are accurately understood through syntax parsing and dependency analysis, providing a basis for subsequent conversion; the key processing nodes are identified through node weight calculation and priority division, optimizing the conversion order; the structured processing flow is organized through semantic clustering and hierarchical syntax tree, improving the systematicness of conversion; the optimization resources are focused through execution cost evaluation and performance sensitive node identification, improving the conversion efficiency; the context-related syntax conversion is realized through rule chain table and associated processing range, ensuring the consistency of conversion results. These technical effects collectively promote the accuracy, efficiency and reliability of cross-database operations, reduce the technical threshold of migration and integration between different databases, and improve the development efficiency and user experience of database applications.

[0147] In an alternative embodiment,

[0148] The execution statement is encapsulated as a transaction unit with a rollback mechanism, submitted to the target database for execution, the connection state corresponding to the connection identification information is monitored, the execution state information is received, the operation result report is generated according to the execution state information, and returned to the visual interface for display, including:

[0149] The data table access identification, data operation type and associated field information in the execution statement are parsed, the association relationship table between data tables is established according to the associated field information, and the execution statement with field reference is organized into a transaction unit group based on the association relationship table;

[0150] An operation sequence chain is constructed for the transaction unit group, a corresponding compensation operation is generated for each operation in the operation sequence chain according to the data operation type, and the operation sequence chain and the compensation operation are encapsulated as a transaction unit with a rollback mechanism;

[0151] The execution statement in the transaction unit is subjected to syntax verification and data consistency check, and after the verification, the database connection is obtained and submitted to the target database for execution;

[0152] The identification information of the database connection is recorded, the network connection state and the database session state corresponding to the connection identification information are collected in real time, when an abnormal state is detected, the checkpoint information of the last successful execution is obtained, the operation range that needs to be rolled back is determined according to the checkpoint information, the rollback is executed in reverse order of the compensation operation, and after completion, the execution request is reinitiated;

[0153] The operation serial number, execution time, affected row number and error information in the execution process are recorded and arranged into a structured operation result report, and the operation result report is returned to the visual interface for display.

[0154] Exemplarily, the execution statement generated in the previous step is analyzed by a syntax parser to extract key information therefrom. The data table access identifier includes a database name, a schema name, and a table name, which are used to uniquely identify the data table involved in the operation; the data operation type includes query (SELECT), insertion (INSERT), update (UPDATE), deletion (DELETE), etc., which represent the processing manner of the data; the associated field information includes the primary key, the foreign key, the field used in the connection condition, etc., which reflect the association relationship between the data tables. For example, for the execution statement "SELECT o.order_id, o.order_date, c.customer_name FROM orders o JOIN customers c ON o.customer_id=c.customer_id WHERE o.order_date>'2023-01-01'", the extracted data table access identifier is "orders" and "customers", the data operation type is "SELECT", and the associated field information is "orders.customer_id" and "customers.customer_id". The association relationship table between the data tables is established according to the associated field information, which is represented in a graph structure, with the nodes being the data tables and the edges being the association relationship, and the edges being labeled with the associated field and the associated type (such as one-to-one, one-to-many, etc.). Based on the association relationship table, the dependency relationship between the execution statements is analyzed, and the execution statements with field references are organized into a transaction unit group, so as to ensure that the associated operations are executed in the same transaction and maintain data consistency.

[0155] The process of constructing the operation sequence chain for the transaction unit group is to determine the execution order of the operations. According to the data operation type and the association relationship between the tables, the order of the operations is determined, and the operation sequence chain is constructed. The operation order follows the following principles: query operations are usually prior to modification operations; main table operations are usually prior to slave table operations; insertion operations are usually prior to update operations; update operations are usually prior to deletion operations. The operation sequence chain adopts a linked list structure, and each node contains an operation and its related information. According to the data operation type, a corresponding compensation operation is generated for each operation in the operation sequence chain, which is used to roll back the executed operations in case of transaction failure. The generation rules of the compensation operation are as follows: for an insertion operation, the compensation operation is to delete the corresponding record; for a deletion operation, the compensation operation is to re-insert the deleted record (the data before deletion needs to be saved in advance); for an update operation, the compensation operation is to restore the updated field to the original value (the data before update needs to be saved in advance); for a query operation, usually no compensation operation is needed. The operation sequence chain and the compensation operation are encapsulated as a transaction unit with a rollback mechanism, which includes an execution statement sequence, a compensation operation sequence, checkpoint information, etc., providing support for exception handling.

[0156] The process of syntax checking and data consistency checking for the execution statement in the transaction unit is to ensure the correctness of the operation. Syntax checking verifies whether the execution statement conforms to the syntax specification of the target database by parsing the structure of the execution statement, checks whether the field name, table name, keyword, etc. are correct. Data consistency checking verifies whether the operation meets the data integrity constraints, such as foreign key constraints, unique constraints, non-empty constraints, etc. For example, checking whether the insert or update operation violates the unique index constraint, whether the foreign key reference is valid, etc. The checking process adopts a combination of static analysis and pre-execution verification, static analysis is based on syntax rules and database schema information, and pre-execution verification checks the data state by constructing a lightweight query statement. After the check is passed, a database connection is obtained from the connection pool, or the connection established before is used, and the transaction unit is submitted to the target database for execution. The submission process sets appropriate transaction isolation level and timeout time to ensure the safety and reliability of the operation.

[0157] The process of recording the identification information of the database connection and collecting the connection state in real time is to realize transaction monitoring. The identification information of the database connection used to execute the transaction is recorded, including connection ID, database type, host address, username, etc. The network connection state and database session state of the connection are collected in real time, the network connection state includes whether the connection is active, delay time, packet loss rate, etc., the database session state includes whether the session is active, lock waiting state, resource usage, etc. The collection adopts a combination of periodic polling and event triggering, the polling interval is dynamically adjusted according to the importance of the operation, and the monitoring frequency of important operations is higher. When an abnormal state is detected, such as connection disconnection, session timeout, lock waiting timeout, etc., the checkpoint information of the last successful execution is obtained immediately. The checkpoint information records the progress of the transaction execution, including the identification and state of the completed operation. According to the checkpoint information, determine the operation range that needs to be rolled back, all executed operations between the checkpoint and the current operation need to be rolled back. Roll back in reverse order of the compensation operation, that is, starting from the last executed operation, execute the corresponding compensation operation one by one, until the checkpoint position is rolled back. After the rollback is completed, you can choose to abandon the current transaction, or reinitiate the execution request from the checkpoint to continue completing the remaining operations.

[0158] The process of recording operation information during execution and generating operation result report is to provide feedback for users. The execution of each operation is recorded, including operation sequence number (order in transaction), execution time (start time and end time), affected row number (number of records inserted, updated or deleted) and error information (if error occurs). These information is arranged into structured operation result report in JSON or XML format, including transaction overall information and operation detailed information. Transaction overall information includes transaction ID, start time, end time, total operation number, successful operation number, failed operation number, total affected row number, etc. Operation detailed information is arranged according to operation sequence number, and each operation contains its type, target table, execution time, affected row number, error information, etc. Operation result report is returned to visual interface for display, and the interface displays execution result according to report content, such as success / failure status, affected data volume, execution time, etc. For error condition, detailed error information and possible solution suggestion are displayed.

[0159] In the embodiment, the dependency between operations is identified through data table association analysis and transaction unit organization, ensuring consistent execution of associated operations; the ordered execution and abnormal rollback of transactions are realized through operation sequence chain and compensation operation mechanism, improving the fault tolerance of the system; the execution of error operations is prevented through syntax checking and data consistency checking, reducing the risk of data anomalies; real-time supervision and abnormal handling of the execution process are realized through connection state monitoring and checkpoint recovery, enhancing the stability of the system; detailed execution feedback and error diagnosis are provided through structured operation result report, optimizing user experience. These technical effects collectively promote the safety, reliability and availability of operation execution under cross-database environment, providing strong support for database management and application development.

[0160] Figure 3 The system architecture diagram of the cross-database unified management and operation method of the embodiment of the application is shown in Figure 3. From the user request on the left, the ResourceTable encapsulates the resource table processing, and the port listener receives the request and passes it to the AbstractDatabaseObject abstract database object class. This abstract class serves as the core component, implementing a unified interface for different database dialect strategy processors, and the figure shows two specific database object implementation classes, MySQL and Oracle. The system realizes unified access and management of different database types through this factory mode design. The data generated during execution is passed to the user interface on the right for display, and the system records data changes and execution status. This architecture design perfectly fits the dialect strategy processor mechanism, database connection management, structure mapping, syntax conversion and transaction processing described in the foregoing, realizing unified operation and management under cross-database environment.

[0161] In a second aspect, the present application provides a system for unified management and operation across databases, comprising:

[0162] A first unit configured to obtain database type identification, database access address and access credential information, establish a database connection, and generate connection identification information;

[0163] A second unit configured to obtain a dialect strategy processor corresponding to the database type identification from a preset dialect strategy registry and instantiate the same, call a metadata extraction method of the dialect strategy processor to extract database structure information from a target database, map the database structure information to a unified structure description according to a preset metadata mapping rule, and generate a structure mapping file;

[0164] A third unit configured to parse a database operation instruction sent by a visual interface and convert the same to a standard operation description object, and generate a standardized intermediate operation statement after checking according to the structure mapping file;

[0165] A fourth unit configured to call a syntax analysis module of the dialect strategy processor to analyze the intermediate operation statement and generate a syntax tree node sequence, obtain a conversion rule set matched with the database type identification from a syntax conversion rule library, and convert the syntax tree node sequence to an execution statement of the target database;

[0166] A fifth unit configured to encapsulate the execution statement as a transaction unit with a rollback mechanism, submit the same to the target database for execution, monitor a connection state corresponding to the connection identification information, receive execution state information, generate an operation result report according to the execution state information, and return the same to the visual interface for display.

[0167] In a third aspect, the present application provides an electronic device, comprising:

[0168] a processor;

[0169] a memory configured to store processor-executable instructions;

[0170] The processor is configured to call the instructions stored in the memory to execute the method described above.

[0171] In a fourth aspect, the present application provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions are executed by a processor to implement the method described above.

[0172] The present application can be a method, device, system and / or computer program product. The computer program product can include a computer readable storage medium having computer readable program instructions loaded thereon for executing various aspects of the present application.

[0173] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions recorded in the above embodiments can be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for uniform management and operation across databases, characterized by, The method comprises the following steps: obtaining database type identification, database access address and access credential information, establishing a database connection, and generating connection identification information; obtaining a dialect strategy processor corresponding to the database type identification from a preset dialect strategy registry and instantiating the dialect strategy processor, calling a metadata extraction method of the dialect strategy processor to extract database structure information from the target database, mapping the database structure information into a unified structure description according to a preset metadata mapping rule, and generating a structure mapping file; parsing a database operation instruction sent by a visual interface and converting it into a standard operation description object, and generating a standardized intermediate operation statement after checking according to the structure mapping file; calling a syntax analysis module of the dialect strategy processor to analyze the intermediate operation statement and generate a syntax tree node sequence, obtaining a conversion rule set matched with the database type identification from a syntax conversion rule library, and converting the syntax tree node sequence into an execution statement of the target database; encapsulating the execution statement into a transaction unit with a rollback mechanism, submitting it to the target database for execution, monitoring the connection state corresponding to the connection identification information, receiving execution state information, generating an operation result report according to the execution state information, and returning it to the visual interface for display; mapping the database structure information into a unified structure description according to a preset metadata mapping rule, and generating a structure mapping file comprises: performing a preset sampling rule on the field values in the database structure information to obtain numerical distribution characteristics, performing intelligent inference on the data types in the database structure information based on the numerical distribution characteristics, outputting inferred type information and inferred confidence, comparing the inferred confidence with a preset confidence threshold, and when the inferred confidence is greater than the preset confidence threshold, updating the data type mapping relationship in the preset metadata mapping rule library using the inferred type information to obtain an optimized metadata mapping rule; inputting the database structure information into the optimized metadata mapping rule for conversion, and outputting a structure mapping file in a unified structure description.

2. The method of claim 1, wherein, obtaining database type identification, database access address and access credential information, establishing a database connection, and generating connection identification information comprises: obtaining database connection information including database type identification, database access address and access credential information, and determining the database type identification from a preset database type mapping table; obtaining the corresponding connection parameter verification rule according to the database type identification, verifying the legality of the database connection information based on the connection parameter verification rule, and when the database connection information passes the verification, finding a matching idle connection from a preset database connection pool according to the database type identification and the database access address, and if no matching idle connection is found, establishing a database connection based on the database connection information; performing a connectivity test on the established database connection, and after the test passes, adding the database connection into the database connection pool for unified management, and generating connection identification information containing the database type identification, the database access address and a connection timestamp; The connection identification information is stored in a connection mapping table, and a connection monitoring thread is started, which periodically detects the connection state of the database connection and automatically reconnects and updates the connection mapping table when a connection exception is detected.

3. The method of claim 1, wherein, A dialect strategy processor corresponding to the database type identifier is obtained from a preset dialect strategy registry and instantiated, and a metadata extraction method of the dialect strategy processor is called to extract database structure information from the target database, including: Dialect strategy processor type information corresponding to the database type identifier is obtained from a preset dialect strategy registry; the dialect strategy processor type information includes a class name and a class path; A bytecode file of the dialect strategy processor is loaded according to the class path, a class object of the dialect strategy processor is obtained based on the class name through a reflection mechanism, a constructor method of the class object is called to generate a dialect strategy processor instance, the dialect strategy processor instance implements a predefined metadata extraction interface, and database structure information is extracted from the target database through the metadata extraction interface.

4. The method of claim 1, wherein, A preset sampling rule is performed on the field values in the database structure information to obtain a numerical distribution feature, an intelligent inference is performed on the data types in the database structure information based on the numerical distribution feature, and inferred type information and an inference confidence level are output, including: The field values in the database structure information are divided into a plurality of numerical intervals, sample values are randomly extracted in each numerical interval, the sample values are sorted by numerical size, and a difference value sequence of adjacent sample values is calculated, and the numerical distribution feature is generated based on the difference value sequence; The number of decimal places of the numerical data is counted to obtain a decimal place distribution feature, and the character length of the character data is counted to obtain a length distribution feature, and the decimal place distribution feature and the length distribution feature are combined to generate a character structure feature; the character structure feature is matched with a preset format template to generate a data pattern feature; The numerical distribution feature, the character structure feature, and the data pattern feature are combined to generate a numerical distribution feature vector, the numerical distribution feature vector is compared with a standard feature vector in a preset data type library to calculate a similarity, the data type with the highest similarity is selected as the inferred type information, the numerical distribution feature vector is compared with a feature rule set corresponding to the inferred type information to calculate a feature matching score, and the inferred confidence level is generated based on the comparison result of the feature matching score and a preset matching threshold, and finally the inferred type information and the inferred confidence level are output.

5. The method of claim 1, wherein, A database operation instruction sent by a visualization interface is parsed and converted into a standard operation description object, and a standardized intermediate operation statement is generated after verification according to a structure mapping file, including: A database operation instruction sent by a visualization interface is received, the database operation instruction is subjected to lexical analysis, and an operation type, a target object, and a filtering condition are extracted; An abstract syntax tree with weights is constructed based on the operation type, the target object, and the filtering condition, priority weights are set for nodes in the abstract syntax tree according to operation complexity, and nodes with dependency relationships are connected through directed edges to generate an operation dependency graph; rearranging the operation sequence based on the priority weight of the nodes in the operation dependency graph to obtain an execution path, and converting the execution path into a standard operation description object; obtaining table structure information and field attribute information from a structure mapping file, performing type checking on the standard operation description object, identifying an optimal type conversion path from a preset conversion template library when type incompatibility is detected, and generating a type conversion code segment according to the type conversion path; splitting the standard operation description object into a plurality of atomic operation units according to execution cost, and recombining each atomic operation unit based on the type conversion code segment to generate a standardized intermediate operation statement.

6. The method of claim 1, wherein, calling a syntax analysis module of a dialect strategy processor to parse the intermediate operation statement to generate a syntax tree node sequence, obtaining a conversion rule set matched with the database type identifier from a syntax conversion rule library, and converting the syntax tree node sequence into an execution statement of the target database, including: calling a syntax analysis module of a dialect strategy processor to parse the intermediate operation statement into an initial syntax unit containing an operation identifier and a parameter identifier; establishing a dependency index table for the initial syntax unit, the dependency index table recording an upstream calling node and a downstream referencing node of each syntax unit, constructing a directed dependency graph based on the dependency index table, calculating a reference depth and a calling breadth of each syntax unit, and generating a node weight value; dividing the initial syntax unit into different processing priorities according to the node weight value, clustering syntax units based on semantic similarity within the same priority, constructing a hierarchical syntax tree containing a plurality of semantic clusters, and generating a syntax tree node sequence; obtaining a rule template matched with the database type identifier from a syntax conversion rule library, constructing a rule linked list based on the rule template, setting an execution order for rule items in the rule linked list, traversing the syntax tree node sequence, calculating an execution cost and resource consumption of a node, marking a node with an execution cost exceeding a preset cost threshold as a performance sensitive node, and applying the rule linked list to the performance sensitive node for structure optimization and syntax conversion; determining an associated processing range based on the converted performance sensitive node, sequentially performing syntax structure conversion on syntax tree nodes in the associated processing range according to the execution order, and generating an execution statement of the target database.

7. The method of claim 1, wherein, encapsulating the execution statement into a transaction unit with a rollback mechanism, submitting it to the target database for execution, monitoring a connection state corresponding to the connection identifier information, receiving execution state information, generating an operation result report according to the execution state information, and returning it to the visualization interface for display, including: parsing data table access identifiers, data operation types, and associated field information in the execution statement, establishing an association relationship table between data tables according to the associated field information, and organizing execution statements with field references into a transaction unit group based on the association relationship table; constructing an operation order chain for the transaction unit group, generating a corresponding compensation operation for each operation in the operation order chain according to the data operation type, and encapsulating the operation order chain and the compensation operation into a transaction unit with a rollback mechanism. The execution statement in the transaction unit is syntax checked and data consistency checked, and after the checking passes, a database connection is acquired and submitted to a target database for execution; The identification information of the database connection is recorded, the network connection state and the database session state corresponding to the connection identification information are collected in real time, when an abnormal state is detected, the checkpoint information of the last successful execution is acquired, the operation range that needs to be rolled back is determined according to the checkpoint information, the rollback is executed in reverse order of the compensation operation, and after completion, the execution request is reinitiated; The operation sequence number, execution time, affected row number and error information in the execution process are recorded and arranged into a structured operation result report, and the operation result report is returned to a visual interface for display.

8. A uniform management and operating system across databases for implementing the method of any of the preceding claims 1-7, characterized by, Comprise: The first unit is used for acquiring database type identification, database access address and access credential information, establishing a database connection, and generating connection identification information; The second unit is used for acquiring and instantiating the dialect strategy processor corresponding to the database type identification from the preset dialect strategy registry, calling the metadata extraction method of the dialect strategy processor to extract database structure information from the target database, mapping the database structure information into a unified structure description according to a preset metadata mapping rule, and generating a structure mapping file; The third unit is used for parsing the database operation instruction sent by the visual interface and converting it into a standard operation description object, and generating a standardized intermediate operation statement after checking according to the structure mapping file; The fourth unit is used for calling the syntax analysis module of the dialect strategy processor to analyze the intermediate operation statement, generating a syntax tree node sequence, acquiring the conversion rule set matched with the database type identification from the syntax conversion rule library, and converting the syntax tree node sequence into the execution statement of the target database; The fifth unit is used for encapsulating the execution statement into a transaction unit with a rollback mechanism, submitting it to the target database for execution, monitoring the connection state corresponding to the connection identification information, receiving the execution state information, generating an operation result report according to the execution state information, and returning it to the visual interface for display.

9. An electronic device, comprising: Comprise: A processor; A memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method of any one of claims 1 to 7.

10. A computer-readable storage medium having stored thereon computer program instructions, wherein, The computer program instructions are executed by the processor to implement the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • SQL statement generation method and device, computer equipment and storage medium

    CN118568123A

  • SQL cross-database conversion method and device, equipment and storage medium

    CN119201978A