Risk prediction method and device for DDL change operation and computer equipment
By identifying the type of DDL change operation and performing risk diagnosis, the problem that traditional methods cannot effectively predict the risk of DDL change operation is solved, and risk prediction of DDL change operation is realized, and the reliability and stability of the system are improved.
Patent Information
- Application Number
- CN202510231979.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-06-17
AI Technical Summary
The traditional risk diagnosis method of DDL change operation cannot effectively predict the risk of DDL change operation, resulting in system performance degradation or failure and production accidents.
Provide a risk prediction method for DDL change operation. By identifying the type of DDL change operation, obtaining and comparing field metadata information, querying SQL statement sample statistics table, performing risk diagnosis and index deletion risk diagnosis to generate risk prediction results.
The risk prediction of DDL change operations is realized, the reliability of the test environment for performing DDL change operations is improved, the loss of system performance is reduced, the index failure caused by the risk of implicit type conversion of associated fields is avoided, and the security and stability of database changes are ensured.
Smart Images

Figure CN120162345A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a risk prediction method, device, computer device, and storage medium for DDL change operations. Background Art
[0002] With the development of information technology, the Database Management System (DBMS) has become the core component of various information systems, responsible for the management and processing of enterprise data. It can be said that the design and maintenance of the database directly affect the stability and security of the system. Under the continuous change of business requirements, the database structure needs to be frequently adjusted, that is, it needs to be implemented through the data definition language (DDL). Among them, DDL operations may largely affect the SQL queries and application logics that depend on the table.
[0003] However, traditional risk diagnosis methods for DDL change operations have problems such as being unable to predict the risks of DDL change operations, resulting in a decline in system performance, and even leading to system failures and production accidents. Summary of the Invention
[0004] Based on this, in view of the above technical problems, it is necessary to provide a risk prediction method, device, computer device, and storage medium for DDL change operations that can predict the risks of DDL change operations.
[0005] In a first aspect, a risk prediction method for DDL change operations is provided, and the method includes:
[0006] In response to receiving an operation statement of a DDL change operation, determine the operation type of the DDL change operation according to the operation statement; the operation type includes a table field metadata modification operation or an index deletion operation;
[0007] In response to the operation type being a table field metadata modification operation, obtain the field metadata information before the change operation and the field metadata information after the change operation, and compare the field metadata information before the change operation and the field metadata information after the change operation to obtain a comparison result; the comparison result includes that the data information is the same or the data information is different;
[0008] In response to the comparison result indicating that the data information is different, obtain the database name of the DDL change table for the DDL change operation and the SQL statement sample statistics table, and query the SQL statement sample statistics table according to the database name to obtain a set of SQL statement samples; the SQL statement sample statistics table is used to store all SQL statement samples in the full database; the set of SQL statement samples includes each target SQL statement sample; the target SQL statement sample is an SQL statement sample that references the DDL change table.
[0009] Perform an implicit type conversion risk diagnosis on the associated fields of each target SQL statement sample in sequence according to the field metadata information after the change operation to obtain the corresponding implicit type conversion risk prediction result for the associated fields.
[0010] In one embodiment, the method further includes: in response to the operation type being an index deletion operation, obtain the database name, query the SQL statement sample statistics table according to the database name to obtain a set of SQL statement samples, and obtain the execution plan of the set of SQL statement samples; parse the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation; perform an index deletion risk diagnosis on each target SQL statement sample in sequence according to the index name and the execution plan to obtain the corresponding index deletion risk prediction result.
[0011] In one embodiment, the implicit type conversion risk prediction result for the associated fields includes a prediction result of the existence or non-existence of an implicit type conversion risk for the associated fields; the index deletion risk prediction result includes the existence or non-existence of an index deletion risk; wherein, the method further includes: outputting an implicit type conversion risk prompt message for the associated fields according to each implicit type conversion risk prediction result for the associated fields; outputting an index deletion risk prompt message according to each index deletion risk prediction result.
[0012] In one embodiment, the method further includes: displaying each implicit type conversion risk prediction result for the associated fields and / or each index deletion risk prediction result on the risk prediction result display interface for the DDL change operation; generating a risk assessment report according to each implicit type conversion risk prediction result for the associated fields and / or each index deletion risk prediction result.
[0013] In one embodiment, the table field metadata modification operation includes a field type modification operation, a character set modification operation, and a collation modification operation.
[0014] In one embodiment, obtaining the field metadata information before the change operation and the field metadata information after the change operation includes: parsing the operation statement to obtain the field metadata information before the change operation; the field metadata information before the change operation includes the field type before the change operation, the character set before the change operation, and the collation rule before the change operation; obtaining the DDL change table, and obtaining the field metadata information after the change operation after parsing the DDL change table; the field metadata information after the change operation includes the field type after the change operation, the character set after the change operation, and the collation rule after the change operation.
[0015] In one embodiment, obtaining the database name of the DDL change table for the DDL change operation and the SQL statement sample statistics table includes: collecting all SQL statement samples in the full database; storing each SQL statement sample in the SQL statement sample statistics table.
[0016] In a second aspect, a risk prediction device for DDL change operations is provided. The method includes:
[0017] An operation type determination module, configured to, in response to receiving an operation statement of a DDL change operation, determine the operation type of the DDL change operation according to the operation statement; the operation type includes a table field metadata modification operation or an index deletion operation;
[0018] An information comparison module, configured to, in response to the operation type being a table field metadata modification operation, obtain the field metadata information before the change operation and the field metadata information after the change operation, and compare the field metadata information before the change operation and the field metadata information after the change operation to obtain a comparison result; the comparison result includes that the data information is the same or the data information is different;
[0019] A sample set generation module, configured to, in response to the comparison result being that the data information is different, obtain the database name of the DDL change table for the DDL change operation and the SQL statement sample statistics table, query the SQL statement sample statistics table according to the database name to obtain a SQL statement sample set; the SQL statement sample statistics table is used to store all SQL statement samples in the full database; the SQL statement sample set includes each target SQL statement sample; the target SQL statement sample is a SQL statement sample that references the DDL change table;
[0020] A risk diagnosis module, configured to perform an implicit type conversion risk diagnosis on the associated fields of each target SQL statement sample in sequence according to the field metadata information after the change operation to obtain a corresponding implicit type conversion risk prediction result for the associated fields.
[0021] In a third aspect, a computer device is provided, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of any of the methods in the above method embodiments are implemented.
[0022] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the methods in the above method embodiments are implemented.
[0023] The above risk prediction method, device, computer device and storage medium for DDL change operations, in response to receiving an operation statement of a DDL change operation, determine the operation type of the DDL change operation according to the operation statement; the operation type includes a table field metadata modification operation or an index deletion operation; then, in response to the operation type being a table field metadata modification operation, obtain the field metadata information before the change operation and the field metadata information after the change operation, and obtain a comparison result after comparing the field metadata information before the change operation and the field metadata information after the change operation; the comparison result includes that the data information is the same or the data information is different; and, in response to the comparison result being that the data information is different, obtain the database name of the DDL change table of the DDL change operation and the SQL statement sample statistical table, and query the SQL statement sample statistical table according to the database name to obtain a set of SQL statement samples; the SQL statement sample statistical table is used to store all SQL statement samples in the full database; the set of SQL statement samples includes each target SQL statement sample; the target SQL statement sample is an SQL statement sample that references the DDL change table; then, perform an implicit type conversion risk diagnosis on each target SQL statement sample in sequence according to the field metadata information after the change operation to obtain a corresponding implicit type conversion risk prediction result for the associated field, realizing the risk prediction of the DDL change operation through the implicit type conversion risk prediction result for the associated field, thereby improving the reliability of the test environment for executing the DDL change operation, reducing the loss of system performance, solving the risk of implicit type conversion of associated fields caused by the table field metadata modification operation, avoiding the index invalidation caused by the risk of implicit type conversion of associated fields, and ensuring the security and stability of database changes. Description of the Drawings
[0024] Figure 1 It is an application environment diagram of the risk prediction method for DDL change operations in an embodiment;
[0025] Figure 2 It is a first process schematic diagram of the risk prediction method for DDL change operations in an embodiment;
[0026] Figure 3Schematic diagram of the process for obtaining field metadata information before a change operation and field metadata information after a change operation in an embodiment;
[0027] Figure 4 Schematic diagram of the process for obtaining the database name of a DDL change table for a DDL change operation and a statistical table of SQL statement samples in an embodiment;
[0028] Figure 5 Second schematic diagram of the risk prediction method for DDL change operations in an embodiment;
[0029] Figure 6 Third schematic diagram of the risk prediction method for DDL change operations in an embodiment;
[0030] Figure 7 Block diagram of the structure of a risk prediction device for DDL change operations in an embodiment;
[0031] Figure 8 Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0032] In order to make the objectives, technical solutions, and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0033] To facilitate the understanding of the present application, the present application will be described more comprehensively below with reference to the relevant accompanying drawings. Embodiments of the present application are given in the accompanying drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.
[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs. The terms used in the description of the present application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application.
[0035] It can be understood that the terms "first", "second", etc. used in the present application can be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of the present application, the first resistor can be called the second resistor, and similarly, the second resistor can be called the first resistor. Both the first resistor and the second resistor are resistors, but they are not the same resistor.
[0036] It can be understood that for the "connection" in the following embodiments, if there is transmission of electrical signals or data between the connected circuits, modules, units, etc., it should be understood as "electrical connection", "communication connection", etc.
[0037] As used herein, the singular forms "a", "an" and "the" may also include the plural forms unless the context clearly dictates otherwise. It should also be understood that the terms "comprises / include" or "has" etc. specify the presence of the stated features, wholes, steps, operations, components, parts or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof.
[0038] The risk prediction method for DDL change operations provided by this application can be applied to, for example, Figure 1 the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. Among them, the terminal 102 can be but is not limited to various personal computers, laptop computers, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.
[0039] In one embodiment, as Figure 2 shown, a risk prediction method for DDL change operations is provided. Taking the method applied to Figure 1 the server 104 as an example for illustration, it includes the following steps:
[0040] Step 201, in response to receiving the operation statement of the DDL change operation, determine the operation type of the DDL change operation according to the operation statement.
[0041] Among them, the operation type includes table field metadata modification operation or index deletion operation. When the server 104 recognizes that it has received the operation statement of the DDL change operation, it determines the operation type of the DDL change operation according to the operation statement.
[0042] In one of the embodiments, the table field metadata modification operation includes field type modification operation, character set modification operation and collation rule modification operation.
[0043] Step 202, in response to the operation type being a table field metadata modification operation, obtain the field metadata information before the change operation and the field metadata information after the change operation, and obtain a comparison result after comparing the field metadata information before the change operation and the field metadata information after the change operation.
[0044] Among them, the comparison result includes that the data information is the same or the data information is different. Specifically, when the server 104 recognizes that the operation type is a table field metadata modification operation, it obtains the field metadata information before the change operation and the field metadata information after the change operation, and obtains the comparison result after comparing the field metadata information before the change operation and the field metadata information after the change operation.
[0045] In one embodiment, as Figure 3 shown, obtaining the field metadata information before the change operation and the field metadata information after the change operation includes step 301 and step 302.
[0046] Step 301, parse the operation statement to obtain the field metadata information before the change operation.
[0047] Step 302, obtain the DDL change table, and obtain the field metadata information after the change operation after parsing the DDL change table.
[0048] Among them, the field metadata information before the change operation includes the field type before the change operation, the character set before the change operation, and the collation rule before the change operation; the field metadata information after the change operation includes the field type after the change operation, the character set after the change operation, and the collation rule after the change operation.
[0049] Specifically, the server 104 parses the operation statement to obtain the field metadata information before the change operation; then, it obtains the DDL change table, and obtains the field metadata information after the change operation after parsing the DDL change table, so as to facilitate obtaining the comparison result after comparing the field metadata information before the change operation and the field metadata information after the change operation, and also facilitate determining whether to start the implicit type conversion risk diagnosis of related fields according to the comparison result, improving the efficiency and convenience of risk prediction for DDL change operations.
[0050] In this embodiment, the operation statement is parsed to obtain the field metadata information before the change operation; then, the DDL change table is obtained, and the field metadata information after the change operation is obtained after parsing the DDL change table, so as to facilitate obtaining the comparison result after comparing the field metadata information before the change operation and the field metadata information after the change operation, and also facilitate determining whether to start the implicit type conversion risk diagnosis of related fields according to the comparison result, improving the efficiency and convenience of risk prediction for DDL change operations.
[0051] Step 203, in response to the comparison result being that the data information is different, obtain the database name of the DDL change table of the DDL change operation and the SQL statement sample statistics table, and query the SQL statement sample statistics table according to the database name to obtain the SQL statement sample set.
[0052] Among them, the SQL statement sample statistics table is used to store all SQL statement samples in the full database; the SQL statement sample set includes each target SQL statement sample; the target SQL statement sample is an SQL statement sample that references the DDL change table.
[0053] Specifically, when the server 104 identifies that the comparison result is that the data information is different, it indicates that the DDL change operation is successful at this time, and the implicit type conversion risk diagnosis of the associated fields can be started. Therefore, the database name of the DDL change table for the DDL change operation and the SQL statement sample statistics table are obtained, and the SQL statement sample set is obtained after querying the SQL statement sample statistics table according to the database name.
[0054] In a specific example, the method further includes:
[0055] In response to the comparison result being that the data information is the same, an operation failure prompt message is output; among them, the operation failure prompt message is used to indicate that the DDL change operation fails. The above is only a specific example, and it is flexibly set according to user needs in actual applications.
[0056] In one of the embodiments, as Figure 4 shown, obtaining the database name of the DDL change table for the DDL change operation and the SQL statement sample statistics table includes steps 401 to 402.
[0057] Step 401, collect all SQL statement samples in the full database;
[0058] Step 402, store each SQL statement sample into the SQL statement sample statistics table.
[0059] Specifically, the server 104 collects all SQL statement samples in the full database; then, each SQL statement sample is stored into the SQL statement sample statistics table, which improves the coverage of the samples and thus improves the accuracy of the risk prediction of the DDL change operation.
[0060] In this embodiment, all SQL statement samples in the full database are collected; then, each SQL statement sample is stored into the SQL statement sample statistics table, which improves the coverage of the samples and thus improves the accuracy of the risk prediction of the DDL change operation.
[0061] Step 204, perform implicit type conversion risk diagnosis of the associated fields on each target SQL statement sample in turn according to the field metadata information after the change operation to obtain the corresponding implicit type conversion risk prediction result of the associated fields. In addition, the risks of the DDL change operation include implicit type conversion risk of associated fields and index deletion risk.
[0062] In the above risk prediction method for DDL change operations, in response to receiving an operation statement of a DDL change operation, the operation type of the DDL change operation is determined according to the operation statement; the operation type includes a table field metadata modification operation or an index deletion operation; then, in response to the operation type being a table field metadata modification operation, the field metadata information before the change operation and the field metadata information after the change operation are obtained, and a comparison result is obtained after comparing the field metadata information before the change operation and the field metadata information after the change operation; the comparison result includes that the data information is the same or the data information is different; and, in response to the comparison result being that the data information is different, the database name of the DDL change table of the DDL change operation and the SQL statement sample statistical table are obtained, and a SQL statement sample set is obtained by querying the SQL statement sample statistical table according to the database name; the SQL statement sample statistical table is used to store all SQL statement samples in the full database; the SQL statement sample set includes each target SQL statement sample; the target SQL statement sample is a SQL statement sample that references the DDL change table; then, the associated field implicit type conversion risk diagnosis is performed on each target SQL statement sample in turn according to the field metadata information after the change operation, and the corresponding associated field implicit type conversion risk prediction result is obtained, realizing the risk prediction of the DDL change operation through the associated field implicit type conversion risk prediction result, thereby improving the reliability of the test environment for executing the DDL change operation, reducing the loss of system performance, solving the associated field implicit type conversion risk caused by the table field metadata modification operation, avoiding the index invalidation caused by the occurrence of the associated field implicit type conversion risk, and ensuring the security and stability of the database change.
[0063] In one embodiment, as Figure 5 shown, the method further includes steps 501 to 503.
[0064] Step 501, in response to the operation type being an index deletion operation, obtain the database name, query the SQL statement sample statistical table according to the database name to obtain a SQL statement sample set, and obtain the execution plan of the SQL statement sample set;
[0065] Step 502, parse and process the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation;
[0066] Step 503, perform index deletion risk diagnosis on each target SQL statement sample in turn according to the index name and the execution plan to obtain the corresponding index deletion risk prediction result.
[0067] Specifically, in response to an operation type being an index deletion operation, the server 104 obtains the database name, queries the SQL statement sample statistics table based on the database name to obtain a set of SQL statement samples, and obtains the execution plan of the set of SQL statement samples; then, it parses and processes the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation; next, it sequentially performs index deletion risk diagnosis on each target SQL statement sample according to the index name and the execution plan to obtain the corresponding index deletion risk prediction result, realizing the evaluation of the impact of the index deletion operation, thereby effectively avoiding the accidental deletion of indexes that are in use, avoiding the degradation of the execution performance of SQL statement samples caused by index production operations, and ensuring the security and stability of database changes.
[0068] In this embodiment, in response to an operation type being an index deletion operation, the server 104 obtains the database name, queries the SQL statement sample statistics table based on the database name to obtain a set of SQL statement samples, and obtains the execution plan of the set of SQL statement samples; then, it parses and processes the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation; next, it sequentially performs index deletion risk diagnosis on each target SQL statement sample according to the index name and the execution plan to obtain the corresponding index deletion risk prediction result, realizing the evaluation of the impact of the index deletion operation, thereby effectively avoiding the accidental deletion of indexes that are in use, avoiding the degradation of the execution performance of SQL statement samples caused by index production operations, and ensuring the security and stability of database changes.
[0069] In one embodiment, as Figure 6 shown, the associated field implicit type conversion risk prediction result includes a prediction result of the existence of an associated field implicit type conversion risk or the non - existence of an associated field implicit type conversion risk; the index deletion risk prediction result includes the existence of an index deletion risk or the non - existence of an index deletion risk; wherein, the method further includes step 601 and step 602.
[0070] Step 601, output an associated field implicit type conversion risk prompt message according to each associated field implicit type conversion risk prediction result;
[0071] Step 602, output an index deletion risk prompt message according to each index deletion risk prediction result.
[0072] Specifically, the server 104 outputs an associated field implicit type conversion risk prompt message according to each associated field implicit type conversion risk prediction result; then, it outputs an index deletion risk prompt message according to each index deletion risk prediction result, so that the staff can confirm whether to continue executing the DDL change operation according to the associated field implicit type conversion risk prompt message and the index deletion risk prompt message.
[0073] In this embodiment, association field implicit type conversion risk prompt information is output according to the risk prediction results of each association field implicit type conversion; then, index deletion risk prompt information is output according to the risk prediction results of each index deletion, so that the staff can confirm whether to continue to execute the DDL change operation according to the association field implicit type conversion risk prompt information and the index deletion risk prompt information.
[0074] In one embodiment, as Figure 6 shown, the method further includes step 603 and step 604.
[0075] Step 603, displaying the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion on the risk prediction result display interface of the DDL change operation;
[0076] Step 604, generating a risk assessment report according to the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion.
[0077] Specifically, the server 104 displays the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion on the risk prediction result display interface of the DDL change operation; then, a risk assessment report is generated according to the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion, which is convenient for risk display, assists the user to make a full risk assessment and decision before performing the DDL change operation, and avoids database performance problems caused by the DDL change operation.
[0078] In this embodiment, the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion are displayed on the risk prediction result display interface of the DDL change operation; then, a risk assessment report is generated according to the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion, which is convenient for risk display, assists the user to make a full risk assessment and decision before performing the DDL change operation, and avoids database performance problems caused by the DDL change operation.
[0079] In one embodiment, after displaying the risk prediction results of each association field implicit type conversion and / or the risk prediction results of each index deletion on the risk prediction result display interface of the DDL change operation, it further includes:
[0080] Responding to a confirmation operation on the DDL change operation, executing the operation statement;
[0081] Responding to a denial operation on the DDL change operation, prohibiting the execution of the operation statement.
[0082] In a specific example, the operation statement of the DDL change operation is: "
[0083] ALTER TABLE configservice.simple business config
[0084] MODIFY COLUMN config varchar(200) COLLATE Utf8mb4 bin NOT NULL COMMENT 'Configuration KEY'
[0085] DROP KEY 'uk_config'
[0086] The operation statement of this DDL change operation has changed the collation of the config field, from utf8mb4_general_ci to utf8mb4_bin, which is the metadata information of the changed table, and at the same time deleted the index uk_config.
[0087] The implicit type conversion risk prompt information of the associated fields output according to the prediction results of the implicit type conversion risks of each associated field is shown in the following table:
[0088]
[0089]
[0090] Specifically, take the target SQL statement sample corresponding to the source SQL link 2 as "
[0091] select
[0092] s.config
[0093] s.config_name,
[0094] s.owner_application,
[0095] v.value,
[0096] v.version,
[0097] from
[0098] simple_business_config s
[0099] left join simple_business_config_value v on s.config = v.config"
[0100] It can be seen that since the collation rule of the config field in the simple_business_config in the change table is utf8mb4_bin, while the collation rule of the associated field config in its associated table simple_business_config_value is utf8mb4_general_ci. Then, the user is reminded that for the condition: s.config = v.config, the types / character sets on both sides of the expression are inconsistent
Left: s.config(varchar(200), utf8mb4_bin), Right: v.config(varchar(200), utf8mb4_general_ci)
[0101] The index deletion risk prompt information output according to the results of each index deletion risk prediction is shown in the following table:
[0102]
[0103]
[0104] Specifically, take the target SQL statement sample corresponding to the source SQL link 4 as "
[0105] select
[0106] count(a.id)
[0107] from
[0108] application simple business_config a
[0109] left join simple business_config s on a.config = s.config
[0110] where
[0111] a.application = 'pageprobe
[0112] and s.config not in(
[0113] probe token'
[0114] probe logon url'
[0115] probe ignored url regex',
[0116] probe_token_expired request url
[0117] probe partition number'
[0118] probe navigate refresh'
[0119] probe screenshot'
[0120] and s.source = 0”.
[0121] Specifically, the execution plans for obtaining the SQL statement sample set are shown in the following table:
[0122]
[0123]
[0124] According to the index name and the execution plan, index deletion risk diagnosis is performed on each target SQL statement sample in sequence. It can be directly obtained that the deleted index uk_config will be used in the query of the target SQL statement sample. The above is only a specific example, and it is flexibly set according to user needs in actual applications and is not limited here.
[0125] It should be understood that although Figure 2-6 the steps in the flowchart of Figure 2-6 are shown in sequence according to the arrows, these steps do not necessarily execute in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover,
[0126] In a second aspect, as Figure 7 shown, a risk prediction device for DDL change operations is provided. The method includes an operation type determination module 710, an information comparison module 720, a sample set generation module 730, and a risk diagnosis module 740.
[0127] Among them, the operation type determination module 710 is used to determine the operation type of the DDL change operation according to the operation statement in response to receiving the operation statement of the DDL change operation; the operation type includes the table field metadata modification operation or the index deletion operation; the information comparison module 720 is used to obtain the field metadata information before the change operation and the field metadata information after the change operation in response to the operation type being the table field metadata modification operation, and compare the field metadata information before the change operation and the field metadata information after the change operation to obtain a comparison result; the comparison result includes that the data information is the same or the data information is different; the sample set generation module 730 is used to obtain the database name of the DDL change table of the DDL change operation and the SQL statement sample statistics table in response to the comparison result being that the data information is different, and query the SQL statement sample statistics table according to the database name to obtain a SQL statement sample set; the SQL statement sample statistics table is used to store all SQL statement samples in the full database; the SQL statement sample set includes each target SQL statement sample; the target SQL statement sample is a SQL statement sample that references the DDL change table; the risk diagnosis module 740 is used to perform an implicit type conversion risk diagnosis on the associated fields of each target SQL statement sample in turn according to the field metadata information after the change operation to obtain a corresponding implicit type conversion risk prediction result for the associated fields.
[0128] In one embodiment, the risk diagnosis module 740 is used to obtain the database name in response to the operation type being the index deletion operation, query the SQL statement sample statistics table according to the database name to obtain a SQL statement sample set, and obtain the execution plan of the SQL statement sample set; the risk diagnosis module 740 is used to parse and process the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation; the risk diagnosis module 740 is used to perform an index deletion risk diagnosis on each target SQL statement sample in turn according to the index name and the execution plan to obtain a corresponding index deletion risk prediction result.
[0129] In one embodiment, the implicit type conversion risk prediction result for the associated fields includes that there is an implicit type conversion risk for the associated fields or there is no implicit type conversion risk prediction result for the associated fields; the index deletion risk prediction result includes that there is an index deletion risk or there is no index deletion risk; among them, the device further includes a risk prompt module.
[0130] Among them, the risk prompt module is used to output an implicit type conversion risk prompt information for the associated fields according to each implicit type conversion risk prediction result for the associated fields; the risk prompt module is used to output an index deletion risk prompt information according to each index deletion risk prediction result.
[0131] In one embodiment, the risk warning module is configured to display the implicit type conversion risk prediction results of each associated field and / or the index deletion risk prediction results on the risk prediction result display interface of the DDL change operation; the risk warning module is configured to generate a risk assessment report according to the implicit type conversion risk prediction results of each associated field and / or the index deletion risk prediction results.
[0132] In one embodiment, the table field metadata modification operation includes a field type modification operation, a character set modification operation, and a collation modification operation.
[0133] In one embodiment, the information comparison module 720 includes an information comparison unit.
[0134] Among them, the information comparison unit is configured to parse the operation statement to obtain the field metadata information before the change operation; the field metadata information before the change operation includes the field type before the change operation, the character set before the change operation, and the collation before the change operation; the information comparison unit is configured to obtain the DDL change table, and obtain the field metadata information after the change operation after parsing the DDL change table; the field metadata information after the change operation includes the field type after the change operation, the character set after the change operation, and the collation after the change operation.
[0135] In one embodiment, the sample set generation module 730 includes a statistical table generation unit.
[0136] Among them, the statistical table generation unit is configured to collect all SQL statement samples in the full database; the statistical table generation unit is configured to store each SQL statement sample in the SQL statement sample statistical table.
[0137] For the specific limitations of the risk prediction device for DDL change operations, reference can be made to the limitations of the risk prediction method for DDL change operations in the foregoing, which will not be elaborated here. Each module in the above-mentioned risk prediction device for DDL change operations can be implemented in whole or in part by software, hardware, and their combinations. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or stored in the memory of the computer device in the form of software, so as to facilitate the processor to call and execute the operations corresponding to the above-mentioned modules.
[0138] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as Figure 8As shown in the figure. The computer device includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data of the SQL statement sample statistical table. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a risk prediction method for DDL change operations.
[0139] Those skilled in the art can understand that Figure 8 the structure shown in the figure is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0140] In a third aspect, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, it implements the steps of any one of the methods in the above method embodiments.
[0141] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program. When the computer program is executed by the processor, it implements the steps of any one of the methods in the above method embodiments.
[0142] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0143] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0144] The above-described embodiments merely represent several implementation manners of the present application. Their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A risk prediction method for a DDL change operation, the method comprising: In response to receiving an operation statement of a DDL change operation, determining an operation type of the DDL change operation according to the operation statement; The operation type includes a table field metadata modification operation or an index deletion operation; In response to the operation type being the table field metadata modification operation, obtaining field metadata information before the change operation and field metadata information after the change operation, and comparing the field metadata information before the change operation and the field metadata information after the change operation to obtain a comparison result; the comparison result includes that the data information is the same or that the data information is not the same; In response to the comparison result that the data information is different, obtaining a database name and an SQL statement sample statistical table of the DDL change table of the DDL change operation, and querying the SQL statement sample statistical table according to the database name to obtain a SQL statement sample set; the SQL statement sample statistical table is used to store all SQL statement samples in the full database; The SQL statement sample set includes each target SQL statement sample; The target SQL statement sample is the SQL statement sample that references the DDL change table; According to the field metadata information after the change operation, the risk diagnosis of implicit type conversion of associated fields is performed on each of the target SQL statement samples in turn to obtain the corresponding prediction result of implicit type conversion risk of associated fields.
2. The method according to claim 1, characterized in that The method further comprises: In response to the operation type being the index deletion operation, obtaining the database name, querying the SQL statement sample statistics table according to the database name to obtain the SQL statement sample set, and obtaining an execution plan of the SQL statement sample set; Parsing the operation statement corresponding to the index deletion operation to obtain the index name of the index deletion operation; According to the index name and the execution plan, index deletion risk diagnosis is performed on each target SQL statement sample in turn to obtain a corresponding index deletion risk prediction result.
3. The method according to claim 2, characterized in that The prediction result of the risk of implicit type conversion of the associated field includes a prediction result of whether there is a risk of implicit type conversion of the associated field or there is no risk of implicit type conversion of the associated field; The index deletion risk prediction result includes whether there is an index deletion risk or there is no index deletion risk; wherein the method further includes: Outputting associated field implicit type conversion risk warning information according to the associated field implicit type conversion risk prediction result; Output index deletion risk warning information according to each of the index deletion risk prediction results.
4. The method according to claim 3, characterized in that The method further comprises: Displaying the risk prediction results of implicit type conversion of each associated field and / or the risk prediction results of each index deletion on the risk prediction result display interface of the DDL change operation; A risk assessment report is generated based on the implicit type conversion risk prediction results of each associated field and / or the index deletion risk prediction results.
5. The method according to claim 1, characterized in that The table field metadata modification operation includes a field type modification operation, a character set modification operation, and a sort rule modification operation.
6. The method according to claim 1, characterized in that The obtaining of the field metadata information before the change operation and the field metadata information after the change operation includes: The operation statement is parsed to obtain the field metadata information before the change operation; the field metadata information before the change operation includes the field type before the change operation, the character set before the change operation, and the sorting rule before the change operation; The DDL change table is obtained, and the field metadata information after the change operation is obtained after parsing the DDL change table; the field metadata information after the change operation includes the field type after the change operation, the character set after the change operation, and the sorting rule after the change operation.
7. The method according to claim 1, characterized in that The step of obtaining the database name and SQL statement sample statistics table of the DDL change table of the DDL change operation includes: Collect all the SQL statement samples in the full database; Each of the SQL statement samples is stored in the SQL statement sample statistics table.
8. A risk prediction device for DDL change operation, characterized in that: The method comprises: An operation type determination module, configured to, in response to receiving an operation statement of a DDL change operation, determine an operation type of the DDL change operation according to the operation statement; the operation type includes a table field metadata modification operation or an index deletion operation; an information comparison module, configured to, in response to the operation type being the table field metadata modification operation, obtain field metadata information before the change operation and field metadata information after the change operation, and compare the field metadata information before the change operation and the field metadata information after the change operation to obtain a comparison result; the comparison result includes that the data information is the same or that the data information is not the same; A sample set generation module is used for obtaining the database name and SQL statement sample statistics table of the DDL change table of the DDL change operation in response to the comparison result that the data information is different, and obtaining the SQL statement sample set after querying the SQL statement sample statistics table according to the database name; the SQL statement sample statistics table is used to store all SQL statement samples in the full database; the SQL statement sample set includes each target SQL statement sample; the target SQL statement sample is the SQL statement sample that references the DDL change table; The risk diagnosis module is used to perform risk diagnosis of implicit type conversion of associated fields on each of the target SQL statement samples in turn according to the field metadata information after the change operation, and obtain corresponding prediction results of implicit type conversion risks of associated fields.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Adaptive detection processing method and system for database DDL change
CN122450957A