A database script logic conversion system and method
By automatically identifying and converting difference keywords in database scripts, the problem of low efficiency and high error rate in logical conversion between different database platforms is solved, achieving efficient and low-cost database script conversion.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- YGSOFT INC
- Filing Date
- 2021-11-24
- Publication Date
- 2026-05-05
AI Technical Summary
In existing technologies, the logical conversion of database functions between different database platforms or versions is inefficient, has a high error rate, and is costly to correct, requiring manual code adjustments.
By identifying distinguishing keywords through a matching module, establishing conversion functions, splitting and adjusting logic script segments, automated conversion is achieved, and a visual management platform is provided to reduce labor costs.
It improves the efficiency of database script logic conversion, reduces error rate and error correction cost, and has strong applicability, making it suitable for use by non-programming developers.
Smart Images

Figure CN116166684B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer script compilation technology, and in particular to a database script logic conversion system and method. Background Technology
[0002] Traditionally, database functions are managed by developers through code adjustments. However, the database language code formats often differ between different database platforms or different versions of the same database. This requires manual logical conversion between the two database scripts based on an understanding of each script, so that the two database scripts can achieve the same functionality before and after conversion.
[0003] In existing technologies, manual conversion based on human understanding of the code is not only inefficient and has a high error rate, but also incurs high error correction costs. Summary of the Invention
[0004] Based on the above analysis, the embodiments of the present invention aim to provide a database script logic conversion system or method to solve the problems of low efficiency, high error rate and high error correction cost of manually converting two database language scripts in the prior art.
[0005] On one hand, the present invention provides a database script logic conversion system, comprising:
[0006] The matching module is used to match keywords from multiple source language databases with keywords from the target language database to identify discrepancies in the matching results.
[0007] The database function creation module is used to create conversion functions that convert difference keywords into corresponding keywords in the target language database;
[0008] The database script splitting module is used to split the source language database script to be converted into multiple logical script segments according to the difference keywords.
[0009] The database script conversion module converts the difference keywords in the source language database script by calling the conversion function, and adjusts the order of multiple logical script segments to obtain the target language database script.
[0010] Furthermore, the database function creation module is also used to configure the corresponding conversion priority for each difference keyword and its corresponding conversion function.
[0011] Furthermore, the distinguishing keywords correspond one-to-one with the logical script segments;
[0012] The database script splitting module is specifically used to split the source language database script to be converted according to the difference keywords to obtain a logical script segment corresponding to each difference keyword, thereby splitting the source language database script to be converted into multiple logical script segments.
[0013] Furthermore, the conversion function is a script that implements the conversion of differential keywords;
[0014] When there are keywords in the target source language database that correspond to the difference keywords in the source language database, the database function establishment module establishes a first mapping relationship between the difference keywords and the corresponding keywords in the target language database, and sets a corresponding logical script segment order adjustment algorithm for the difference keywords, thereby obtaining a first conversion function to convert the difference keywords.
[0015] Furthermore, in the case where there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the database function establishment module is used to establish a function script that can achieve the same function as the difference keyword, establish a second mapping relationship between the difference keyword and the function script, and set a corresponding logical script segment order adjustment algorithm for the difference keyword, thereby obtaining a second conversion function corresponding to the difference keyword.
[0016] Furthermore, the database script conversion module is specifically used for:
[0017] If there are keywords in the target source language database that correspond to the difference keywords in the source language database, the corresponding first conversion function is called according to the association between the difference keywords and the first conversion function. The difference keywords are converted through the first mapping relationship, and the order of the logical script segments corresponding to the difference keywords is adjusted according to the corresponding logical script segment order adjustment algorithm.
[0018] Furthermore, the database script conversion module is also used for:
[0019] If there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the corresponding second conversion function is called according to the association between the difference keyword and the second conversion function. The corresponding function script is called through the second mapping relationship to replace the difference keyword, and the order of the logical script segment corresponding to the difference keyword is adjusted according to the corresponding logical script segment order adjustment algorithm.
[0020] Furthermore, the database script conversion module is also used for:
[0021] The database script in the target language is obtained by reorganizing and integrating each differentiated keyword and its corresponding logical script segment according to priority.
[0022] On the other hand, the present invention provides a database script logic transformation method, including:
[0023] Keywords from multiple source language databases are matched with keywords from the target language database to identify discrepancies in matching.
[0024] Establish a conversion function to convert difference keywords into corresponding keywords in the target language database;
[0025] The source language database script to be converted is split into multiple logical script segments according to the differences in keywords;
[0026] The conversion function is called to convert the difference keywords in the source language database script to be converted, and to adjust the order of multiple logical script segments, thereby merging them to obtain the target language database script.
[0027] In another aspect, the present invention provides a storage medium for storing a computer program, characterized in that a processor executes the computer program and is capable of the aforementioned database script logic conversion method.
[0028] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0029] 1. The database script logic conversion system and method proposed in this invention converts the difference keywords between two source language database scripts by establishing corresponding conversion functions, and adjusts the order of the multiple logic script segments after the difference keywords are converted, thereby realizing automatic conversion between database scripts of different source languages, improving the logic conversion efficiency between database scripts of different source languages, reducing the conversion error rate, and reducing the error correction cost.
[0030] 2. The database script logic conversion system and method proposed in this invention provide a visual database platform to manage the conversion functions corresponding to the difference keywords between different source language databases. When the difference keywords change, the developers can add, delete, modify or query the corresponding conversion functions. The adjusted script logic conversion system can be used by non-programmers, has strong applicability and reduces labor costs.
[0031] In this invention, the above-described technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of this invention will be set forth in the following description, and some advantages may become apparent from the description or be learned by practicing the invention. The objects and other advantages of this invention can be realized and obtained from what is particularly pointed out in the description and drawings. Attached Figure Description
[0032] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts.
[0033] Figure 1 This is a schematic diagram of the database script logic conversion system according to an embodiment of the present invention;
[0034] Figure 2 This is a flowchart of a database script logic conversion method according to an embodiment of the present invention. Detailed Implementation
[0035] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0036] System Implementation Examples
[0037] One specific embodiment of the present invention discloses a database script logic conversion system.
[0038] like Figure 1 As shown, the system includes:
[0039] The matching module 110 is used to match keywords in multiple source language databases with keywords in the target language database to identify discrepancies in the matching.
[0040] The database function creation module 120 is used to create conversion functions that convert difference keywords into corresponding keywords in the target language database.
[0041] The database script splitting module 130 is used to split the source language database script to be converted into multiple logical script segments according to the difference keywords. These difference keywords include, but are not limited to, keywords corresponding to DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), and DQL (Data Query Language). For example, in Oracle, the `withas` keyword can split and package the content within the adjacent parentheses for later use elsewhere.
[0042] The database script conversion module 140 converts the difference keywords in the source language database script by calling the conversion function, and adjusts the order of multiple logical script segments, and then merges them to obtain the target language database script.
[0043] Preferably, the matching module 110 is specifically used for:
[0044] For example, Oracle C18 SQL language is selected as the standard language for converting SQL scripts, i.e., the target language. All keywords in the Oracle database (the database corresponding to the target language) are retrieved, along with keywords from other commonly used database languages, i.e., keywords in the source language database to be converted (e.g., MySQL database). Fuzzy matching of keywords is then performed. If the keywords are completely identical, they are judged as matching keywords. If the keyword names are different but the functions are matching, or the names are the same but the functions are not matching, or other keywords in the source language database to be converted that do not match are judged as different keywords.
[0045] Preferably, the database function creation module 120 is specifically used for:
[0046] Establish a mapping relationship between the difference keywords of the target language and the source language to be converted.
[0047] It is also used to edit scripts that implement the function of different keywords in the source language database to be converted, i.e., conversion functions. Executing the conversion function can convert the different keywords in the source language database to be converted into scripts in the target language that achieve the same function.
[0048] Preferably, the database function creation module 120 is also used to configure the corresponding conversion priority for each difference keyword and its corresponding conversion function.
[0049] Preferably, there is a one-to-one correspondence between the difference keywords and the logical script segments. The database script splitting module 130 is specifically used to split the source language database script to be converted according to the difference keywords to obtain the logical script segments corresponding to each difference keyword, thereby splitting the source language database script to be converted into multiple logical script segments.
[0050] For example, the source language database script (MySQL script) to be converted is:
[0051] CREATE TABLE t_sac_archivestype(
[0052] GID string COMMENT 'primary key',
[0053] S_CREATE_TIME datetime COMMENT 'Creation Time'
[0054] )COMMENT'Category Table';
[0055] The entire script is broken down using the keyword CREATE TABLE(). The highest priority character in the script is ";", and since the script only has one semicolon at the end, it is not broken down.
[0056] The sub-decomposition of the fixed pattern keyword "CREATE TABLE()" yields the information "t_sac_archivestype" between "CREATE TABLE" and "()", marked as 2.1.
[0057] The information within the parentheses is "GID string COMMENT 'Primary Key', S_CREATE_TIME datetime COMMENT 'Creation Time'", marked as 2.2.
[0058] The information after the parentheses is "COMMENT 'Category Table'", marked as 2.3, which divides the entire script logic segment into 3 large logic script segments.
[0059] Furthermore, the large logic script segment is further broken down according to its keywords, specifically as follows:
[0060] For 2.1, it is the simplest information and does not need to be broken down.
[0061] For 2.2, the information is decomposed according to the comma "", which is "GID string COMMENT 'Primary Key'" (2.2.1) and "S_CREATE_TIME datetime COMMENT 'Creation Time'" (2.2.2).
[0062] For 2.3, "comment" (2.3) is the keyword, and the rest is the text information "'Category Table'" (2.4).
[0063] Among them, 2.2.1 matches "string" (2.2.1.1) and "COMMENT" (2.2.1.2) as keywords, and the remaining parts are decomposed into the text information "GID" (2.2.1.3) and "'primary key'" (2.2.1.4).
[0064] In addition, 2.2.2 matches "datetime" (2.2.2.1) and "COMMENT" (2.2.2.2) as keywords, and the remaining information is broken down into the text information "S_CREATE_TIME" (2.2.2.3) and "'Creation Time'" (2.2.2.4).
[0065] At this point, the source language database script to be converted has been completely disassembled.
[0066] Preferably, the conversion function is a script that implements the conversion of differential keywords.
[0067] When a keyword exists in the target source language database that corresponds to a different keyword in the source language database, the database function establishment module 120 establishes a first mapping relationship between the different keyword and the corresponding keyword in the target language database, and sets a corresponding logical script segment order adjustment algorithm for the different keyword, thereby obtaining a first conversion function to convert the different keyword. Specifically, a corresponding logical script segment order adjustment algorithm is configured for each different keyword according to its actual application rules.
[0068] Preferably, when there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the database function creation module 120 is used to create a function script that can achieve the same function as the difference keyword, establish a second mapping relationship between the difference keyword and the function script, and set a corresponding logical script segment order adjustment algorithm for the difference keyword, thereby obtaining a second conversion function corresponding to the difference keyword. Specifically, a corresponding logical script segment order adjustment algorithm is configured for each difference keyword according to its actual application rules.
[0069] Preferably, the database script conversion module 140 is specifically used for:
[0070] If there are keywords in the target source language database that correspond to the difference keywords in the source language database, the corresponding first conversion function is called according to the association between the difference keywords and the first conversion function. The difference keywords are converted through the first mapping relationship, and the order of the logical script segments corresponding to the difference keywords is adjusted according to the corresponding logical script segment order adjustment algorithm.
[0071] Preferably, the database script conversion module 140 is also used for:
[0072] If there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the corresponding second conversion function is called according to the association between the difference keyword and the second conversion function. The corresponding function script is called through the second mapping relationship to replace the difference keyword, and the order of the logical script segment corresponding to the difference keyword is adjusted according to the corresponding logical script segment order adjustment algorithm.
[0073] Preferably, the database script conversion module 140 is further used for:
[0074] The converted difference keywords and their corresponding logical script segments are reorganized and integrated according to priority to obtain the database script in the target language. Specifically, a corresponding priority order is configured for each difference keyword based on its actual application rules.
[0075] For example, the logical script segments obtained from the aforementioned splitting are specifically reorganized according to the Oracle database script, including:
[0076] Based on the decomposition order, first map the "create table" keyword to the Oracle template:
[0077] "create table(column1 type,column2 type,column3 type);"
[0078] Enter the mapped keywords and text information, specifically:
[0079] CREATE TABLE t_sac_archivestype(2.1)(
[0080] GID(2.2.1.3)text(2.2.1.1),
[0081] S_CREATE_TIME(2.2.2.3)timestamp(2.2.2.1) );
[0083] Using the keyword templates "comment" (2.3), (2.2.1.2), and (2.2.2.2), specifically:
[0084] "COMMENT ON table table_name is";"
[0085] "COMMENT ON COLUMN table_name.column is";"
[0086] Enter the keywords and text information obtained based on the mapping relationship to obtain:
[0087] COMMENT ON table t_sac_archivestype_df(2.1)IS'Classification Table'(2.4);
[0088] COMMENT ON COLUMN t_sac_archivestype_df(2.1).GID(2.2.1.3)IS'primary key'(2.2.1.4);
[0089] COMMENT ON COLUMN
[0090] t_sac_archivestype_df(2.1).S_CREATE_TIME(2.2.2.3)IS'Creation Time'(2.2.2.4);
[0091] After logical script conversion, the resulting target language database script (Oracle script) is:
[0092] CREATE TABLE t_sac_archivestype(
[0093] GID text,
[0094] S_CREATE_TIME timestamp );
[0096] COMMENT ON table t_sac_archivestype_df IS 'Category Table';
[0097] COMMENT ON COLUMN t_sac_archivestype_df.GID IS 'primary key';
[0098] COMMENT ON COLUMN t_sac_archivestype_df.S_CREATE_TIME
[0099] IS'Creation Time';
[0100] Preferably, when converting a database script, the script to be converted is entered into the system, and the source database language and target database language are selected on the system. If neither the target database language nor the source database language is an Oracle database language, then two conversions are required: from the source database language to the Oracle C18 version language, and then from the Oracle C18 version language to the target database language. Otherwise, only one conversion is required.
[0101] Method Implementation Examples
[0102] Another specific embodiment of the present invention discloses a database script logic conversion method.
[0103] Since the method embodiment and the aforementioned system embodiment have the same working principle, the repeated parts can be referred to the above method embodiment, and will not be repeated here.
[0104] Specifically, as shown in Figure 2, the method includes:
[0105] S110. Match the keywords in the multiple source language databases with the keywords in the target language database to identify the discrepancies in the matching.
[0106] S120. Establish a conversion function to convert the difference keywords into corresponding keywords in the target language database.
[0107] S130. Split the source language database script to be converted into multiple logical script segments according to the difference keywords.
[0108] S140. By calling the conversion function, the difference keywords in the source language database script to be converted are converted, and the order of multiple logical script segments is adjusted, and then the database script of the target language is obtained by merging them.
[0109] Another specific embodiment of the present invention discloses a storage medium for storing a computer program, which is executed by a processor to perform the aforementioned database script logic conversion method. The storage medium may be random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0110] The database script logic conversion system and method disclosed in this invention firstly converts the difference keywords between two source language database scripts by establishing corresponding conversion functions, and then adjusts the order of the multiple logic script segments after the conversion of the difference keywords. This enables automatic conversion between database scripts of different source languages, improves the efficiency of logical conversion between database scripts of different source languages, and reduces the error rate and correction costs. Secondly, the database script logic conversion system and method proposed in this invention provide a visual database platform to manage the conversion functions corresponding to the difference keywords between different source language databases. When the difference keywords change, developers can add, delete, modify, or query the corresponding conversion functions. The adjusted script logic conversion system can be used by non-programmers, has strong applicability, and reduces labor costs.
[0111] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0112] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A database script logic conversion system, characterized in that, include: The matching module is used to match keywords from multiple source language databases with keywords from the target language database to identify discrepancies in the matching results. The database function creation module is used to create a conversion function that converts difference keywords into corresponding keywords in the target language database. The conversion function is a functional script that implements the difference keyword conversion, including a first conversion function and a second conversion function. When there are keywords in the target source language database that correspond to the difference keywords in the source language database, the database function creation module establishes a first mapping relationship between the difference keyword and the corresponding keyword in the target language database, and sets a corresponding logical script segment order adjustment algorithm for the difference keyword, thereby obtaining a first conversion function to convert the difference keyword. If there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the database function establishment module is used to establish a function script that can achieve the same function as the difference keyword, establish a second mapping relationship between the difference keyword and the function script, and set a corresponding logical script segment order adjustment algorithm for the difference keyword, thereby obtaining a second conversion function corresponding to the difference keyword; The database script splitting module is used to split the source language database script to be converted into multiple logical script segments according to the difference keywords. The database script conversion module converts the difference keywords in the source language database script by calling the conversion function, and adjusts the order of multiple logical script segments to obtain the target language database script.
2. The database script logic conversion system according to claim 1, characterized in that, The database function creation module is also used to configure the corresponding conversion priority for each difference keyword and its corresponding conversion function.
3. The database script logic conversion system according to claim 2, characterized in that, The key difference keywords correspond one-to-one with the logical script segments; The database script splitting module is specifically used to split the source language database script to be converted according to the difference keywords to obtain a logical script segment corresponding to each difference keyword, thereby splitting the source language database script to be converted into multiple logical script segments.
4. The database script logic conversion system according to claim 3, characterized in that, The database script conversion module is specifically used for: If there are keywords in the target source language database that correspond to the difference keywords in the source language database, the corresponding first conversion function is called according to the association between the difference keywords and the first conversion function. The difference keywords are converted through the first mapping relationship, and the order of the logical script segments corresponding to the difference keywords is adjusted according to the corresponding logical script segment order adjustment algorithm.
5. The database script logic conversion system according to claim 4, characterized in that, The database script conversion module is also used for: If there is no keyword in the target source language database that corresponds to the difference keyword in the source language database, the corresponding second conversion function is called according to the association between the difference keyword and the second conversion function. The corresponding function script is called through the second mapping relationship to replace the difference keyword, and the order of the logical script segment corresponding to the difference keyword is adjusted according to the corresponding logical script segment order adjustment algorithm.
6. The database script logic conversion system according to claim 5, characterized in that, The database script conversion module is also used for: The database script in the target language is obtained by reorganizing and integrating each differentiated keyword and its corresponding logical script segment according to priority.
7. A database script logic conversion method applied to the system according to any one of claims 1-6, characterized in that, include: Keywords from multiple source language databases are matched with keywords from the target language database to identify discrepancies in matching. Establish a conversion function to convert difference keywords into corresponding keywords in the target language database; The source language database script to be converted is split into multiple logical script segments according to the differences in keywords; The conversion function is called to convert the difference keywords in the source language database script to be converted, and to adjust the order of multiple logical script segments, thereby merging them to obtain the target language database script.
8. A storage medium for storing computer programs, characterized in that, The processor executes the computer program to implement the database script logic conversion method of claim 7.
Citation Information
Patent Citations
Big data system and method for converting traditional database scripts into cloud in batches
CN113535758A