[go: up one dir, main page]

CN119322803A - Database SQL management method and device, electronic equipment and storage medium - Google Patents

Database SQL management method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN119322803A
CN119322803A CN202411541192.7A CN202411541192A CN119322803A CN 119322803 A CN119322803 A CN 119322803A CN 202411541192 A CN202411541192 A CN 202411541192A CN 119322803 A CN119322803 A CN 119322803A
Authority
CN
China
Prior art keywords
sql
database
information
sql request
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411541192.7A
Other languages
Chinese (zh)
Inventor
许雪峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianyi Digital Life Technology Co Ltd
Original Assignee
Tianyi Digital Life Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianyi Digital Life Technology Co Ltd filed Critical Tianyi Digital Life Technology Co Ltd
Priority to CN202411541192.7A priority Critical patent/CN119322803A/en
Publication of CN119322803A publication Critical patent/CN119322803A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/256Integrating or interfacing systems involving database management systems in federated or virtual databases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database SQL management method, a device, electronic equipment and a storage medium, which are used for solving the technical problems that middleware cannot identify that a SQL request does not contain a fragmentation key, so that the request is distributed to all database nodes in error, the load of a database is increased rapidly, and the service availability is affected. The method comprises the steps of analyzing an SQL request through the database SQL interceptor plug-in to obtain an analysis result when the application server receives the SQL request, judging whether the SQL request is a normal statement according to the analysis result, inquiring whether the SQL request has slicing information corresponding to the SQL in a database console if the SQL request is normal, judging whether the SQL request needs slicing according to the slicing information if the SQL request exists, judging whether the SQL request correctly carries slicing keys when the SQL request needs slicing, and if so, sending the SQL request to a middleware and executing the SQL request through the middleware.

Description

Database SQL management method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of SQL management technologies, and in particular, to a method and apparatus for managing database SQL, an electronic device, and a storage medium.
Background
As large system traffic continues to grow, the amount of data in the database also increases dramatically. To improve database performance, many companies employ a database-splitting-table strategy to balance data distribution, thereby improving query speed. Under this architecture, middleware such as Mycat plays a key role in directing queries to the correct database according to the sharded keys in the SQL request.
However, if the SQL request does not include a shard key, the middleware may not recognize the deficiency, and erroneously distribute the request to all database nodes, resulting in a steep increase in database load, and in extreme cases, even a paralysis of the database, affecting service availability.
In addition, no tool is currently available for maintaining the sharded key, and as time goes by, the original sharded key may be forgotten, so that a person writing SQL may miss the sharded key when writing SQL.
Disclosure of Invention
The invention provides a database SQL management method, a device, electronic equipment and a storage medium, which are used for solving the technical problems that middleware cannot identify that a SQL request does not contain a fragmentation key, so that the request is distributed to all database nodes in error, the load of a database is increased rapidly, and the service availability is affected.
The invention provides a database SQL management method which is applied to a database SQL management system, wherein the SQL management system comprises a database console and a database SQL interceptor plug-in, and the method comprises the following steps:
When the application server receives the SQL request, the SQL request is analyzed through the database SQL interceptor plug-in to obtain an analysis result;
Judging whether the SQL request is a normal statement or not according to the analysis result;
if so, inquiring whether the fragmentation information corresponding to the SQL exists in the database console;
if yes, judging whether the SQL request needs to be fragmented or not according to the fragmentation information;
when the SQL request needs to be fragmented, judging whether the SQL request carries a fragmented key correctly or not;
If yes, the SQL request is sent to the middleware, and the SQL request is executed through the middleware.
Optionally, the database SQL management system further comprises a database executor, and when the application server receives the SQL request, the database SQL interceptor plug-in analyzes the SQL request to obtain an analysis result, and before the step of obtaining the analysis result, the method further comprises the steps of:
acquiring historical data of a service database;
extracting service library table information from the service library history data by the database executor;
transmitting the service library table information to the database console;
when the auditing passing information aiming at the service library table information is received, the database control console carries out format conversion on the service library table information to obtain target format information, and returns the target format information to the database executor.
Optionally, the method further comprises:
And when the SQL request does not need to be fragmented, sending the SQL request to the middleware, and executing the SQL request through the middleware.
Optionally, the step of determining whether the SQL request correctly carries a shard key includes:
acquiring first fragment key information from the SQL request;
acquiring second fragment key information from the fragment information;
and when the first piece of key information is the same as the second piece of key information, judging that the SQL request correctly carries the piece of key.
Optionally, the method further comprises:
and outputting error reporting information when the SQL request does not correctly carry the slicing keys.
The invention also provides a database SQL management device which is applied to a database SQL management system, wherein the SQL management system comprises a database console and a database SQL interceptor plug-in, and the method comprises the following steps:
The analysis module is used for analyzing the SQL request through the database SQL interceptor plug-in when the application server receives the SQL request, so as to obtain an analysis result;
The normal statement judging module is used for judging whether the SQL request is a normal statement or not according to the analysis result;
the fragment information inquiry module is used for inquiring whether the fragment information corresponding to the SQL exists in the database console or not if the fragment information is normal;
the slicing judgment module is used for judging whether the SQL request needs slicing or not according to the slicing information if the SQL request needs slicing;
the slicing key judging module is used for judging whether the SQL request correctly carries slicing keys or not when the SQL request needs slicing;
And the first execution module is used for sending the SQL request to the middleware if yes, and executing the SQL request through the middleware.
Optionally, the method further comprises:
the service database historical data acquisition module is used for acquiring service database historical data;
the database executor is used for extracting the database historical data from the database;
the business library table information sending module is used for sending the business library table information to the database console;
and the auditing module is used for carrying out format conversion on the business library table information by the database control console when receiving auditing passing information aiming at the business library table information to obtain target format information and returning the target format information to the database executor.
Optionally, the method further comprises:
And the second execution module is used for sending the SQL request to the middleware when the SQL request does not need to be fragmented, and executing the SQL request through the middleware.
The invention also provides an electronic device comprising a processor and a memory:
the memory is used for storing program codes and transmitting the program codes to the processor;
The processor is configured to execute the database SQL management method according to any of the above claims according to instructions in the program code.
The present invention also provides a computer readable storage medium for storing program code for executing the database SQL management method according to any one of the above.
The technical scheme shows that the method has the advantages that when the application server receives the SQL request, the SQL request is analyzed through the database SQL interceptor plug-in to obtain an analysis result, whether the SQL request is a normal statement is judged according to the analysis result, if so, whether the SQL corresponding fragmentation information exists in the database console is inquired, if so, whether the SQL request needs fragmentation is judged according to the fragmentation information, and if so, whether the SQL request correctly carries the fragmentation key is judged, if so, the SQL request is sent to the middleware, and the SQL request is executed through the middleware. According to the method and the device, the SQL request is analyzed through the database SQL interceptor plug-in, whether the SQL request correctly carries the slicing keys is analyzed from the analysis result, so that the middleware is prevented from distributing the SQL request to all database nodes in an error mode, and service availability is guaranteed.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from these drawings without inventive faculty for a person skilled in the art.
FIG. 1 is a block diagram of a database SQL management system according to an embodiment of the invention
FIG. 2 is a flowchart illustrating steps of a method for managing database SQL according to an embodiment of the present invention;
FIG. 3 is a table of t_table_info of the database;
FIG. 4 is a table of t_table_column_info of the database;
fig. 5 is a schematic diagram of family information in the current service system;
fig. 6 is a second schematic diagram of family information in the current service system;
fig. 7 is a block diagram of a database SQL management device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a database SQL management method, a device, electronic equipment and a storage medium, which are used for solving the technical problems that a middleware cannot identify that a SQL request does not contain a fragmentation key, so that the request is distributed to all database nodes in error, the load of a database is rapidly increased, and the service availability is influenced.
In order to make the objects, features and advantages of the present invention more comprehensible, the technical solutions in the embodiments of the present invention are described in detail below with reference to the accompanying drawings, and it is apparent that the embodiments described below are only some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a block diagram of a database SQL management system according to an embodiment of the present invention.
As shown in fig. 1, the database SQL management system includes a database console, a database SQL interceptor plug-in, and a database executor.
The database console is responsible for managing the table creation, updating and deleting operations of the database and maintaining the sharding keys, and provides sharding key query service for the database SQL interceptor plug-in. In addition, the control console can display the cache time of the database table and the slicing keys in a visual mode, so that the user can inquire conveniently.
And the database executor is used for inputting the table creation information and the fragment information through a visual interface of the control console by an operator and submitting the table creation information and the fragment information to a database auditor for auditing. After the verification is passed, the executor converts the information into SQL script and executes the SQL script into corresponding database to ensure the normalization and accuracy of operation. The database executor can be connected with the target database in a multi-data source mode, and in order to ensure the performance, the database executor and the database console need to be deployed under the same local area network.
And the database SQL interceptor plug-in is responsible for analyzing the business SQL statement and judging whether the slicing key is needed or not by analyzing the SQL statement. If the fragment key is not carried or the fragment key value is empty, the plug-in will intercept the statement and return an error prompt. Only the SQL statement carrying the valid sharded key can be allowed to be executed, thereby avoiding the database performance problem caused by the sharded key missing.
Based on a database SQL management system, the embodiment of the invention provides a database SQL management method, which is used for solving the technical problems that middleware cannot identify that a SQL request does not contain a sharding key, so that the request is distributed to all database nodes in error, the load of a database is increased sharply, and the service availability is affected.
Referring to fig. 2, fig. 2 is a flowchart illustrating steps of a method for managing database SQL according to an embodiment of the present invention.
Step 201, when the application server receives the SQL request, analyzing the SQL request through a database SQL interceptor plug-in to obtain an analysis result;
step 202, judging whether the SQL request is a normal statement or not according to the analysis result;
SQL (Structured Query Language ), a special purpose programming language, is a database query and programming language used to access data and query, update and manage relational database systems.
In the embodiment of the invention, the database SQL interceptor plug-in can control the business SQL slicing keys of the application service according to the database slicing information which is input by the database console.
In order not to affect the execution performance of the business SQL of the application service, the database sharding information in the console needs to be loaded into the local memory of the application service. When an application service loading the database SQL interceptor plugin is started, the interceptor plugin can pull the database fragmentation information from the database console in a remote calling mode for the first time and load the database fragmentation information into a local memory of the application service, and then the database fragmentation information can be pulled at regular time to refresh the fragmentation information in the local memory. The configuration file of the application service needs to configure remote address information (both internal network and external network can access) of the database control console and time interval (millisecond, -1 is not refreshed) of the time pull information.
After the business SQL enters the application server, the application server responds to the SQL request, analyzes the SQL request through the database SQL interceptor, judges whether the SQL request is a normal SQL statement, and if so, continues to execute. The following are SQL request parsing examples:
Inquiring user equipment information Select user_id, device_name, device_sn, device_mac form t_device_info window user_id=1001, resolving to type= selelct, tabaleName =t_device_info, conditions= { "user_id": "1001" }. Wherein the type comprises select, update, delete, tableName is the list name of the operation, and conditions are the query conditions.
Step 203, if so, inquiring whether the database console has the fragment information corresponding to SQL;
If the SQL request is a normal statement, inquiring whether the corresponding fragmentation information exists in the local memory according to tabaleName, if the fragmentation information is not inquired, terminating the business flow and prompting that the corresponding information does not exist in the database, and requesting to confirm to a database manager. And if the corresponding information is queried, executing a corresponding fragment information rule judging program.
Step 204, if yes, judging whether the SQL request needs to be fragmented according to the fragmentation information;
step 205, when the SQL request needs to be fragmented, judging whether the SQL request carries a fragmented key correctly;
Step 206, if yes, sending the SQL request to the middleware and executing the SQL request through the middleware;
According to the queried information, the SQL interceptor plug-in of the database only issues SQL sentences carrying correct slicing keys to the middleware such as Mycat for execution.
Further, in the embodiment of the invention, when the SQL request does not need to be fragmented, the SQL request is sent to the middleware and executed through the middleware, and when the SQL request does not correctly carry the fragmented key, the error reporting information is output.
In a specific implementation, the database SQL interceptor plug-in is based on the queried information. And if the judgment that the segmentation is not needed, issuing Mycat to execute the SQL statement. And if the slicing is needed, comparing the returned slicing information with the value in the conditions to judge whether all the slicing keys are contained. If the slicing key is not available, the error reporting information "$ { table name } does not carry the correct slicing key", and the original business SQL statement is printed in the business log for subsequent checking and correcting through the log. If the value of the fragment field is Null, returning error reporting information "$ { table name }" and the value of the fragment key $ { fragment field name $ { is Null or Null ", and printing an original service SQL sentence in the service log for subsequent checking and correcting through the log.
Further, in the embodiment of the present invention, the step of determining whether the SQL request correctly carries the shard key includes:
S51, acquiring first fragment key information from the SQL request;
S52, acquiring second piece key information from the piece information;
And S53, when the first piece of key information is the same as the second piece of key information, judging that the SQL request correctly carries the piece of key.
Further, in the embodiment of the invention, the database SQL management system further comprises a database executor, and when the application server receives the SQL request, the database SQL interceptor plug-in analyzes the SQL request to obtain an analysis result, and before the step of obtaining the analysis result, the method further comprises the steps of:
s1, acquiring historical data of a service database;
S2, extracting service library table information from service library historical data through a database executor;
S3, sending the business library table information to a database control console;
And S4, when the auditing passing information aiming at the service library table information is received, the database control console performs format conversion on the service library table information to obtain target format information, and returns the target format information to the database executor.
In a specific implementation, for the service database history data, the database executor may decompil the service database table information, writing into the console information base. The identification of the slicing keys of the service library can be realized by reading the keyword identification of the field remark information, intelligently recommending the marking slicing keys by means including but not limited to artificial intelligence, service statistics and the like, and finally correcting the slicing information by means of manual work.
It should be noted that, in the embodiment of the present invention, the subsequent service database maintenance work may be performed through the database console, and the operator may add, modify, and delete the table or field information in the service database through the Web page of the console. Through the newly added list information of the web page, chinese and English input of the list cannot be null, whether the slicing is selected to be yes or not through the drop-down frame, if yes, the slicing key must be input, and the caching time of the slicing information is required to be input. Then adding field information of the table, wherein the field input frame can be dynamically increased or decreased, the English name, the field type and the field remark information in the field can not be null, the field value can be null or not in the drop-down selection, and the drop-down selection is a primary key or not.
After the database table information is stored in the t_table_info table (fig. 3) and the t_table_column_info table (fig. 3) of the database, the state is the state to be checked, the main key automatically generates a unique number for the system, the update time and the creation time are data entry time, and the operation is a data entry personnel. And after the information is stored, sending mails and short message reminding to a database manager.
The database manager can see the data information to be audited through the Web page of the database control console, and after the administrator passes the audit, the database control console can automatically issue the corresponding input information to the database executor in a JSON format. The data format is as follows:
tableName is the corresponding table english name, operationType is the operation type create, alert update, drop delete, columnName is the field english name, columnType is the field database storage type, isNUll is whether the field can be empty, 0 is no, 1 is yes, ISPRIMARY is whether the field can be the primary key, 0 is no, 1 is yes, and the comment is field remark information.
If the database manager does not pass the audit, the database manager returns, and the input personnel can submit the audit after modifying according to the modification suggestion.
The database executor assembles the database execution script after receiving the JSON data of the database console, then issues the script to the database for execution, the executor needs to report the execution result to the console after the execution is completed, and the state of updating the t_table_info table (figure 3) after the execution is successful is 1-passed and the updating time is reached.
An operator can check the auditing condition of the recorded information through a database control console, and can maintain and check the database table and the fragment information through the control console later.
According to the method and the device, the SQL request is analyzed through the database SQL interceptor plug-in, whether the SQL request correctly carries the slicing keys is analyzed from the analysis result, so that the middleware is prevented from distributing the SQL request to all database nodes in an error mode, and service availability is guaranteed.
For ease of understanding, embodiments of the present invention are described below by way of specific examples:
Fig. 5 and 6 are family information in the current service system, the information is input through a database console, and it can be seen from table 3 that the slicing key of t_family_info is user_id, and the buffer validity period is 43200 seconds. From Table 4, it can be seen that t_family_info has 9 fields in total, where family_id is the primary key. The user_id information needs to be carried when a user or other functional module needs to query the family information. The following are two cases that occur when the current system queries:
Case 1 is that user 1 queries family information, and SQL request statement select family_id,family_name,user_id,house_type,description,address from t_family_info where user_id = 20010 and family_id = 30040, knows that shard key FRAGMENTKEY is user_id from database console tabaleName as t_family_info information. The current service SQL carries a user_id and has a value of 20010, so that the fragment query condition of the table is satisfied, the service SQL is normally issued to Mycat for execution and normally returns family information of user_id=20010 and family_id=30040.
Case 2 is the device module querying the home information for assembling the return parameters. Since the service bug fails to acquire the user id information, the service SQL statement select family_id,family_name,user_id,house_type,description,address from t_family_info where user_id = null and family_id = 20008. knows that the shard key FRAGMENTKEY is the user_id according to the database console tabaleName being t_family_info information. The current service SQL carries a user_id but has a null value, so that the fragment query condition of the table is not satisfied, the service SQL cannot be normally issued to Mycat for execution, and the fragment key user_id value of the error reporting information t_family_info is returned as null.
Referring to fig. 7, fig. 7 is a block diagram illustrating a database SQL management apparatus according to an embodiment of the present invention.
The embodiment of the invention provides a database SQL management device which is applied to a database SQL management system, wherein the SQL management system comprises a database console and a database SQL interceptor plug-in, and the method comprises the following steps:
The parsing module 701 is configured to parse the SQL request through the database SQL interceptor plug-in when the application server receives the SQL request, to obtain a parsing result;
the normal sentence judging module 702 is configured to judge whether the SQL request is a normal sentence according to the analysis result;
The fragment information query module 703 is configured to query whether the database console has the fragment information corresponding to the SQL if the fragment information is normal;
The fragmentation judgment module 704 is configured to judge whether the SQL request needs fragmentation according to the fragmentation information if the fragmentation information exists;
the slicing key judging module 705 is configured to judge whether the SQL request correctly carries the slicing key when the SQL request needs slicing;
the first execution module 706 is configured to send the SQL request to the middleware if yes, and execute the SQL request through the middleware.
In an embodiment of the present invention, the method further includes:
the service database historical data acquisition module is used for acquiring service database historical data;
the business library table information extraction module is used for extracting business library table information from the business library historical data through the database executor;
the business library table information sending module is used for sending the business library table information to the database control console;
And the auditing module is used for converting the format of the business library table information to obtain target format information when receiving auditing passing information aiming at the business library table information, and returning the target format information to the database executor.
In an embodiment of the present invention, the method further includes:
and the second execution module is used for sending the SQL request to the middleware when the SQL request does not need to be fragmented and executing the SQL request through the middleware.
In the embodiment of the present invention, the slicing key determining module 705 includes:
The first slicing key information acquisition sub-module is used for acquiring the first slicing key information from the SQL request;
The second segment key information acquisition sub-module is used for acquiring the second segment key information from the segment information;
and the judging submodule is used for judging that the SQL request correctly carries the slicing key when the first slicing key information is the same as the second slicing key information.
In an embodiment of the present invention, the method further includes:
And the error reporting module is used for outputting error reporting information when the SQL request does not correctly carry the slicing keys.
The embodiment of the invention also provides electronic equipment, which comprises a processor and a memory:
The memory is used for storing the program codes and transmitting the program codes to the processor;
the processor is used for executing the database SQL management method according to the embodiment of the invention according to the instructions in the program code.
The embodiment of the invention also provides a computer readable storage medium, which is used for storing program codes, and the program codes are used for executing the database SQL management method of the embodiment of the invention.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article or terminal device comprising the element.
While the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that the foregoing embodiments may be modified or equivalents may be substituted for some of the features thereof, and that the modifications or substitutions do not depart from the spirit and scope of the embodiments of the invention.

Claims (10)

1.一种数据库SQL管理方法,其特征在于,应用于数据库SQL管理系统,所述SQL管理系统包括数据库控制台、数据库SQL拦截器插件;所述方法包括:1. A database SQL management method, characterized in that it is applied to a database SQL management system, the SQL management system includes a database console and a database SQL interceptor plug-in; the method includes: 当应用服务器接收到SQL请求时,通过所述数据库SQL拦截器插件解析所述SQL请求,得到解析结果;When the application server receives the SQL request, the database SQL interceptor plug-in parses the SQL request to obtain a parsing result; 根据所述解析结果判断所述SQL请求是否为正常语句;Determine whether the SQL request is a normal statement according to the parsing result; 若正常,则查询所述数据库控制台中是否存在所述SQL对应的分片信息;If normal, query whether there is sharding information corresponding to the SQL in the database console; 若存在,根据所述分片信息判断所述SQL请求是否需要分片;If so, determine whether the SQL request needs to be fragmented according to the fragmentation information; 当所述SQL请求需要分片时,判断所述SQL请求是否正确携带分片键;When the SQL request needs to be sharded, determine whether the SQL request correctly carries the sharding key; 若是,将所述SQL请求发送至中间件,并通过所述中间件执行所述SQL请求。If so, the SQL request is sent to the middleware, and the SQL request is executed by the middleware. 2.根据权利要求1所述的方法,其特征在于,所述数据库SQL管理系统还包括数据库执行器;所述当应用服务器接收到SQL请求时,通过所述数据库SQL拦截器插件解析所述SQL请求,得到解析结果的步骤之前,还包括:2. The method according to claim 1 is characterized in that the database SQL management system further comprises a database executor; when the application server receives the SQL request, before the step of parsing the SQL request through the database SQL interceptor plug-in to obtain the parsing result, it also comprises: 获取业务数据库历史数据;Obtain historical data from the business database; 通过所述数据库执行器从所述业务库历史数据中提取业务库表信息;Extracting business library table information from the business library historical data through the database executor; 将所述业务库表信息发送至所述数据库控制台;Sending the business library table information to the database console; 当接收到针对所述业务库表信息的审核通过信息时,所述数据库控制台将所述业务库表信息进行格式转换,得到目标格式信息,并将目标格式信息返回至所述数据库执行器。When receiving the audit approval information for the business library table information, the database console converts the format of the business library table information to obtain target format information, and returns the target format information to the database executor. 3.根据权利要求1所述的方法,其特征在于,还包括:3. The method according to claim 1, further comprising: 当所述SQL请求不需要分片时,将所述SQL请求发送至所述中间件,并通过所述中间件执行所述SQL请求。When the SQL request does not need to be fragmented, the SQL request is sent to the middleware, and the SQL request is executed by the middleware. 4.根据权利要求1所述的方法,其特征在于,所述判断所述SQL请求是否正确携带分片键的步骤,包括:4. The method according to claim 1, characterized in that the step of determining whether the SQL request correctly carries the sharding key comprises: 从所述SQL请求中获取第一分片键信息;Obtaining first shard key information from the SQL request; 从所述分片信息中获取第二分片键信息;Obtaining second shard key information from the shard information; 当所述第一分片键信息与所述第二分片键信息相同时,判定所述SQL请求正确携带分片键。When the first sharding key information is the same as the second sharding key information, it is determined that the SQL request correctly carries the sharding key. 5.根据权利要求1-4任一项所述的方法,其特征在于,还包括:5. The method according to any one of claims 1 to 4, further comprising: 当所述SQL请求未正确携带分片键时,输出报错信息。When the SQL request does not correctly carry the sharding key, an error message is output. 6.一种数据库SQL管理装置,其特征在于,应用于数据库SQL管理系统,所述SQL管理系统包括数据库控制台、数据库SQL拦截器插件;所述装置包括:6. A database SQL management device, characterized in that it is applied to a database SQL management system, the SQL management system includes a database console and a database SQL interceptor plug-in; the device includes: 解析模块,用于当应用服务器接收到SQL请求时,通过所述数据库SQL拦截器插件解析所述SQL请求,得到解析结果;A parsing module, used for parsing the SQL request through the database SQL interceptor plug-in to obtain a parsing result when the application server receives the SQL request; 正常语句判断模块,用于根据所述解析结果判断所述SQL请求是否为正常语句;A normal statement judgment module, used to judge whether the SQL request is a normal statement according to the parsing result; 分片信息查询模块,用于若正常,则查询所述数据库控制台中是否存在所述SQL对应的分片信息;A shard information query module, used to query whether the shard information corresponding to the SQL exists in the database console if it is normal; 分片判断模块,用于若存在,根据所述分片信息判断所述SQL请求是否需要分片;A sharding judgment module, used to judge whether the SQL request needs sharding according to the sharding information, if any; 分片键判断模块,用于当所述SQL请求需要分片时,判断所述SQL请求是否正确携带分片键;A sharding key judgment module, used to judge whether the SQL request correctly carries the sharding key when the SQL request needs to be sharded; 第一执行模块,用于若是,将所述SQL请求发送至中间件,并通过所述中间件执行所述SQL请求。The first execution module is used to send the SQL request to the middleware and execute the SQL request through the middleware. 7.根据权利要求6所述的装置,其特征在于,还包括:7. The device according to claim 6, further comprising: 业务数据库历史数据获取模块,用于获取业务数据库历史数据;A business database historical data acquisition module is used to acquire business database historical data; 业务库表信息提取模块,用于通过所述数据库执行器从所述业务库历史数据中提取业务库表信息;A business library table information extraction module, used to extract business library table information from the business library historical data through the database executor; 业务库表信息发送模块,用于将所述业务库表信息发送至所述数据库控制台;A business library table information sending module, used for sending the business library table information to the database console; 审核模块,用于当接收到针对所述业务库表信息的审核通过信息时,所述数据库控制台将所述业务库表信息进行格式转换,得到目标格式信息,并将目标格式信息返回至所述数据库执行器。The audit module is used for, when receiving the audit pass information for the business library table information, the database console converts the format of the business library table information to obtain the target format information, and returns the target format information to the database executor. 8.根据权利要求6所述的装置,其特征在于,还包括:8. The device according to claim 6, further comprising: 第二执行模块,用于当所述SQL请求不需要分片时,将所述SQL请求发送至所述中间件,并通过所述中间件执行所述SQL请求。The second execution module is used to send the SQL request to the middleware when the SQL request does not need to be fragmented, and execute the SQL request through the middleware. 9.一种电子设备,其特征在于,所述设备包括处理器以及存储器:9. An electronic device, characterized in that the device comprises a processor and a memory: 所述存储器用于存储程序代码,并将所述程序代码传输给所述处理器;The memory is used to store program code and transmit the program code to the processor; 所述处理器用于根据所述程序代码中的指令执行权利要求1-6任一项所述的数据库SQL管理方法。The processor is used to execute the database SQL management method according to any one of claims 1 to 6 according to the instructions in the program code. 10.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质用于存储程序代码,所述程序代码用于执行权利要求1-6任一项所述的数据库SQL管理方法。10. A computer-readable storage medium, characterized in that the computer-readable storage medium is used to store program codes, and the program codes are used to execute the database SQL management method according to any one of claims 1 to 6.
CN202411541192.7A 2024-10-31 2024-10-31 Database SQL management method and device, electronic equipment and storage medium Pending CN119322803A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411541192.7A CN119322803A (en) 2024-10-31 2024-10-31 Database SQL management method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411541192.7A CN119322803A (en) 2024-10-31 2024-10-31 Database SQL management method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN119322803A true CN119322803A (en) 2025-01-17

Family

ID=94228645

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411541192.7A Pending CN119322803A (en) 2024-10-31 2024-10-31 Database SQL management method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN119322803A (en)

Similar Documents

Publication Publication Date Title
CN111522816B (en) Data processing method, device, terminal and medium based on database engine
CN110659282B (en) Data route construction method, device, computer equipment and storage medium
US8065323B2 (en) Offline validation of data in a database system for foreign key constraints
CN113110866A (en) Method and device for evaluating database change script
US10521407B2 (en) Grouping of database objects
CN111857721B (en) SQL statement verification method, data acquisition method, equipment and storage device
CN110597844A (en) Heterogeneous database data unified access method and related equipment
CN104769585A (en) System and method for recursively traversing the internet and other sources to identify, gather, curate, adjudicate, and qualify business identity and related data
US20200089792A1 (en) Consistency checks between database systems
US8489631B2 (en) Distributing a query
CN119202708A (en) Fault diagnosis data labeling method and device
US10003492B2 (en) Systems and methods for managing data related to network elements from multiple sources
CN111125213A (en) Data acquisition method, device and system
CN113626423B (en) Log management method, device and system of business database
CN119322803A (en) Database SQL management method and device, electronic equipment and storage medium
CN114153461A (en) A script processing method, device, electronic device and storage medium
CN116401140A (en) Data processing method, device, equipment, readable medium and software product
TWI696080B (en) System and implementing method for managing security of information based on inspection of database log file
US10289531B2 (en) Software integration testing with unstructured database
US12026134B2 (en) Flow-based data quality monitoring
CN114937316B (en) Software fault detection method, device, equipment and medium
CN112965993B (en) Data processing system, method, device and storage medium
CN111695031B (en) Tag-based search method, device, server and storage medium
CN120448348A (en) Log management method, device, equipment and medium
CN121283774A (en) Rights management method, electronic device and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination