SQL (Structured Query Language) file splitting method and device

By defining statement rules and keyword lists in the SQL file, and combining contextual relationships and auxiliary stack processing, the accuracy and fault tolerance issues of SQL file splitting in existing technologies are solved, achieving more efficient SQL statement recognition and database migration optimization.

CN121658495APending Publication Date: 2026-03-13HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-11
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing SQL file splitting technologies have poor accuracy and fault tolerance when dealing with complex scenarios, and are difficult to effectively identify and split independent statements in complex SQL files.

Method used

By using predefined statement rules and keyword lists, combined with the contextual relationships of keywords, the independent statements in the SQL file are determined by keyword matching. An auxiliary stack is used to handle nested structures, reducing rule complexity and improving splitting accuracy and fault tolerance.

Benefits of technology

It improves the accuracy and fault tolerance of splitting SQL statements from complex SQL files, can more accurately identify independent statements, supports scalability for different database types, and optimizes database migration strategies to improve migration efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121658495A_ABST
    Figure CN121658495A_ABST
Patent Text Reader

Abstract

The invention provides an SQL file splitting method and device, and the method comprises the steps: obtaining first information according to an SQL file, the first information comprises a plurality of keywords in the SQL file and the position of each keyword in the SQL file; according to a plurality of statement rules and the first information, a plurality of first keywords are determined from a plurality of keywords, each statement rule comprises a plurality of rule keywords and a context relationship among the rule keywords, and each first keyword is the same as the corresponding rule keyword in content; the position of the first keyword in the SQL file accords with a context relationship among a plurality of rule keywords of the first statement rule; and splitting the SQL file according to the plurality of first keywords and the positions of the plurality of first keywords in the SQL file. According to the method, SQL statement matching can be performed according to the statement rule defined in advance, so that the independent SQL statements in the complex SQL file can be determined more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing, and more specifically, to a method and apparatus for splitting Structured Query Language (SQL) statements. Background Technology

[0002] In the process of database replacement and migration, architecture migration and application migration are crucial steps. SQL files in the database or application are an important component of architecture migration. To evaluate, transform, and audit SQL files, the first task is to break down complex SQL files, correctly identify the individual SQL statements, and then perform a series of subsequent processing on each SQL statement.

[0003] Existing SQL file splitting techniques rely on SQL parsers or regular expression matching, which can only handle a limited number of simple scenarios or have poor fault tolerance when dealing with complex scenarios. Therefore, improving the accuracy of splitting SQL statements from complex SQL files has become an urgent technical problem to be solved. Summary of the Invention

[0004] This application provides a method and apparatus for splitting SQL files, which can match SQL statements according to predefined statement rules, thereby more accurately identifying independent SQL statements in complex SQL files.

[0005] Firstly, a method for splitting an SQL file is provided. This method includes: obtaining first information based on the SQL file, the first information including multiple keywords in the SQL file and the position of each keyword in the SQL file; determining multiple first keywords from the multiple keywords based on multiple statement rules and the first information, wherein each statement rule includes multiple rule keywords and the contextual relationship between the multiple rule keywords, the multiple first keywords correspond one-to-one with the multiple rule keywords of the first statement rule in the multiple statement rules, each first keyword has the same content as its corresponding rule keyword, and the positions of the multiple first keywords in the SQL file conform to the contextual relationship between the multiple rule keywords of the first statement rule; and splitting the SQL file based on the multiple first keywords and their positions in the SQL file.

[0006] According to the technical solution provided in this application, by including specific keywords and the contextual relationships between keywords in the predefined statement rules, the complexity of the statement rules can be reduced. This allows for the matching and determination of SQL statements in the SQL file that conform to the statement rules through keyword comparison, thereby improving the accuracy of splitting SQL statements from complex SQL files.

[0007] In conjunction with the first aspect, in some implementations of the first aspect, obtaining the first information based on the SQL file includes: determining multiple keywords from the SQL file based on the keyword list and the SQL file, wherein the keyword list includes at least multiple rule keywords; and determining the positions of the multiple keywords in the SQL file based on the multiple keywords.

[0008] According to the above technical solution, by defining a keyword list, specific keywords in the SQL file are extracted only from the keyword list for matching with statement rules. This allows syntax errors in the SQL file that do not affect the statement structure to be ignored without affecting the splitting results of other statements, thereby improving the fault tolerance of SQL file splitting.

[0009] In conjunction with the first aspect, in certain implementations of the first aspect, determining multiple first keywords from multiple keywords based on multiple statement rules and first information includes: determining a second keyword and at least one candidate statement rule from multiple statement rules, wherein the first rule keyword of each candidate statement rule is the same as the content of the second keyword; determining at least one fourth keyword from at least one third keyword based on the first information, and determining a first statement rule from at least one candidate statement rule, wherein at least one third keyword is a keyword among multiple keywords, and at least one third keyword is located after the second keyword in the SQL file, the content and position of the second keyword and at least one fourth keyword conform to the first statement rule, and the multiple first keywords include the second keyword and at least one fourth keyword.

[0010] According to the above technical solution, by traversing the keywords in the SQL file and matching each keyword with the statement rules, the rule matching algorithm does not need to be adjusted according to the specific content of the statement rules. It only needs to adjust the preset keyword list and statement rules for different database types, thereby improving the scalability of the SQL file splitting method.

[0011] In conjunction with the first aspect, in certain implementations of the first aspect, the rule keywords of the first statement rule include a pair of first rule keywords and second rule keywords. Based on the first information, at least one fourth keyword is determined from at least one third keyword, and the first statement rule is determined from at least one candidate statement rule, including: determining a fifth keyword from at least one third keyword, wherein the fifth keyword has the same content as the first rule keyword; determining a sixth keyword from at least one third keyword based on the fifth keyword, wherein the sixth keyword has the same content as the second rule keyword, and the positions of the fifth and sixth keywords in the SQL file include an equal number of N seventh keywords and N eighth keywords, each seventh keyword having the same content as the first rule keyword, and each eighth keyword having the same content as the second rule keyword, where N is an integer greater than or equal to 0; and determining at least one fourth keyword, wherein the at least one fourth keyword includes the fifth and sixth keywords.

[0012] Based on the above technical solution, an auxiliary stack is used to handle the nested structures that may occur in SQL statements, reducing the possibility of incorrect or misaligned paired keywords, thereby improving the accuracy of the SQL file splitting method.

[0013] In conjunction with the first aspect, in some implementations of the first aspect, the SQL file is split according to multiple first keywords and their positions in the SQL file, including: determining the first SQL statement, the end of the first SQL statement being the last first keyword among multiple first keywords.

[0014] According to the above technical solution, after a statement is successfully matched, the last keyword of the statement is recorded. Based on the position of the last keyword of each statement, the SQL file is split into multiple independent SQL statements, reducing the complexity of SQL file splitting.

[0015] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: determining multiple tenth keywords from multiple ninth keywords based on multiple statement rules and first information, wherein the multiple ninth keywords are keywords among multiple keywords, and the multiple ninth keywords are located after multiple first keywords in the SQL file; the multiple tenth keywords correspond one-to-one with multiple rule keywords of the second statement rules among the multiple statement rules; each tenth keyword has the same content as the corresponding rule keyword; and the positions of the multiple tenth keywords in the SQL file conform to the contextual relationship between the multiple rule keywords of the second statement rules; determining a second SQL statement, the end of the second SQL statement being the last tenth keyword among the multiple tenth keywords.

[0016] According to the above technical solution, after a statement is successfully matched, the next statement is matched from the keywords after the last keyword of that statement. This avoids matching errors caused by duplicate or missed keyword matching, thereby improving the accuracy of the SQL file splitting method.

[0017] In conjunction with the first aspect, in some implementations of the first aspect, the SQL file includes SQL statements for operating the database to be migrated, and the method further includes: determining the type of at least one object in the database to be migrated based on the result of splitting the SQL file; and migrating at least one object from the database to be migrated to the target database based on the type of the at least one object.

[0018] According to the above technical solution, the SQL statements extracted from the SQL file can be used to determine the type of objects in the database, thereby determining a better database migration strategy based on the type of objects. For example, determining the migration order of multiple objects of different types, or batch processing multiple objects of the same type, thereby improving the database migration efficiency.

[0019] Secondly, an apparatus for splitting an SQL file is provided. The apparatus includes: an extraction module for obtaining first information based on the SQL file, the first information including multiple keywords in the SQL file and the position of each keyword in the SQL file; a matching module for determining multiple first keywords from the multiple keywords based on multiple statement rules and the first information, wherein each statement rule includes multiple rule keywords and the contextual relationship between the multiple rule keywords, the multiple first keywords correspond one-to-one with the multiple rule keywords of the first statement rule in the multiple statement rules, each first keyword has the same content as its corresponding rule keyword, and the positions of the multiple first keywords in the SQL file conform to the contextual relationship between the multiple rule keywords of the first statement rule; and a splitting module for splitting the SQL file based on the multiple first keywords and their positions in the SQL file.

[0020] In conjunction with the second aspect, in some implementations of the second aspect, the extraction module is specifically used to: determine multiple keywords from the SQL file based on the keyword list and the SQL file, wherein the keyword list includes at least multiple rule keywords; and determine the positions of the multiple keywords in the SQL file based on the multiple keywords.

[0021] In conjunction with the second aspect, in some implementations of the second aspect, the matching module is specifically used to: determine a second key and at least one candidate statement rule among multiple statement rules, wherein the first rule key of each candidate statement rule is the same as the content of the second key; determine at least one fourth key from at least one third key according to the first information, and determine a first statement rule from at least one candidate statement rule, wherein at least one third key is a key among multiple keys, and at least one third key is located after the second key in the SQL file, the content and position of the second key and at least one fourth key conform to the first statement rule, and the multiple first keys include the second key and at least one fourth key.

[0022] In conjunction with the second aspect, in some implementations of the second aspect, the rule keywords of the first statement rule include a pair of first rule keywords and second rule keywords. The matching module is specifically used to: determine a fifth keyword from at least one third keyword, the fifth keyword being identical to the content of the first rule keyword; determine a sixth keyword from at least one third keyword based on the fifth keyword, the sixth keyword being identical to the content of the second rule keyword, and the positions of the fifth and sixth keywords in the SQL file include an equal number of N seventh keywords and N eighth keywords, each seventh keyword being identical to the content of the first rule keyword, each eighth keyword being identical to the content of the second rule keyword, where N is an integer greater than or equal to 0; and determine at least one fourth keyword, the at least one fourth keyword including the fifth and sixth keywords.

[0023] In conjunction with the second aspect, in some implementations of the second aspect, the split module is specifically used to: determine the first SQL statement, the end of the first SQL statement being the last first keyword among multiple first keywords.

[0024] In conjunction with the second aspect, in some implementations of the second aspect, the matching module is further configured to: determine multiple tenth keywords from multiple ninth keywords based on multiple statement rules and first information, wherein the multiple ninth keywords are keywords among multiple keywords, and the multiple ninth keywords are located after multiple first keywords in the SQL file, the multiple tenth keywords correspond one-to-one with multiple rule keywords of the second statement rules among the multiple statement rules, each tenth keyword has the same content as the corresponding rule keyword, and the positions of the multiple tenth keywords in the SQL file conform to the contextual relationship between the multiple rule keywords of the second statement rules; the splitting module is further configured to: determine the second SQL statement, the end of the second SQL statement being the last tenth keyword among the multiple tenth keywords.

[0025] In conjunction with the second aspect, in some implementations of the second aspect, the SQL file includes SQL statements for operating the database to be migrated, and the apparatus further includes a migration module for: determining the type of at least one object in the database to be migrated based on the result of splitting the SQL file; and migrating at least one object from the database to be migrated to the target database based on the type of the at least one object.

[0026] Thirdly, a computing device is provided, including a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, causing the computing device to perform the method of the first aspect or any possible implementation thereof.

[0027] Fourthly, a computing device cluster is provided, including at least one computing device, each computing device including a processor and a memory, wherein the memory is used to store instructions, and the processor is used to call and execute the instructions from the memory, causing the computing device cluster to perform the method in the first aspect or any possible implementation of the first aspect.

[0028] Optionally, the processor can be a general-purpose processor, which can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc.; when implemented in software, the processor can be a general-purpose processor that reads software code stored in memory, which can be integrated into the processor or exist independently outside the processor.

[0029] Fifthly, a chip is provided that acquires and executes instructions to implement the method in the first aspect or any possible implementation of the first aspect.

[0030] Optionally, as one implementation, the chip includes a processor and a data interface, through which the processor reads instructions stored in the memory and executes the method in the first aspect or any possible implementation of the first aspect.

[0031] Optionally, as one implementation, the chip may further include a memory storing instructions, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to perform the method in the first aspect or any possible implementation of the first aspect.

[0032] In a sixth aspect, a computer program product containing instructions is provided, which, when executed by a computing device or a cluster of computing devices, causes the computing device or the cluster of computing devices to perform the method described in the first aspect or any possible implementation thereof.

[0033] In a seventh aspect, a computer-readable storage medium is provided, including computer program instructions that, when executed by a computing device or a cluster of computing devices, cause the computing device or the cluster of computing devices to perform the method described in the first aspect or any possible implementation thereof.

[0034] As examples, these computer-readable storage media include, but are not limited to, one or more of the following: read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), flash memory, electrically EPROM (EEPROM), and hard drive.

[0035] Alternatively, as one implementation method, the aforementioned storage medium can specifically be a non-volatile storage medium. Attached Figure Description

[0036] Figure 1 This is a schematic flowchart illustrating SQL file splitting based on an SQL parser.

[0037] Figure 2 This is a schematic flowchart illustrating a method for splitting SQL files provided in an embodiment of this application.

[0038] Figure 3 This is a schematic diagram of a method for splitting SQL files provided in an embodiment of this application.

[0039] Figure 4 This is a schematic diagram of a method for splitting SQL files provided in an embodiment of this application.

[0040] Figure 5 This is a schematic structural block diagram of an SQL file splitting device provided in an embodiment of this application.

[0041] Figure 6 This is a schematic structural block diagram of a computing device provided in an embodiment of this application.

[0042] Figure 7 This is a schematic structural block diagram of a computing device cluster provided in an embodiment of this application.

[0043] Figure 8 This is a schematic structural block diagram of another computing device cluster provided in an embodiment of this application. Detailed Implementation

[0044] The technical solutions in this application will now be described with reference to the accompanying drawings.

[0045] This application will present various aspects, embodiments, or features relating to systems comprising multiple devices, components, modules, etc. It should be understood and appreciated that individual systems may include additional devices, components, modules, etc., and / or may not include all devices, components, modules, etc. discussed in conjunction with the accompanying drawings. Furthermore, combinations of these approaches are also possible.

[0046] Furthermore, in the embodiments of this application, the words "exemplary," "for example," etc., are used to indicate that they are examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the term "exemplary" is intended to present the concept in a concrete manner.

[0047] In the embodiments of this application, "corresponding" and "corresponding" can sometimes be used interchangeably. It should be noted that when the distinction is not emphasized, their intended meanings are consistent.

[0048] The network architecture and business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0049] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0050] In this application, "at least one" means one or more, and "more than one" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A alone, A and B simultaneously, and B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.

[0051] In the process of database replacement and migration, architecture migration and application migration are crucial steps. SQL files in the database or application are an important component of architecture migration. To evaluate, transform, and audit SQL files, the first task is to break down complex SQL files, correctly identify the individual SQL statements, and then perform a series of subsequent processing on each SQL statement.

[0052] Existing SQL file splitting techniques can be implemented using SQL parsers or regular expression matching.

[0053] SQL parsers can identify SQL files and extract individual SQL statements. The ability to identify SQL statements in a SQL file relies heavily on the parser's capabilities. If the parser is powerful enough, it can correctly identify and distinguish statements even in SQL files containing complex stored procedures and stored functions. However, in reality, the capabilities of most commonly used SQL parsers vary greatly, and no single parser can meet the needs of all scenarios. For example, some parsers only support the recognition of simple Data Manipulation Language (DML) statements and do not support user-defined grammar rules, limiting the types of statements they can recognize. Conversely, while some parsers support custom grammar rules, allowing users to define rules for the SQL statements to be parsed and then segment them, the sheer volume of work results in low segmentation efficiency.

[0054] Furthermore, SQL file splitting based on an SQL parser suffers from poor fault tolerance. A schematic flowchart of SQL file splitting based on an SQL parser is shown below. Figure 1As shown, the SQL parser needs to accurately match the expected lexical rules and then construct a parse tree based on the grammar rules. If the parse tree of the entire SQL file can be constructed successfully, the parsing is successful, and the SQL file can be correctly split. However, if unexpected lexical rules occur, the parse tree construction will fail, causing the parsing to stop and subsequent matches to fail.

[0055] SQL files can also be treated as regular text, and SQL statements can be identified and extracted using regular text processing techniques such as regular expression matching. SQL statements generally have a fixed format, such as ending with a semicolon. However, using only semicolons as delimiters to split SQL files is only suitable for simple single-statement SQL statements. When complex compound objects such as stored procedures and packages contain multiple statements, simple semicolon separation cannot yield complete statements. In such cases, regular expressions can be defined to match the format of stored procedures. However, due to the flexibility of SQL statements and the syntactic differences between different databases, regular expressions can only handle a very limited number of simple scenarios and have low fault tolerance. Unexpected content may cause problems with the entire subsequent matching process.

[0056] Therefore, improving the accuracy of splitting SQL statements from complex SQL files (including SQL files composed of multiple statements) has become an urgent technical problem to be solved.

[0057] This application provides a method and apparatus for splitting SQL files, which can match SQL statements according to predefined statement rules, thereby more easily and accurately identifying independent SQL statements in complex SQL files.

[0058] The following is combined Figure 2 This application describes in detail the method for splitting SQL files. For example... Figure 2 As shown, the method includes the following steps.

[0059] Step S210: Obtain the first information based on the SQL file.

[0060] Specifically, the first information may include multiple keywords in the SQL file and the position of each keyword in the SQL file. For example, in step S210, the computing device or cluster of computing devices may extract a keyword data stream from the SQL file. The keyword data stream records the keywords determined from the SQL file and records the position of each keyword in the SQL file. As an example and not a limitation, the position of a keyword in the SQL file can be represented by a combination of line number and line offset. For example, (6, 19) can indicate that the keyword is located on the 6th line of the SQL file, and the first character of the keyword is located at the 19th character position of the 6th line of the SQL file.

[0061] It should be understood that the term "keyword" appearing in the embodiments of this application can be a symbol, a word, or a combination of symbols and words. For example, symbols can include, but are not limited to, semicolons ";", single forward slashes " / ", asterisks "*", etc., and words can include, but are not limited to, "create", "function", "begin", "end", etc. Therefore, each keyword can consist of one or more characters.

[0062] Optionally, step S240, which preprocesses the SQL file, may be included before step S210. For example, through the preprocessing step, symbols and / or words that affect the determination of the SQL statement structure in the SQL file can be deleted according to specific rules. The deleted keywords will not be extracted into the keyword data stream in step S210. By ignoring the influence of some interference items that are unrelated to the statement structure, the accuracy of the SQL file splitting method is improved.

[0063] In some possible implementations, the keyword data stream extraction in step S210 can be performed based on a keyword list. For example, a computing device or cluster of computing devices can determine multiple keywords in the SQL file based on the keyword list and the SQL file, these keywords being identical to the keywords included in the keyword list; and based on these multiple keywords, determine the representation of the position of each keyword in the SQL file. The keyword list includes predefined keywords related to the SQL statement structure, which may include one or more rule keywords involved in the statement rules mentioned below, as well as other keywords outside the statement rules but related to the SQL statement structure. It should be understood that the keywords included in the keyword list can be adjusted according to the SQL file to be split, including but not limited to adjusting the keyword list according to the database type, adjusting the keyword list according to the function of the SQL file, adjusting the keyword list according to the type of objects involved in the statement rules, etc.

[0064] Step S220: Based on multiple statement rules and first information, determine multiple first keywords from multiple keywords.

[0065] For example, in step S220, the computing device or cluster of computing devices can traverse the keyword data stream extracted in S210, compare the keywords in the keyword data stream with the statement rules, and determine a set of keywords that can match a certain statement rule. Specifically, each statement rule can include its own rule keywords and the contextual relationships between these rule keywords. Multiple first keywords match the first statement rules in multiple statement rules. That is, multiple first keywords correspond one-to-one with multiple rule keywords in the first statement rule, each first keyword has the same content as the corresponding rule keyword, and the positions of the multiple first keywords in the SQL file conform to the contextual relationships between the multiple rule keywords described by the first statement rule.

[0066] As an example, let's use "A", "B", and "C" to abstractly represent three rule keywords. Suppose the content of a statement rule is "AB…C", then the three keywords matched from the keyword data stream that conform to this statement rule should satisfy the following: In order of their positions in the SQL file, the first keyword should contain "A", the second "B", and the third "C", and the first two keywords should be adjacent in the SQL file (i.e., there should be no other keywords between them), while the last two keywords can be separated by other keywords.

[0067] In some possible implementations, the multiple first keywords and their matching statement rules can be determined through keyword-by-keyword matching. For example, a second keyword can be determined as the starting point, which is identical to the first rule keyword of one or more candidate statement rules. Then, each candidate statement rule can be compared sequentially with the keywords following the second keyword in the keyword data stream until a candidate statement rule that can be completely matched, along with the corresponding keyword in the keyword data stream, is found.

[0068] Optionally, the matching process between candidate statement rules and keyword data streams can also be performed keyword by keyword. For example, for a candidate statement rule, starting from the second keyword, the process iterates keyword by keyword until a keyword matching the second rule keyword in the candidate statement rule is found. It is then determined whether the positional relationship between this keyword and the previously matched keyword in the SQL file satisfies the context requirements represented by the statement rule. If not, the matching of this statement rule is terminated, and the matching of the next statement rule begins; if so, the process continues to traverse the keyword data stream, and so on, matching the next keyword in the candidate statement. If all rule keywords in a candidate statement rule are successfully matched, the matching result is recorded. Optionally, the first keyword of the next statement can start from the keyword after the last keyword of the successfully matched statement.

[0069] In some possible implementations, an auxiliary stack can be used to handle the interference of nested pairs of keywords in the keyword data stream on the statement rule matching results. A pair of rule keywords appearing in a statement rule can include a first rule keyword and a second rule keyword. The first rule keyword indicates the beginning of a specific section in the corresponding SQL statement, and the second rule keyword indicates the end of that section. For example, "begin…end" represents a pair of rule keywords "begin" and "end," and "if…end" can also represent another pair of rule keywords "if" and "end." Other keywords from the SQL file can be included between the first and second rule keywords. In some cases, keywords matching the first and second rule keywords in the keyword data stream may appear nested. For example, the contextual relationship of some keywords in a keyword data stream might be "begin…begin…if…end;…end;…end;", which is a three-level nested structure. The first occurrence of "end" and "if" forms the innermost nested structure; the second occurrence of "end" and "begin" forms the second nested structure; and the third occurrence of "end" and "begin" forms the outermost nested structure. As another example, the contextual relationship of some keywords in a keyword data stream might be "begin…if…end;…if…end;…end;", which is a two-level nested structure. The first occurrence of "end" and "if" forms the first pair of keywords in the inner nested structure; the second occurrence of "end" and "if" forms the second pair of keywords in the inner nested structure; and the third occurrence of "end" and "begin" forms the outer nested structure.

[0070] In the above situation, without additional identification of nested structures, the first occurrence of "end" and the first occurrence of "begin" might be incorrectly identified as a pair of keywords, thus affecting subsequent matching results. Therefore, for paired rule keywords, after identifying the two keywords in the keyword data stream that match the paired keyword during the matching process, it is also possible to additionally determine the number of paired keywords between these two keywords. A match is successful only if the number of keywords between the two keywords that are identical to the content of the first rule keyword is the same as the number of keywords that are identical to the content of the second rule keyword; otherwise, the keyword data stream continues to be traversed. Optionally, the above judgment of nested structures can be based on an auxiliary stack structure.

[0071] Step S230: Split the SQL file based on the multiple primary keys and their positions in the SQL file.

[0072] For example, in step S230, a computing device or cluster of computing devices can extract independent SQL statements from the SQL file based on the identification result of step S220. As an example, and not a limitation, for each successfully matched set of keywords that can constitute an independent statement, the position of the last keyword in that set can be recorded. After the keyword data stream is traversed, the SQL file is split according to the position of the last keyword in each recorded statement, thus splitting the SQL file into one or more independent SQL statements.

[0073] By incorporating specific keywords and the contextual relationships between keywords into the predefined statement rules, the complexity of the syntax rules can be reduced. This allows for the matching and determination of SQL statements in the SQL file that conform to the statement rules through keyword comparison, thereby improving the accuracy of splitting SQL statements from complex SQL files.

[0074] The split SQL statements can be used to determine the types of objects in the database, thereby enabling evaluation and conversion based on these object types to determine a better database migration strategy and improve the efficiency of database migration. Optionally, the above method may also include steps S250 and S260.

[0075] Step S250: Based on the results of splitting the SQL file, determine the type of at least one object in the database to be migrated.

[0076] For example, in step S250, the database migration tool can determine the details of the objects in the database involved in the SQL file based on the individual SQL statements extracted from the SQL file. The object details may include the object type, which may include, but is not limited to, tables, indexes, views, packages, stored functions, stored procedures, triggers, etc. The object details may also include other information, such as the object's name, its acquisition status, its encryption status, etc., which are not specifically limited in this application.

[0077] Step S260: Based on the type of at least one object, migrate at least one object from the database to be migrated to the target database.

[0078] For example, in step S260, after determining the details of the objects in the database to be migrated, the database migration tool can evaluate and convert them according to their data types, thereby migrating the objects from the database to be migrated to the target database with a better strategy. Object evaluation and conversion may include, but are not limited to: analyzing the difficulty of database migration, batch processing objects of the same type in the database, and determining the migration order of different types of objects in the database.

[0079] In some possible implementations, database migration tools can determine the migration difficulty of each object based on its type, thereby providing users with a more accurate assessment report on database migration. For example, stored procedures and packages are more complex than tables and indexes, and therefore the corresponding assessment indicators, such as the level of transformation risk and the amount of migration workload, are also different. However, these specific assessment indicators cannot be directly determined based on the size of the SQL file. By splitting the SQL file into individual SQL statements and determining the type of each object, the assessment report provided to the user can be tailored to different object types, providing information such as the transformation risk and migration workload for each object, thus offering a more accurate and specific assessment report.

[0080] In other possible implementations, database migration tools can batch process the evaluation results of objects of the same type, thereby reducing repetitive and redundant operations and improving processing efficiency.

[0081] In other possible implementations, database migration tools can control the migration order of objects based on their types, thereby completing database migration tasks more efficiently. The migration process for different types of objects may have dependencies; for example, views, indexes, and triggers depend on table objects, and table objects depend on sequence objects. Therefore, during migration, sequences can be migrated first, followed by tables, and then views, indexes, and triggers, ensuring that the target database can be established and function correctly. Different types of objects may also have different impacts on migration efficiency. For example, indexes and triggers can affect data migration efficiency. Therefore, generally, the structure of table objects is migrated first, followed by the synchronization of existing data. After data synchronization is complete, indexes and triggers are created, thereby improving migration efficiency.

[0082] The following is combined Figure 3 and Figure 4 This paper describes the method for splitting SQL files provided by the technical solution of this application through specific embodiments.

[0083] As an example, and not a limitation, this refers to an SQL file for a specific type of database that may involve seven complex objects: package, packagebody, typebody, stored procedure, stored function, trigger, and anonymous block. For complex SQL statements related to these complex objects, the following statement rules can be configured:

[0084] The rule for statements used to create packages is: create package…is / as…end…;

[0085] The rule for the statement used to create the package body is: create package body…is / as…end…;

[0086] The rule for the statement used to create the typebody is: create typebody...is / as...end...;

[0087] A rule for statements used to create stored functions: create function...is / as [declare] begin...end;

[0088] Another rule for statements used to create stored functions: create function...is / as language / external...;

[0089] A rule for statements used to create stored procedures: create procedure...is / as [declare] begin...end;

[0090] Another rule for statements used to create stored procedures: create procedure...is / as language / external...;

[0091] A rule for statements used to create triggers: create trigger…begin…end…;

[0092] Another rule for statements used to create triggers: create trigger…call…;

[0093] Another rule for statements used to create triggers: create trigger…compound trigger…end…;

[0094] The statement rules for anonymous blocks are: [declare]...begin...end;

[0095] It should be understood that in this embodiment, the " / " appearing in the above statement rules represents "or". For example, "is / as" is a simplified representation of "is or as", meaning that the keyword at the corresponding position in the matched statement can be either the word "is" or the word "as". Similarly, "language / external" is a simplified representation of "language or external", meaning that the keyword at the corresponding position in the matched statement can be either the word "language" or the word "external". Square brackets "[]" indicate that the keyword may or may not appear in the corresponding position. For example, "[declare]" indicates that the word "declare" may or may not appear in the position specified by the statement rule. "…" represents any one or more keywords, meaning that the corresponding position in the matched statement can include any number of any keywords.

[0096] In addition, for single statements that do not meet the above statement rules, delimiters such as " / " and ";" can be defined.

[0097] like Figure 3As shown, based on the above statement rules, a keyword list can be defined to extract keywords from the SQL file. The keyword list can include the following keywords: "create", "package", "body", "type", "procedure", "function", "trigger", "declare", "begin", "end", "as", "is", "language", "external", "compound", "call", "grant", "revoke", "if", "loop", "case", "aggregate", "when", ";", and " / ".

[0098] Optionally, the file content can be preprocessed before extracting the keyword data stream from the SQL file based on the keyword list. Figure 3 In the example shown, the content of the first line of the SQL file conforms to the format of a predefined comment statement " / *…* / ". The symbol "--" in the fifth line indicates that the content following this line is comment content. Therefore, after preprocessing, the content of the first and fifth lines will be ignored when extracting keywords later.

[0099] like Figure 3 As shown, the words and / or symbols circled in the SQL file are keywords extracted from the keyword list. The content of each extracted keyword and its position in the SQL file are recorded in the order they appear, resulting in a keyword data stream. This keyword data stream is then traversed and matched against the aforementioned statement rules to obtain the statement splitting result of the SQL file.

[0100] The specific process of the above matching steps can be described as follows: Figure 4 As shown. If there is no complex statement being matched, and the current keyword matches the end of a single statement, then the result is recorded directly, and the process continues to iterate and begin matching a new statement. For example, Figure 4 The semicolon at (3,19) shown is the semicolon starting from the 19th character position of the third line. When traversing the keyword data stream to the semicolon at (3,19), there are currently no candidate statement rules being matched, and as mentioned earlier, the semicolon can be the end of a single statement, so the semicolon and the position (3,19) corresponding to the keyword are recorded.

[0101] If the content of the current keyword is the same as the content of the first rule keyword of at least one statement rule, then the matching process for complex statements begins from the current keyword. For example... Figure 4In the example shown, after the semicolon ";" at (3,19) successfully matches as the end of a single statement, the next keyword is "create" at position (6,1). Since the first keyword of the aforementioned multiple statement rules is "create", the matching process for complex statements begins from "create" at (6,1). Since the next keyword after "create" at (6,1) is "procedure" at (6,19), the range of candidate statement rules can be further narrowed down, thus continuing the traversal and comparing it with the two statement rules used to create stored procedures. Similarly, since the subsequent traversal reaches "as" at (7,1), "begin" at (8,1), "end" at (10,1), and ";" at (10,4), which completely match the first statement rule used to create stored functions, and the next keyword is " / " at (11,1), representing an absolute statement separator, " / " at (11,1) is recorded as the end of the complex statement, along with its content and position. It should be understood that the above matching process traversed the semicolon (9,38), but since there are candidate statement rules and no match was reached at the end of any candidate statement rule, the semicolon (9,38) will not be recognized as the end of the statement. After the current statement is successfully matched, the pointer is shifted from the beginning keyword of the statement to the length of the statement based on the position of the ending keyword, and the matching process of a new statement begins, that is, it continues to traverse from "create" (13,1).

[0102] like Figure 4As shown, if paired keywords are matched during the matching process of complex statements, an auxiliary stack structure can be used for processing. Taking a three-level nested structure "begin…begin…if…end;…end;…end" as an example, after matching the first "begin", push it onto the stack. Since the next matched keyword is the second "begin" instead of "end", this "begin" is pushed onto the stack, and similarly, the next matched "if" is also pushed onto the stack. This continues until the first "end" is matched, which is paired with the "if" at the top of the stack. This "if" is popped from the stack. Since there are still keywords on the stack, this "end" will not be recognized as the end of the nested structure, and the matching continues. This continues until the second "end" is matched, which is paired with the "begin" at the top of the stack, meaning the second "begin" is popped from the stack, and the matching continues. This continues until the third "end" is matched. At this point, only the first "begin" remains on the stack, so it is popped from the stack, ending the matching of this nested structure, and the matching of other parts of the statement continues. It is important to note that if some "if" or "begin" are popped from the stack and the stack is not empty, and new "if" or "begin" keywords are matched, the new "if" or "begin" is pushed onto the stack and is given priority to be paired with the subsequently matched "end" keywords.

[0103] Following the above process, by traversing the entire keyword data stream, the content and position of the keyword at the end of each statement can be obtained as the output of the splitting result. For example... Figure 4 As shown, the splitting results are ";" in (3,19), " / " in (11,1), and ";" in (18,4). Based on this result, the semicolon at the 19th character position of the third line in the SQL file and the content before the semicolon can be identified as an independent SQL statement. The content after the semicolon up to the first single forward slash in the eleventh line can be identified as another SQL statement. The content after the single forward slash up to the fourth semicolon in the eighteenth line can be identified as another SQL statement.

[0104] The technical solution of this application eliminates the need for the rule matching algorithm to be adjusted based on the specific content of the statement rules. Instead, it only requires adjusting the preset keyword list and statement rules for different database types, thereby improving the scalability of the SQL file splitting method.

[0105] As an example, for SQL files of another specific type of database, a new set of statement rules and a corresponding keyword list can be configured, but the matching and splitting process can completely follow the above embodiment. For example, the SQL file of this type of database may involve five complex objects: package, packagebody, stored procedure, stored function, and anonymous block. For complex SQL statements related to the above complex objects, the following statement rules can be configured:

[0106] The rule for statements used to create packages is: create package…is / as…end…;

[0107] The rule for the statement used to create the package body is: create package body…is / as…end…;

[0108] The first rule for using the statement to create a stored function is: create function...as '...'end;

[0109] The second rule for using statements to create stored functions is: create function...as $$...$$;

[0110] The third rule for using statements to create stored functions: create function...as $xxx$...$xxx$;

[0111] The fourth rule for using statements to create stored functions: create function...is / as [declare] begin...end;

[0112] The first rule for using the statement to create a stored procedure: create procedure...as '...'end;

[0113] The second rule for using statements to create stored procedures is: create procedure...as $$...$$;

[0114] The third rule for using statements to create stored procedures: create procedure...as $xxx$...$xxx$;

[0115] The fourth rule for using statements to create stored procedures: create procedure...is / as [declare] begin...end;

[0116] A statement rule for anonymous blocks: [declare]...begin...end;

[0117] Another rule for anonymous blocks: do$xxx$...$xxx$;

[0118] In addition, for single statements that do not meet the above statement rules, delimiters such as " / " and ";" can be defined.

[0119] It's important to note that in the above statement rules, "$xxx$", "$$", or "..." represent a string within the SQL file. These strings may be identified using the "$xxx$" tag or simply enclosed in single quotes within the SQL file. Therefore, optionally, for this type of SQL file, the processing steps can uniformly replace the "$xxx$" tag and the content enclosed in single quotes with "$$", using it as a unified keyword for subsequent matching.

[0120] Based on the above statement rules and keyword list, the subsequent keyword extraction and statement matching process in the SQL file can be... Figure 3 and Figure 4 The content shown is consistent; for specific implementation methods, please refer to the previous text. Figure 3 and Figure 4 The descriptions of the relevant embodiments will not be repeated here.

[0121] The above text combined Figures 2 to 4 This application illustrates an embodiment of the SQL file splitting method, which is described below in conjunction with... Figures 5 to 8 The embodiments of the SQL file splitting apparatus provided in this application will be described.

[0122] Figure 5 A schematic structural diagram of an SQL file splitting apparatus 500 provided in an embodiment of this application is shown.

[0123] like Figure 5 As shown, the SQL file splitting device 500 includes: an extraction module 510, a matching module 520, and a splitting module 530.

[0124] Specifically, the extraction module 510 is used to obtain first information based on the SQL file. The first information includes multiple keywords in the SQL file and the position of each keyword in the SQL file.

[0125] Optionally, the extraction module 510 is also used to preprocess the SQL file to remove at least one eleventh keyword from the SQL file.

[0126] Optionally, the extraction module 510 is specifically used to determine multiple keywords from the SQL file based on the keyword list and the SQL file, wherein the keyword list includes at least multiple rule keywords; and to determine the positions of the multiple keywords in the SQL file based on the multiple keywords.

[0127] Specifically, the matching module 520 is used to determine multiple first keywords from multiple keywords based on multiple statement rules and first information. Each statement rule includes multiple rule keywords and the contextual relationship between the multiple rule keywords. The multiple first keywords correspond one-to-one with the multiple rule keywords of the first statement rule in the multiple statement rules. Each first keyword has the same content as the corresponding rule keyword, and the position of the multiple first keywords in the SQL file conforms to the contextual relationship between the multiple rule keywords of the first statement rule.

[0128] Optionally, the matching module 520 is specifically used to determine a second key and at least one candidate statement rule among multiple statement rules, wherein the first rule key of each candidate statement rule is the same as the content of the second key; based on the first information, to determine at least one fourth key from at least one third key, and to determine a first statement rule from at least one candidate statement rule, wherein at least one third key is a key among multiple keys, and at least one third key is located after the second key in the SQL file, the content and position of the second key and at least one fourth key conform to the first statement rule, and the multiple first keys include the second key and at least one fourth key.

[0129] Optionally, the rule keywords of the first statement rule include a pair of first rule keywords and second rule keywords. The matching module 520 is specifically used to determine a fifth keyword from at least one third keyword, the fifth keyword being identical to the content of the first rule keyword; based on the fifth keyword, determine a sixth keyword from at least one third keyword, the sixth keyword being identical to the content of the second rule keyword, and the positions of the fifth and sixth keywords in the SQL file include an equal number of N seventh keywords and N eighth keywords, each seventh keyword being identical to the content of the first rule keyword, each eighth keyword being identical to the content of the second rule keyword, where N is an integer greater than or equal to 0; determine at least one fourth keyword, the at least one fourth keyword including the fifth and sixth keywords.

[0130] Optionally, the matching module 520 is further configured to determine multiple tenth keywords from multiple ninth keywords based on multiple statement rules and first information, wherein the multiple ninth keywords are keywords among multiple keywords, and the multiple ninth keywords are located after multiple first keywords in the SQL file, the multiple tenth keywords correspond one-to-one with the rule keywords of the second statement rules among the multiple statement rules, each tenth keyword has the same content as the corresponding rule keyword, and the position of the tenth keyword in the SQL file conforms to the contextual relationship between the multiple rule keywords of the second statement rules.

[0131] Specifically, the splitting module 530 is used to split the SQL file based on multiple primary keys and the positions of the multiple primary keys in the SQL file.

[0132] Optionally, the splitting module 530 is specifically used to determine the first SQL statement, the end of which is the last first keyword among multiple first keywords.

[0133] Optionally, the splitting module 530 is also used to determine a second SQL statement, the second SQL statement ending with the last of a plurality of tenth keywords.

[0134] Optionally, the apparatus 500 includes a migration module 540, configured to determine the type of at least one object in the database to be migrated based on the result of splitting the SQL file; and to migrate at least one object from the database to be migrated to the target database based on the type of the at least one object.

[0135] All of the above modules can be implemented in software or hardware. For example, the implementation of matching module 520 will be described below. Similarly, the implementation of extraction module 510, splitting module 530, and migration module 540 can refer to the implementation of matching module 520.

[0136] As an example of a software functional unit, the matching module 520 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, the matching module 520 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed within the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed within the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0137] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0138] As an example of a hardware functional unit, the matching module 520 may include at least one computing device, such as a server. Alternatively, the matching module 520 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0139] The matching module 520 includes multiple computing devices that can be distributed in the same region or in different regions. Similarly, the matching module 520 includes multiple computing devices that can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the matching module 520 includes multiple computing devices that can be distributed in the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0140] It should be noted that, in other embodiments, the extraction module 510, matching module 520, splitting module 530, and migration module 540 can be used to execute any step in the above-described SQL file splitting method. The steps implemented by the extraction module 510, matching module 520, splitting module 530, and migration module 540 can be specified as needed. By implementing different steps in the above-described SQL file splitting method through the extraction module 510, matching module 520, splitting module 530, and migration module 540, all functions of the device 500 can be realized.

[0141] This application also provides a computing device 100. For example... Figure 6 As shown, the computing device 100 includes a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other via the bus 102. The computing device 100 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 100.

[0142] Bus 102 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 6 The bus 102 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 102 may include a path for transmitting information between various components of the computing device 100 (e.g., memory 106, processor 104, communication interface 108).

[0143] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0144] Memory 106 may include volatile memory, such as random access memory (RAM). Memory 106 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0145] The memory 106 stores executable program code, which the processor 104 executes to implement the functions of the aforementioned extraction module, matching module, and splitting module, thereby implementing the SQL file splitting method described above. In other words, the memory 106 stores instructions for executing the SQL file splitting method described above.

[0146] The communication interface 108 uses a command distribution module, such as, but not limited to, a network interface card or a transceiver, to enable communication between the computing device 100 and other devices or communication networks.

[0147] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0148] like Figure 7 As shown, the computing device cluster includes at least one computing device 100. The memory 106 in one or more computing devices 100 within the computing device cluster may store the same instructions for executing the aforementioned SQL file splitting method.

[0149] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions for executing the above-described SQL file splitting method. In other words, a combination of one or more computing devices 100 can jointly execute the instructions for executing the above-described SQL file splitting method.

[0150] It should be noted that the memory 106 in different computing devices 100 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the aforementioned SQL file splitting device. That is, the instructions stored in the memory 106 of different computing devices 100 can implement the functions of one or more modules among the extraction module, matching module, and splitting module.

[0151] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 8 One possible implementation is shown. For example... Figure 8 As shown, the two computing devices 100A and 100B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this possible implementation, the memory 106 in computing device 100A stores instructions for executing the extraction module. Simultaneously, the memory 106 in computing device 100B stores instructions for executing the matching and splitting modules.

[0152] It should be understood that Figure 8 The functions of the computing device 100A shown can also be performed by multiple computing devices 100. Similarly, the functions of the computing device 100B can also be performed by multiple computing devices 100.

[0153] This application also provides a chip, which includes a processor and a data interface. The processor reads instructions stored in the memory through the data interface to execute the above-described SQL file splitting method.

[0154] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to execute the aforementioned SQL file splitting method.

[0155] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the aforementioned SQL file splitting method.

[0156] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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, they should be considered to be within the scope of this specification.

[0157] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.

Claims

1. A method for splitting Structured Query Language (SQL) files, characterized in that, include: Based on the SQL file, obtain first information, which includes multiple keywords in the SQL file and the position of each keyword in the SQL file; Based on multiple statement rules and the first information, multiple first keywords are determined from the multiple keywords. Each statement rule includes multiple rule keywords and the context relationship between the multiple rule keywords. The multiple first keywords correspond one-to-one with the multiple rule keywords of the first statement rule in the multiple statement rules. Each first keyword has the same content as the corresponding rule keyword, and the position of the multiple first keywords in the SQL file conforms to the context relationship between the multiple rule keywords of the first statement rule. The SQL file is split based on the plurality of first keywords and their positions in the SQL file.

2. The method according to claim 1, characterized in that, The step of obtaining the first information based on the SQL file includes: Based on the keyword list and the SQL file, determine the plurality of keywords from the SQL file, wherein the keyword list includes at least the plurality of rule keywords; Based on the multiple keywords, determine the positions of the multiple keywords in the SQL file.

3. The method according to claim 1 or 2, characterized in that, The step of determining multiple first keywords from the multiple keywords based on multiple statement rules and the first information includes: Determine a second keyword and at least one candidate statement rule from the plurality of statement rules, wherein the first rule keyword of each candidate statement rule is the same as the content of the second keyword; Based on the first information, at least one fourth keyword is determined from at least one third keyword, and the first statement rule is determined from at least one candidate statement rule, wherein the at least one third keyword is a keyword among the plurality of keywords, and the position of the at least one third keyword in the SQL file is after the second keyword, the content and position of the second keyword and the at least one fourth keyword conform to the first statement rule, and the plurality of first keywords include the second keyword and the at least one fourth keyword.

4. The method according to claim 3, characterized in that, The rule keywords of the first statement rule include a pair of first rule keywords and second rule keywords. The step of determining at least one fourth keyword from at least one third keyword based on the first information, and determining the first statement rule from the at least one candidate statement rule, includes: A fifth keyword is determined from the at least one third keyword, wherein the fifth keyword is identical to the content of the first rule keyword; Based on the fifth keyword, a sixth keyword is determined from the at least one third keyword. The sixth keyword is identical to the content of the second rule keyword. Between the positions of the fifth keyword and the sixth keyword in the SQL file, there are an equal number of N seventh keywords and N eighth keywords. Each seventh keyword is identical to the content of the first rule keyword, and each eighth keyword is identical to the content of the second rule keyword. N is an integer greater than or equal to 0. The at least one fourth keyword is determined, and the at least one fourth keyword includes the fifth keyword and the sixth keyword.

5. The method according to any one of claims 1 to 4, characterized in that, The step of splitting the SQL file based on the plurality of first keywords and their positions in the SQL file includes: Determine the first SQL statement, the end of which is the last first keyword among the plurality of first keywords.

6. The method according to claim 5, characterized in that, The method further includes: Based on the multiple statement rules and the first information, multiple tenth keywords are determined from multiple ninth keywords, wherein the multiple ninth keywords are keywords among the multiple keywords, and the multiple ninth keywords are located after the multiple first keywords in the SQL file. The multiple tenth keywords correspond one-to-one with multiple rule keywords of the second statement rules among the multiple statement rules. Each tenth keyword has the same content as the corresponding rule keyword, and the position of the multiple tenth keywords in the SQL file conforms to the contextual relationship between the multiple rule keywords of the second statement rules. Determine the second SQL statement, the second SQL statement ending with the last tenth keyword among the plurality of tenth keywords.

7. The method according to any one of claims 1 to 6, characterized in that, The SQL file includes SQL statements for manipulating the database to be migrated, and the method further includes: Based on the results of splitting the SQL file, determine the type of at least one object in the database to be migrated; Based on the type of the at least one object, migrate the at least one object from the database to be migrated to the target database.

8. An apparatus for splitting Structured Query Language (SQL) files, characterized in that, include: The extraction module is used to obtain first information based on the SQL file. The first information includes multiple keywords in the SQL file and the position of each keyword in the SQL file. The matching module is used to determine multiple first keywords from the multiple keywords based on multiple statement rules and the first information. Each statement rule includes multiple rule keywords and the context relationship between the multiple rule keywords. The multiple first keywords correspond one-to-one with the multiple rule keywords of the first statement rule in the multiple statement rules. Each first keyword has the same content as the corresponding rule keyword, and the position of the multiple first keywords in the SQL file conforms to the context relationship between the multiple rule keywords of the first statement rule. The splitting module is used to split the SQL file according to the plurality of first keywords and the positions of the plurality of first keywords in the SQL file.

9. The apparatus according to claim 8, characterized in that, The extraction module is used for: Based on the keyword list and the SQL file, determine the plurality of keywords from the SQL file, wherein the keyword list includes at least the plurality of rule keywords; Based on the multiple keywords, determine the positions of the multiple keywords in the SQL file.

10. The apparatus according to claim 8 or 9, characterized in that, The matching module is used for: Determine a second keyword and at least one candidate statement rule from the plurality of statement rules, wherein the first rule keyword of each candidate statement rule is the same as the content of the second keyword; Based on the first information, at least one fourth keyword is determined from at least one third keyword, and the first statement rule is determined from at least one candidate statement rule, wherein the at least one third keyword is a keyword among the plurality of keywords, and the position of the at least one third keyword in the SQL file is after the second keyword, the content and position of the second keyword and the at least one fourth keyword conform to the first statement rule, and the plurality of first keywords include the second keyword and the at least one fourth keyword.

11. The apparatus according to claim 10, characterized in that, The first statement rule includes a pair of first rule keywords and second rule keywords. The matching module is used to: A fifth keyword is determined from the at least one third keyword, wherein the fifth keyword is identical to the content of the first rule keyword; Based on the fifth keyword, a sixth keyword is determined from the at least one third keyword. The sixth keyword is identical to the content of the second rule keyword. Between the positions of the fifth keyword and the sixth keyword in the SQL file, there are an equal number of N seventh keywords and N eighth keywords. Each seventh keyword is identical to the content of the first rule keyword, and each eighth keyword is identical to the content of the second rule keyword. N is an integer greater than or equal to 0. The at least one fourth keyword is determined, and the at least one fourth keyword includes the fifth keyword and the sixth keyword.

12. The apparatus according to any one of claims 8 to 11, characterized in that, The splitting module is used for: Determine the first SQL statement, the end of which is the last first keyword among the plurality of first keywords.

13. The apparatus according to claim 12, characterized in that, The matching module is also used for: Based on the multiple statement rules and the first information, multiple tenth keywords are determined from multiple ninth keywords, wherein the multiple ninth keywords are keywords among the multiple keywords, and the multiple ninth keywords are located after the multiple first keywords in the SQL file. The multiple tenth keywords correspond one-to-one with multiple rule keywords of the second statement rules among the multiple statement rules. Each tenth keyword has the same content as the corresponding rule keyword, and the position of the multiple tenth keywords in the SQL file conforms to the contextual relationship between the multiple rule keywords of the second statement rules. The splitting module is also used for: Determine the second SQL statement, the second SQL statement ending with the last tenth keyword among the plurality of tenth keywords.

14. The apparatus according to any one of claims 8 to 13, characterized in that, The SQL file includes SQL statements for operating the database to be migrated, and the device further includes a migration module for: Based on the results of splitting the SQL file, determine the type of at least one object in the database to be migrated; Based on the type of the at least one object, migrate the at least one object from the database to be migrated to the target database.

15. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 7.

16. A computer program product, characterized in that, Includes instructions that, when executed by a computing device or a cluster of computing devices, cause the computing device or the cluster of computing devices to perform the method as described in any one of claims 1 to 7.

17. A computer-readable storage medium, characterized in that, Includes computer program instructions that, when executed by a computing device or cluster of computing devices, cause the computing device or cluster of computing devices to perform the method as described in any one of claims 1 to 7.