Database structure comparison method and device, storage medium and equipment

By automatically comparing the database table name and table structure attributes, completing and modifying statements are generated, the problem of low efficiency in database structure comparison is solved, and efficient and accurate comparison and synchronization is achieved.

CN118535552APending Publication Date: 2024-08-23PINGAN YIQIANBAO E COMMERCE CO LTD

Patent Information

Application Number
CN202410725172.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-05
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In the prior art, the database structure comparison efficiency is low and manual detailed comparison is required, which leads to high time and labor consumption, especially when there are more tables, the comparison efficiency and accuracy are difficult to guarantee.

Method used

By obtaining the table name and table structure attributes of the reference database and the database to be compared, automatically compare and generate complete and modified table execution statements, automatic comparison and synchronization of table structures are realized, and efficiency and accuracy are improved.

Benefits of technology

It realizes automation of database structure comparison, improves efficiency and accuracy, reduces manual intervention and reduces workload.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535552A
    Figure CN118535552A
Patent Text Reader

Abstract

The invention discloses a database structure comparison method and device, a storage medium and equipment, relates to the technical field of computers, and can solve the technical problem of low efficiency of manual database structure comparison. The method comprises the following steps: obtaining all reference table names of a reference database and all table names to be compared of a database to be compared, and comparing table names to be complemented which are less than the reference table names in the table names to be compared; determining a target table name of which the to-be-compared table name is the same as the reference table name, and querying a reference table structure attribute of the target table name in the reference database and a to-be-compared table structure attribute in the to-be-compared database; comparing the to-be-complemented table structure attributes, which are less than the reference table structure attributes, in the to-be-compared table structure attributes, and comparing the to-be-modified table structure attributes, which are different from the reference table structure attributes, in the to-be-compared table structure attributes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a database structure comparison method, device, storage medium and equipment. Background Art

[0002] Each application system, from development to testing to launch, will involve multiple database environments, including development database, test database, and production database. If the database structure is inconsistent, it may cause exceptions after the system code is launched, so it is necessary to ensure that the database structure of multiple database environments is consistent.

[0003] At present, taking the comparison of database structures of production database and test database as an example (the same applies to production database and development database), pull the same table creation statement (show create table + table name can get the table) into the production database and test database, both databases get the statement string, and compare the two statement strings. If the statement string comparison is inconsistent, the structures of the two databases (production database and test database) are inconsistent.

[0004] The existing defects are mainly as follows: we can only know which tables have inconsistent structures, but the specific details of the inconsistencies have to be manually compared in the next step. This takes time and manpower to compare one table, and the more tables there are, the more time and manpower it takes, and the efficiency of database structure comparison is low. Summary of the invention

[0005] In view of this, the present invention provides a database structure comparison method, device, storage medium and equipment, which can solve the technical problem of low efficiency of manual database structure comparison.

[0006] According to one aspect of the present invention, a method for comparing database structures is provided, the method comprising:

[0007] Acquire all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-compared table names that are less than the reference table names;

[0008] Determine a target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database;

[0009] The table structure attributes to be completed that are less than the reference table structure attributes among the table structure attributes to be compared are compared, and the table structure attributes to be modified that are different from the reference table structure attributes are compared.

[0010] Preferably, it also includes:

[0011] Generate a new table execution statement according to the table name to be completed, generate a new table structure attribute execution statement according to the table structure attribute to be completed, and generate a modify table structure attribute execution statement according to the table structure attribute to be modified;

[0012] The newly added table execution statement, the newly added table structure attribute execution statement and the modified table structure attribute execution statement are executed in the database to be compared.

[0013] Preferably, generating a new table execution statement according to the table name to be completed includes:

[0014] Get the template statement for the new table;

[0015] The table name to be completed is added to the new table template statement, and the new table execution statement is obtained and saved.

[0016] Preferably, the step of generating a new table structure attribute execution statement according to the table structure attribute to be completed includes:

[0017] Get the new table structure attribute template statement;

[0018] The target table name and the table structure attribute to be completed are added to the new table structure attribute template statement, and the new table structure attribute execution statement is obtained and saved.

[0019] Preferably, generating an execution statement for modifying table structure attributes according to the table structure attributes to be modified includes:

[0020] Get the template statement for modifying table structure attributes;

[0021] The target table name and the table structure attribute to be modified are added to the template statement for modifying the table structure attribute, and an execution statement for modifying the table structure attribute is obtained and saved.

[0022] Preferably, the table structure attributes include: column information, index information and constraint information.

[0023] Preferably, it also includes:

[0024] The table name to be completed and / or the table structure attribute to be completed and / or the table structure attribute to be modified are visualized.

[0025] According to another aspect of the present invention, there is provided a database structure comparison device, the device comprising:

[0026] A table name comparison module is used to obtain all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-completion table names that are less than the reference table names in the to-be-compared table names;

[0027] A query module, used to determine the target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database;

[0028] The table structure attribute comparison module is used to compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and to compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared.

[0029] According to another aspect of the present invention, there is provided a storage medium storing a computer program, wherein the program implements the above-mentioned database structure comparison method when executed by a processor.

[0030] According to another aspect of the present invention, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned database structure comparison method when executing the program.

[0031] By means of the above technical scheme, the present invention provides a database structure comparison method, device, storage medium and equipment, which can first obtain all reference table names of the reference database and all table names to be compared of the database to be compared, and compare the table names to be completed that are less than the reference table names in the table names to be compared; then determine the target table name whose table name to be compared is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and the table structure attributes to be compared in the database to be compared; finally, compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared. By means of the technical scheme of the present invention, layer-by-layer comparison is performed according to the hierarchy of table names and table structure attributes, and the comparison process is implemented by code. After the code is deployed, the comparison can be performed automatically without manual work, which not only improves efficiency but also improves accuracy.

[0032] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation on the local application. In the drawings:

[0034] Figure 1 A schematic diagram showing a flow chart of a database structure comparison method provided by an embodiment of the present invention;

[0035] Figure 2 A schematic diagram showing a flow chart of another database structure comparison method provided by an embodiment of the present invention;

[0036] Figure 3 A schematic diagram showing the structure of a database structure comparison device provided by an embodiment of the present invention;

[0037] Figure 4 A schematic structural diagram of another database structure comparison device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0038] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.

[0039] To solve the technical problem of low efficiency in database structure comparison, this embodiment provides a database structure comparison method, such as Figure 1 As shown, the method includes:

[0040] 101. Obtain all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-completion table names that are less than the reference table names.

[0041] It should be noted that since online production is the ultimate goal, therefore:

[0042] On the one hand, there is no need to compare the structure of the development database with the test database. It is only necessary to compare the structure of the development database with the production database, and the structure of the test database with the production database. For this embodiment, the reference database can be the production database, and the database to be compared can be just the test database, just the development database, or both the test database and the development database.

[0043] On the other hand, the database to be compared needs to be aligned with the reference database, that is, the data in the database to be compared but not in the reference database will not be considered.

[0044] Among them, since the database stores data through tables, and each table is identified by a table name, for the database to be compared, the tables included are the table names to be compared, and for the reference database, the tables included are the reference table names. The table names to be compared and the reference table names are compared to find out the table names to be completed that are less than the reference table names. For example, the table names to be compared are table name 1, table name 2, and table name 3, and the reference table names are table name 3 and table name 4. Then the table names to be compared that are less than the reference table names include table name 4.

[0045] 102. Determine a target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database.

[0046] 103. Compare and find out the table structure attributes to be completed that are less than the reference table structure attributes among the table structure attributes to be compared, and compare and find out the table structure attributes to be modified that are different from the reference table structure attributes among the table structure attributes to be compared.

[0047] Continuing with the example of step 101 of the embodiment, the names of the tables to be compared are table name 1, table name 2, and table name 3, and the names of the reference tables are table name 3 and table name 4. For steps 102 and 103 of the embodiment, a target table name whose name to be compared is the same as the reference table name is determined, then the target table name is table name 3, and then the reference table structure attributes of table name 3 in the reference database are queried, and the table structure attributes to be compared of table name 3 in the database to be compared are queried.

[0048] Among them, the table structure attributes include: column information [column name, column type, etc.], index information [index field, index type, etc.], constraint information [constraint field, constraint type, etc.], etc. For step 103 of the embodiment, taking the table structure attributes as column information [column name, column type], index information [index field, index type], and constraint information [constraint field, constraint type] as an example, the table structure attributes to be compared are compared with the reference table structure attributes, specifically, the column information to be compared is compared with the reference column information, the index information to be compared is compared with the reference index information, the constraint information to be compared is compared with the reference constraint information, etc., and there is no order restriction for these comparisons.

[0049] Take the comparison of the to-be-compared column information and the reference column information as an example:

[0050] First, query the reference table structure attributes of table name 3 in the reference database, and query the table structure attributes of table name 3 in the to-be-compared database, which may specifically include: querying the reference column information of table name 3 in the reference database, and querying the to-be-compared column information of table name 3 in the to-be-compared database. For example, the reference column information includes: column name 1, column type 1; column name 2, column type 2; column name 3, column type 3; column name 4, column type 4; the to-be-compared column information includes: column name 1, column type 2; column name 2, column type 2; column name 3, column type 1.

[0051] Then compare:

[0052] On the one hand, the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared are found: the column information to be compared does not have column name 4 and column type 4, while the reference column information has column name 4 and column type 4. Therefore, the column information to be completed that is less than the reference column information in the column information to be compared is column name 4 and column type 4.

[0053] On the other hand, the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared are compared: column name 1 and column type 2 in the column information to be compared are different from column name 1 and column type 1 in the reference column information, and column name 3 and column type 1 in the column information to be compared are different from column name 3 and column type 3 in the reference column information. Therefore, the column information to be modified that is different from the reference column information in the column information to be compared is: column type 2 corresponding to column name 1; column type 1 corresponding to column name 3.

[0054] Similarly, the index information to be compared is compared with the reference index information, and the constraint information to be compared is compared with the reference constraint information. Taking the case where the index information to be compared is not less than or different from the reference index information, and the constraint information to be compared is not less than or different from the reference constraint information as an example, the table structure attributes to be completed only include the column information to be completed, i.e., column name 4 and column type 4, and the table structure attributes to be modified only include the column information to be modified, i.e., column type 2 corresponding to column name 1 and column type 1 corresponding to column name 3.

[0055] It should be noted that steps 101-103 of the above embodiment are all implemented through code, that is, the code is compared, and the entire process does not require manual work, thereby improving the comparison efficiency and accuracy and reducing the workload.

[0056] The present invention provides a database structure comparison method, device, storage medium and equipment, which can first obtain all reference table names of the reference database and all table names to be compared of the database to be compared, and compare the table names to be completed that are less than the reference table names in the table names to be compared; then determine the target table name whose table name to be compared is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and the table structure attributes to be compared in the database to be compared; finally, compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared. Through the technical solution of the present invention, layer-by-layer comparison is performed according to the hierarchy of table names and table structure attributes, and the comparison process is implemented by code. After the code is deployed, the comparison can be performed automatically without manual work, which not only improves efficiency but also improves accuracy.

[0057] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another database structure comparison method is provided, such as Figure 2As shown, the method includes:

[0058] It should be noted that the comparison of database structures requires a comparison of specific details, and the reason for this is to generate a statement corresponding to the specific details. Executing this statement will ensure that what is in the reference database must also be in the comparison database and be the same.

[0059] 201. Obtain all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-completion table names that are less than the reference table names.

[0060] The specific implementation is the same as step 101 in the embodiment, and will not be repeated here.

[0061] 202. Generate a new table execution statement according to the table name to be completed.

[0062] For this embodiment, it includes: obtaining a new table template statement, adding the table name to be completed to the new table template statement, and obtaining and saving the new table execution statement.

[0063] Continuing with step 201 of the embodiment (i.e., step 101 of the embodiment), the table names to be compared are table name 1, table name 2, and table name 3, and the reference table names are table name 3 and table name 4. Then, among the table names to be compared, table name 4 is less than the reference table name, i.e., the table name to be completed is table name 4. A pre-written new table template statement is obtained. This new table template statement only has the table name but no table name is added. After knowing that table name 4 needs to be added, table name 4 is added to the new table template statement to obtain a new table execution statement.

[0064] Preferably, after obtaining the newly added table execution statement, the method further includes: executing the newly added table execution statement in the database to be compared. Specifically, for this embodiment, the newly added table execution statement is executed in the database to be compared. After the execution is completed, a table name 4 is newly added in the database to be compared.

[0065] 203. Determine a target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database.

[0066] 204. Compare and find out the table structure attributes to be completed that are less than the reference table structure attributes among the table structure attributes to be compared, and compare and find out the table structure attributes to be modified that are different from the reference table structure attributes among the table structure attributes to be compared.

[0067] For steps 203 and 204 of the embodiment, the specific implementation methods are the same as those of steps 102 and 103 of the embodiment, and will not be repeated here.

[0068] 205. Generate a new table structure attribute execution statement based on the table structure attribute to be completed, and generate a modify table structure attribute execution statement based on the table structure attribute to be modified.

[0069] For this embodiment, generating a new table structure attribute execution statement according to the table structure attribute to be completed includes: obtaining a new table structure attribute template statement; adding the target table name and the table structure attribute to be completed to the new table structure attribute template statement, and obtaining and saving the new table structure attribute execution statement.

[0070] Among them, the table structure attribute template statement is pre-written without the target table name and the table structure attributes to be completed. After knowing the target table name and the table structure attributes to be completed, add them to the corresponding position of the table structure attribute template statement to obtain the newly added table structure attribute execution statement.

[0071] Continuing with the example of steps 203 and 204 of the embodiment (i.e., steps 102 and 103 of the embodiment), the target table name is table name 3, and the table structure attributes to be completed are the column information to be completed, i.e., column name 4 and column type 4. Table name 3, column name 4, and column type 4 are added to the corresponding positions of the table structure attribute template statement to obtain the newly added table structure attribute execution statement.

[0072] Preferably, after obtaining the newly added table structure attribute execution statement, the method further includes: executing the newly added table structure attribute execution statement in the database to be compared. Specifically, for this embodiment, the newly added table structure attribute execution statement is executed in the database to be compared. After the execution is completed, a column name 4 and a column type 4 are newly added to the table name 3 in the database to be compared.

[0073] For this embodiment, generating a modify table structure attribute execution statement according to the table structure attribute to be modified includes: obtaining a modify table structure attribute template statement; adding the target table name and the table structure attribute to be modified to the modify table structure attribute template statement, obtaining and saving the modify table structure attribute execution statement.

[0074] Among them, the template statement for modifying table structure attributes is pre-written without the target table name and the table structure attributes to be modified. After knowing the target table name and the table structure attributes to be modified, add them to the corresponding position of the template statement for modifying table structure attributes, and obtain the execution statement for modifying table structure attributes.

[0075] Following the example of steps 203 and 204 of the embodiment (ie, steps 102 and 103 of the embodiment), the target table name is table name 3, and the table structure attribute to be modified is the column information to be modified, namely, column type 2 corresponding to column name 1 and column type 1 corresponding to column name 3.

[0076] Preferably, after obtaining the execution statement for modifying the table structure attribute, the method further includes: executing the execution statement for modifying the table structure attribute in the database to be compared. Specifically, for this embodiment, the execution statement for modifying the table structure attribute is executed in the database to be compared, and after the execution is completed, the column type corresponding to column name 1 in table name 3 is modified to column type 2 in the database to be compared, and the column type corresponding to column name 3 in table name 3 is modified to column type 1.

[0077] In summary, there is no limit on the time interval between obtaining a new table execution statement and executing the new table execution statement in the database to be compared, there is no limit on the time interval between obtaining a new table structure attribute execution statement and executing the new table structure attribute execution statement in the database to be compared, and there is no limit on the time interval between obtaining a table structure attribute modification execution statement and executing the table structure attribute modification execution statement in the database to be compared.

[0078] That is, as an implementation mode, after obtaining the execution statement for adding a table, the execution statement for adding a table is immediately executed in the database to be compared; after obtaining the execution statement for adding a table structure attribute, the execution statement for adding a table structure attribute is immediately executed in the database to be compared; after obtaining the execution statement for modifying the table structure attribute, the execution statement for modifying the table structure attribute is immediately executed in the database to be compared;

[0079] As another implementation, after all comparisons are completed, they are executed at one time in the database to be compared. Taking the result after all comparisons are completed including the execution statement for adding a table, the execution statement for adding a table structure attribute, and the execution statement for modifying the table structure attribute as an example, the execution statement for adding a table, the execution statement for adding a table structure attribute, and the execution statement for modifying the table structure attribute are executed at one time in the database to be compared, thereby realizing the synchronization of the database to be compared with the reference database.

[0080] It should be noted that, for steps 201-205 of the above embodiment, the logic is implemented through code, that is, the code is compared, and an execution statement is generated after the comparison is completed, and executed in the database to be compared. The whole process does not require manual work, thereby improving the comparison efficiency and accuracy and reducing the workload.

[0081] Preferably, for this embodiment, in order to facilitate viewing, after obtaining the table name to be completed and / or the table structure attributes to be completed and / or the table structure attributes to be modified, the table name to be completed and / or the table structure attributes to be completed and / or the table structure attributes to be modified are visualized, wherein, in order to facilitate intuitively seeing the places where the database to be compared is less than and different from the reference database, visualization can be performed before the database to be compared is synchronized with the reference database as the target; wherein, in order to facilitate seeing the effect of synchronization, visualization can also be performed after the database to be compared is synchronized with the reference database as the target.

[0082] Specifically, for visualizing the table name to be completed, as an implementation method, after obtaining the table name to be completed, the table name to be completed can be saved to a preset location, and the command to visualize the table name to be completed can be a command to search for the preset location, so that the saved table name to be completed can be visualized.

[0083] Specifically, for visualizing the table structure attributes to be completed and / or the table structure attributes to be modified, as an implementation method, first, determine the table name to be pulled that you want to view, wherein the table name to be pulled is any target table name (the target table name is a table that exists in both the database to be compared and the reference database). Take the table name to be pulled as table name 3 as an example, then, choose whether to view it before or after synchronization, for example, choose to view it before synchronization, and further, query the table name 3 before synchronization in the database to be compared and the reference database (the same applies to selecting to view it after synchronization, which will not be repeated here), and finally, pull the table structure attributes to be compared and the reference table structure attributes of this table name 3 before synchronization through the view field, and display them as follows:

[0084] First, the table structure attribute to be compared and the reference table structure attribute of the same table structure attribute are compared and displayed. If the table structure attribute to be compared and the reference table structure attribute do not have table structure attributes to be modified, then it is displayed that there is no table structure attribute to be modified. If the table structure attribute to be compared and the reference table structure attribute do have table structure attributes to be modified, then the table structure attribute to be modified is displayed.

[0085] Second, if there is a property in the parameter database but not in the database to be compared, that is, a pair of structure attributes of the table to be compared and the structure attributes of the reference table cannot be found, then the reference table structure attribute is displayed as the table structure attribute to be completed.

[0086] The present invention provides a database structure comparison method, device, storage medium and equipment, which can first obtain all reference table names of the reference database and all table names to be compared of the database to be compared, and compare the table names to be completed that are less than the reference table names in the table names to be compared; then determine the target table name that is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and the table structure attributes to be compared in the database to be compared; finally, compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared, and visualize the table names to be completed and / or the table structure attributes to be completed and / or the table structure attributes to be modified. Through the technical solution of the present invention, on the one hand, the comparison is performed layer by layer according to the hierarchy of the table name and the table structure attribute, and the comparison process is realized by code. After the code is deployed, the comparison can be automatically performed without manual work, which not only improves efficiency but also improves accuracy; on the other hand, the comparison results are visualized for easy viewing.

[0087] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the figure, the embodiment of the present invention provides a database structure comparison device, such as Figure 3 As shown, the device includes: a table name comparison module 31, a query module 32, and a table structure attribute comparison module 33;

[0088] The table name comparison module 31 can be used to obtain all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-completion table names that are less than the reference table names.

[0089] A query module 32, which can be used to determine the target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database;

[0090] The table structure attribute comparison module 33 can be used to compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared.

[0091] In a specific application scenario, a database structure comparison device, such as Figure 4 As shown, the device further includes: an execution module 34, including: a generation unit 341, an execution unit 342;

[0092] A generating unit 341 may be used to generate a table adding execution statement according to the table name to be completed, generate a table adding structure attribute execution statement according to the table structure attribute to be completed, and generate a table structure attribute modification execution statement according to the table structure attribute to be modified;

[0093] The execution unit 342 may be configured to execute the newly added table execution statement, the newly added table structure attribute execution statement, and the modified table structure attribute execution statement in the to-be-compared database.

[0094] Accordingly, in order to generate a new table execution statement according to the table name to be completed, the generating unit 341 can be specifically used to obtain a new table template statement; add the table name to be completed to the new table template statement, and obtain and save the new table execution statement.

[0095] Correspondingly, in order to generate a new table structure attribute execution statement according to the table structure attribute to be completed, the generation unit 341 can also be used to obtain a new table structure attribute template statement; add the target table name and the table structure attribute to be completed to the new table structure attribute template statement, and obtain and save the new table structure attribute execution statement.

[0096] Correspondingly, in order to generate an execution statement for modifying the table structure attributes according to the table structure attributes to be modified, the generation unit 341 can also be specifically used to obtain a template statement for modifying the table structure attributes; add the target table name and the table structure attributes to be modified to the template statement for modifying the table structure attributes, and obtain and save the execution statement for modifying the table structure attributes.

[0097] Correspondingly, the table structure attributes include: column information, index information and constraint information.

[0098] In a specific application scenario, a database structure comparison device, such as Figure 4 As shown, the device further includes: a visualization module 35, which can be specifically used to visualize the table name to be completed and / or the table structure attribute to be completed and / or the table structure attribute to be modified.

[0099] It should be noted that other corresponding descriptions of the functional units involved in the database structure comparison device provided in this embodiment can be referred to in Figure 1 to Figure 2 The corresponding description will not be repeated here.

[0100] Based on the above Figure 1 to Figure 2 The method shown in the embodiment, accordingly, also provides a storage medium, which can be volatile or non-volatile, and stores a computer program, which is executed by a processor to implement the above-mentioned Figure 1 to Figure 2 The comparison method of the database structure shown.

[0101] Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of various implementation scenarios of the present invention.

[0102] Based on the above Figure 1 to Figure 2 The method shown and Figure 3 , Figure 4 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides a computer device, which can be a personal computer, a server, a network device, etc. The computer device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 and Figure 2 The comparison method of the database structure shown.

[0103] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.

[0104] Those skilled in the art will appreciate that the computer device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.

[0105] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned computer device and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the non-volatile storage medium, and communication with other hardware and software in the information processing entity device.

[0106] Through the description of the above implementation modes, those skilled in the art can clearly understand that the present invention can be implemented by means of software plus a necessary general hardware platform, or by hardware.

[0107] The present invention provides a database structure comparison method, device, storage medium and equipment, which can first obtain all reference table names of the reference database and all table names to be compared of the database to be compared, and compare the table names to be completed that are less than the reference table names in the table names to be compared; then determine the target table name whose table name to be compared is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and the table structure attributes to be compared in the database to be compared; finally, compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared. Through the technical solution of the present invention, layer-by-layer comparison is performed according to the hierarchy of table names and table structure attributes, and the comparison process is implemented by code. After the code is deployed, the comparison can be performed automatically without manual work, which not only improves efficiency but also improves accuracy.

[0108] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present invention. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.

[0109] The above serial numbers of the present invention are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of the present invention, but the present invention is not limited thereto, and any changes that can be thought of by those skilled in the art should fall within the protection scope of the present invention.

Claims

1. A database structure comparison method, characterized in that: The method comprises: Acquire all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-compared table names that are less than the reference table names; Determine a target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database; The table structure attributes to be completed that are less than the reference table structure attributes among the table structure attributes to be compared are compared, and the table structure attributes to be modified that are different from the reference table structure attributes are compared.

2. The method according to claim 1, characterized in that Also includes: Generate a new table execution statement according to the table name to be completed, generate a new table structure attribute execution statement according to the table structure attribute to be completed, and generate a modify table structure attribute execution statement according to the table structure attribute to be modified; The newly added table execution statement, the newly added table structure attribute execution statement and the modified table structure attribute execution statement are executed in the database to be compared.

3. The method according to claim 2, characterized in that The generating a new table execution statement according to the table name to be completed includes: Get the template statement for the new table; The table name to be completed is added to the new table template statement, and the new table execution statement is obtained and saved.

4. The method according to claim 2, characterized in that: The step of generating a new table structure attribute execution statement according to the table structure attribute to be completed includes: Get the new table structure attribute template statement; The target table name and the table structure attribute to be completed are added to the new table structure attribute template statement, and the new table structure attribute execution statement is obtained and saved.

5. The method according to claim 2, characterized in that: The step of generating an execution statement for modifying the table structure attribute according to the table structure attribute to be modified includes: Get the template statement for modifying table structure attributes; The target table name and the table structure attribute to be modified are added to the template statement for modifying the table structure attribute, and an execution statement for modifying the table structure attribute is obtained and saved.

6. The method according to claim 1, characterized in that Table structure properties, including column information, index information, and constraint information.

7. The method according to any one of claims 1 to 6, characterized in that: Also includes: The table name to be completed and / or the table structure attribute to be completed and / or the table structure attribute to be modified are visualized.

8. A database structure comparison device, characterized in that: The device comprises: A table name comparison module is used to obtain all reference table names of the reference database and all to-be-compared table names of the to-be-compared database, and compare the to-be-completion table names that are less than the reference table names in the to-be-compared table names; A query module, used to determine the target table name whose to-be-compared table name is the same as the reference table name, query the reference table structure attributes of the target table name in the reference database, and query the to-be-compared table structure attributes in the to-be-compared database; The table structure attribute comparison module is used to compare the table structure attributes to be completed that are less than the reference table structure attributes in the table structure attributes to be compared, and to compare the table structure attributes to be modified that are different from the reference table structure attributes in the table structure attributes to be compared.

9. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the database structure comparison method described in any one of claims 1 to 7 is implemented.

10. A computer device comprising a memory, a processor, and a computer program stored in a storage medium and executable on the processor, characterized in that: When the processor executes the program, the database structure comparison method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Database table structure synchronization method and device, electronic device and storage medium

    CN108572996A

  • Multi-type database table structure comparison method and system, equipment and storage medium

    CN113672639A

  • Data table structure synchronization method, system and equipment

    CN116578651A

  • Database table structure synchronization method and device

    CN117194421A

  • Method and device for identifying database differences

    WO2019237574A1

Cited By

  • Method to intelligently compare database in resumable batch mode

    US12566749B1