CN115687292A - Verifiable database upgrading method irrelevant to database technology - Google Patents
Verifiable database upgrading method irrelevant to database technology Download PDFInfo
- Publication number
- CN115687292A CN115687292A CN202211121679.0A CN202211121679A CN115687292A CN 115687292 A CN115687292 A CN 115687292A CN 202211121679 A CN202211121679 A CN 202211121679A CN 115687292 A CN115687292 A CN 115687292A
- Authority
- CN
- China
- Prior art keywords
- statement
- upgrade
- verification
- database
- standard
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000005516 engineering process Methods 0.000 title claims abstract description 15
- 238000012795 verification Methods 0.000 claims abstract description 181
- 238000013507 mapping Methods 0.000 claims description 14
- 238000000605 extraction Methods 0.000 claims description 4
- 238000004458 analytical method Methods 0.000 claims description 3
- 238000010200 validation analysis Methods 0.000 claims description 2
- 230000009286 beneficial effect Effects 0.000 abstract description 3
- 230000000694 effects Effects 0.000 abstract description 3
- 238000012856 packing Methods 0.000 abstract description 2
- 230000006870 function Effects 0.000 description 5
- 238000012827 research and development Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 239000000284 extract Substances 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000013024 troubleshooting Methods 0.000 description 1
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机技术领域,具体涉及一种可验证的与数据库技术无关的数据库升级方法。The invention relates to the field of computer technology, in particular to a verifiable database upgrading method independent of database technology.
背景技术Background technique
在项目中需要对数据库进行升级是软件项目中经常遇到的情况。对已部署的数据库进行升级是一项繁琐且需要十分小心的任务。对数据库表属性的更改、字段属性变动以及字段值的改动均属于数据库升级的范畴。对于分布式系统而言,数据库部署在多个终端设备或云端设备,设备本地的数据库类型不同,进一步增加了数据库升级的工作量和难度。严重影响项目开发人员的工作效率和项目进度。为此有必要研究能够脱离数据库类型的数据库无关的数据库升级方法。It is a common situation in software projects that the database needs to be upgraded in the project. Upgrading a deployed database is a tedious and careful task. Changes to database table properties, field property changes, and field value changes all belong to the category of database upgrades. For a distributed system, the database is deployed on multiple terminal devices or cloud devices, and the types of local databases on the devices are different, which further increases the workload and difficulty of database upgrades. Seriously affect the work efficiency and project progress of project developers. Therefore, it is necessary to study a database-independent database upgrade method that can break away from the database type.
如中国专利CN105468717A,公开日2016年4月6日,公开了一种数据库操作方法和装置,该方法包括:接收对目标数据库的数据库操作请求,数据库操作请求包括:目标数据库的类型标识、对目标数据库进行的预设数据库操作的操作标识,其中,每一个操作标识预设为对应多个分别由不同类型的数据库执行的数据库操作;确定出由类型标识指示的类型的数据库执行的、与操作标识对应的数据库操作;对目标数据库执行经确定出的数据库操作。其技术方案实现了对不同类型的数据库的操作逻辑、操作接口以及操作方法的统一,但其技术方案不能解决数据库无关类型的升级。For example, Chinese patent CN105468717A, published on April 6, 2016, discloses a database operation method and device, the method includes: receiving a database operation request for the target database, the database operation request includes: the type identification of the target database, the target The operation identification of the preset database operation performed by the database, wherein each operation identification is preset to correspond to a plurality of database operations performed by different types of databases respectively; determine the operation identification performed by the type of database indicated by the type identification Corresponding database operation: Execute the determined database operation on the target database. Its technical solution realizes the unification of operation logic, operation interface and operation method for different types of databases, but its technical solution cannot solve the upgrade of irrelevant types of databases.
发明内容Contents of the invention
本发明所要解决的技术问题:目前缺乏能够实现数据库无关的数据库升级方案的技术问题。提出了一种可验证的与数据库技术无关的数据库升级方法,能够有效提高分布式项目的数据库升级效率。Technical problem to be solved by the present invention: Currently, there is a lack of technical problems that can realize database-independent database upgrade solutions. A verifiable database upgrade method independent of database technology is proposed, which can effectively improve the database upgrade efficiency of distributed projects.
解决上述技术问题,本发明采用如下技术方案:一种可验证的与数据库技术无关的数据库升级方法,包括:生成标准升级语句,生成与标准升级语句相对应的标准验证语句;To solve the above-mentioned technical problems, the present invention adopts the following technical solutions: a verifiable database upgrade method that has nothing to do with database technology, including: generating a standard upgrade statement, and generating a standard verification statement corresponding to the standard upgrade statement;
将标准升级语句和标准验证语句打包作为升级包,发送到目标设备;Package the standard upgrade statement and the standard verification statement as an upgrade package and send it to the target device;
目标设备解包升级包,将标准升级语句解析成与本地数据库类型相符的升级语句,将标准验证语句解析成与本地数据库类型相符的验证语句;The target device unpacks the upgrade package, parses the standard upgrade statement into an upgrade statement that matches the type of the local database, and parses the standard verification statement into a verification statement that matches the type of the local database;
目标设备执行升级语句;The target device executes the upgrade statement;
目标设备执行验证语句,若验证通过,则反馈升级成功,反之,则反馈升级失败并回滚至升级语句执行前。The target device executes the verification statement. If the verification is passed, it will report that the upgrade is successful. Otherwise, it will report that the upgrade has failed and roll back to before the execution of the upgrade statement.
作为优选,生成标准升级语句的方法包括:Preferably, the method for generating a standard upgrade statement includes:
罗列多种数据库的升级语句,将相同功能的升级语句分组;List the upgrade statements of various databases, and group the upgrade statements with the same function;
为每组升级语句关联语义替换语句,所述语义替换语句包括用于表示数据库操作的功能标识符以及用于记录语句参数的若干个参数占位符;Associating a semantic replacement statement for each group of upgrade statements, the semantic replacement statement includes a function identifier for representing a database operation and several parameter placeholders for recording statement parameters;
为每组的每个升级语句关联用于指示参数占位符与升级语句内容映射关系的映射符,形成升级语句对照表;Associating each upgrade statement in each group with a mapper used to indicate the mapping relationship between the parameter placeholder and the upgrade statement content, forming an upgrade statement comparison table;
根据升级内容编写任意一种数据库的升级语句而后转换为对应的语义替换语句,或者直接编写语义替换语句,所述语义替换语句即为标准升级语句。Write an upgrade statement for any database according to the upgrade content and then convert it into a corresponding semantic replacement statement, or directly write a semantic replacement statement, which is a standard upgrade statement.
作为优选,生成标准验证语句的方法包括:Preferably, the method for generating a standard verification statement includes:
为每个升级语句关联验证执行语句和验证条件语句,所述验证执行语句为数据库操作语句,所述验证条件语句根据数据库的输出判断升级结果;Associating each upgrade statement with a verification execution statement and a verification condition statement, the verification execution statement is a database operation statement, and the verification condition statement judges the upgrade result according to the output of the database;
同组升级语句关联的验证执行语句划分为一组,为每组验证执行语句关联标准验证执行语句,所述标准验证执行语句包括用于表示数据库操作的功能标识符以及用于记录语句参数的若干个参数占位符;The verification execution statements associated with the same group of upgrade statements are divided into one group, and each group of verification execution statements is associated with a standard verification execution statement. parameter placeholders;
为每个标准验证执行语句关联指示参数占位符与验证执行语句映射关系的映射符,形成验证语句对照表;Associating each standard verification execution statement with a mapper indicating the mapping relationship between the parameter placeholder and the verification execution statement to form a verification statement comparison table;
同组升级语句关联的验证条件语句划分为一组,为每组验证条件语句生成标准条件语句,所述标准条件语句包括属性提取词、属性条件词以及条件参数占位符;The verification condition statements associated with the same group of upgrade statements are divided into one group, and standard condition statements are generated for each group of verification condition statements, and the standard condition statements include attribute extraction words, attribute condition words and condition parameter placeholders;
为每个标准验证执行语句关联记录条件参数占位符与验证条件语句映射关系的映射符,形成条件语句对照表;For each standard verification execution statement, associate and record the mapper of the mapping relationship between the condition parameter placeholder and the verification condition statement to form a condition statement comparison table;
根据验证语句对照表和条件语句对照表,获得升级语句对应的标准验证执行语句和标准条件语句,所述标准验证执行语句和标准条件语句构成标准验证语句。According to the verification statement comparison table and the condition statement comparison table, a standard verification execution statement and a standard condition statement corresponding to the upgrade statement are obtained, and the standard verification execution statement and the standard condition statement constitute a standard verification statement.
作为优选,所述方法还包括:将升级语句对照表、验证语句对照表及条件语句对照表上传到网络存储设备;Preferably, the method further includes: uploading the upgrade statement comparison table, the verification statement comparison table and the condition statement comparison table to the network storage device;
目标设备将标准升级语句解析成与本地数据库类型相符的升级语句的方法为:The method for the target device to parse the standard upgrade statement into an upgrade statement that matches the type of the local database is as follows:
查询升级语句对照表,获得标准升级语句所在组中符合目标设备数据库类型的升级语句;Query the upgrade statement comparison table to obtain the upgrade statement that matches the database type of the target device in the group where the standard upgrade statement is located;
将标准升级语句中的参数按照映射符映射到升级语句中,完成解析;Map the parameters in the standard upgrade statement to the upgrade statement according to the mapper, and complete the analysis;
将标准验证语句解析成与本地数据库类型相符的验证语句的方法为:The method of parsing the standard verification statement into a verification statement that matches the type of the local database is:
查询验证语句对照表,获得与标准验证执行语句所在组中符合目标数合并数据库类型的验证执行语句和验证条件语句;Query the verification statement comparison table to obtain the verification execution statement and verification condition statement that meet the target number in the group where the standard verification execution statement is located;
将标准验证执行语句中的参数按照映射符映射到验证执行语句中,将标准条件语句中的参数按照映射符映射到验证条件语句中,完成解析。The parameters in the standard verification execution statement are mapped to the verification execution statement according to the mapper, and the parameters in the standard conditional statement are mapped to the verification conditional statement according to the mapper to complete the parsing.
作为优选,目标设备执行升级语句的方法包括:Preferably, the method for the target device to execute the upgrade statement includes:
判断升级语句的执行对象,若执行对象为数据库,则直接执行升级语句;Determine the execution object of the upgrade statement, if the execution object is a database, execute the upgrade statement directly;
若执行对象为数据库的表,则建立表的副本,表的副本保持表的结构,且复制若干条表的数据;If the execution object is a table of the database, create a copy of the table, the copy of the table maintains the structure of the table, and copies the data of several tables;
将执行语句的执行对象更换为表的副本,在表的副本上执行;Replace the execution object of the execution statement with a copy of the table, and execute it on the copy of the table;
使用验证语句验证表的副本的升级结果,若升级成功,则执行下一步骤,若升级失败,则删除表的副本并结束数据库升级;Use the verification statement to verify the upgrade result of the copy of the table. If the upgrade is successful, execute the next step. If the upgrade fails, delete the copy of the table and end the database upgrade;
删除表的副本,复原执行语句的执行对象并执行;Delete the copy of the table, restore the execution object of the execution statement and execute it;
使用验证语句验证升级结果。Use the verify statement to verify the result of the upgrade.
作为优选,为每个升级语句关联验证执行语句的方法包括:Preferably, the method for associating each upgrade statement with a verification execution statement includes:
人工制作每个数据库类型的验证执行语句集合;Manually create a collection of verification execution statements for each database type;
创建每种数据库类型的数据库实例记为辅助实例,在辅助实例上生成若干个例表;The database instance created for each database type is recorded as an auxiliary instance, and several instance tables are generated on the auxiliary instance;
依次读取升级语句对照表中的升级语句,人工填写语义替换语句中的参数,使参数指向辅助实例和/或例表;Read the upgrade statements in the upgrade statement comparison table in turn, manually fill in the parameters in the semantic replacement statement, so that the parameters point to the auxiliary instance and/or the example table;
将语义替换语句中的参数映射到升级语句中,形成可执行的升级语句,将可执行的升级语句在辅助实例上执行;Map the parameters in the semantic replacement statement to the upgrade statement to form an executable upgrade statement, and execute the executable upgrade statement on the auxiliary instance;
尝试将语义替换语句中的参数填入到验证执行语句集合中的验证执行语句,并依次在辅助实例上执行验证执行语句;Try to fill in the parameters in the semantic replacement statement into the verification execution statement in the verification execution statement set, and execute the verification execution statement on the auxiliary instance in turn;
筛除执行错误的验证执行语句,将辅助实例上成功执行的验证执行语句,作为建议关联验证执行语句,供人工选择。Screen out the verification execution statements that are incorrectly executed, and use the verification execution statements that are successfully executed on the auxiliary instance as suggestions to correlate the verification execution statements for manual selection.
作为优选,所述方法还包括:对于能够成功执行的验证执行语句,获得验证执行语句的输出内容;Preferably, the method further includes: for the verification execution statement that can be executed successfully, obtaining the output content of the verification execution statement;
依次更改可执行的升级语句中的参数,再次执行可执行的升级语句;Change the parameters in the executable upgrade statement in turn, and execute the executable upgrade statement again;
在任一参数被更改后,得到输出内容不同的验证执行语句,作为建议关联验证执行语句,供人工选择。After any parameter is changed, a verification execution statement with different output content is obtained as a suggested associated verification execution statement for manual selection.
本发明的有益技术效果为:制作数据库升级语句和验证语句的标准语句,使技术人员在制作代码时无需考虑具体的数据库类型,提高技术人员的效率,加快项目研发进度;带有验证语句能够及时判断数据库升级是否成功,有助于及早排查故障,提高数据库升级的安全性。The beneficial technical effects of the present invention are as follows: standard statements for making database upgrade statements and verification statements, so that technicians do not need to consider specific database types when making codes, improve the efficiency of technicians, and speed up project research and development; Judging whether the database upgrade is successful is helpful for troubleshooting early and improving the security of the database upgrade.
本发明的其他特点和优点将会在下面的具体实施方式、附图中详细的揭露。Other features and advantages of the present invention will be disclosed in detail in the following specific embodiments and drawings.
附图说明Description of drawings
下面结合附图对本发明做进一步的说明:Below in conjunction with accompanying drawing, the present invention will be further described:
图1为本发明实施例一可验证数据库升级方法流程示意图。FIG. 1 is a schematic flowchart of a method for upgrading a verifiable database according to an embodiment of the present invention.
图2为本发明实施例一生成标准升级语句方法流程示意图。FIG. 2 is a schematic flowchart of a method for generating a standard upgrade statement according to Embodiment 1 of the present invention.
图3为本发明实施例一生成标准验证语句方法流程示意图。FIG. 3 is a schematic flowchart of a method for generating standard verification sentences according to Embodiment 1 of the present invention.
图4为本发明实施例一目标设备解析方法流程示意图。FIG. 4 is a schematic flowchart of a method for parsing a target device according to Embodiment 1 of the present invention.
图5为本发明实施例二为升级语句关联验证执行语句方法流程示意图。FIG. 5 is a schematic flowchart of a method for executing a statement associated with an upgrade statement in Embodiment 2 of the present invention.
具体实施方式Detailed ways
下面结合本发明实施例的附图对本发明实施例的技术方案进行解释和说明,但下述实施例仅为本发明的优选实施例,并非全部。基于实施方式中的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得其他实施例,都属于本发明的保护范围。The technical solutions of the embodiments of the present invention will be explained and described below in conjunction with the accompanying drawings of the embodiments of the present invention, but the following embodiments are only preferred embodiments of the present invention, not all of them. Based on the examples in the implementation manners, other examples obtained by those skilled in the art without making creative efforts all belong to the protection scope of the present invention.
在下文描述中,出现诸如术语“内”、“外”、“上”、“下”、“左”、“右”等指示方位或者位置关系仅是为了方便描述实施例和简化描述,而不是指示或暗示所指的装置或者元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。In the following description, terms such as "inner", "outer", "upper", "lower", "left", "right" etc. appearing to indicate orientation or positional relationship are only for the convenience of describing the embodiment and simplifying the description, rather than Nothing indicating or implying that a referenced device or element must have a particular orientation, be constructed, and operate in a particular orientation should therefore not be construed as limiting the invention.
实施例一:Embodiment one:
一种可验证的与数据库技术无关的数据库升级方法,请参阅附图1,包括:A verifiable database upgrade method that has nothing to do with database technology, please refer to Figure 1, including:
步骤A01)生成标准升级语句,生成与标准升级语句相对应的标准验证语句;Step A01) generating a standard upgrade statement, and generating a standard verification statement corresponding to the standard upgrade statement;
步骤A02)将标准升级语句和标准验证语句打包作为升级包,发送到目标设备;Step A02) Packing the standard upgrade statement and the standard verification statement as an upgrade package and sending it to the target device;
步骤A03)目标设备解包升级包,将标准升级语句解析成与本地数据库类型相符的升级语句,将标准验证语句解析成与本地数据库类型相符的验证语句;Step A03) The target device unpacks the upgrade package, parses the standard upgrade statement into an upgrade statement consistent with the type of the local database, and parses the standard verification statement into a verification statement consistent with the type of the local database;
步骤A04)目标设备执行升级语句;Step A04) The target device executes the upgrade statement;
步骤A05)目标设备执行验证语句,若验证通过,则反馈升级成功,反之,则反馈升级失败并回滚至升级语句执行前。Step A05) The target device executes the verification statement. If the verification is passed, it will report that the upgrade is successful; otherwise, it will report that the upgrade has failed and roll back to before the execution of the upgrade statement.
对于分布式系统而言,系统中存在多个服务器设备及终端设备,服务器设备和终端设备均联网,但设备上的数据库类型不尽相同。对于项目管理系统而言,同样的系统有多个企业用户,同样的系统将部署在多个企业用户的设备上,支持每个企业用户各自的业务。不同企业用户的设备支持的数据库类型不尽相同。但系统升级时,有时会需要对数据库进行调整。此时就涉及到同样的升级内容,需要在多个类型不同的数据库上执行。若开发升级内容时,技术人员需要考虑每种数据库的升级语句和验证语句,将导致项目开发的代码臃肿,严重影响开发效率,同时影响数据库的稳定性和可靠性。For a distributed system, there are multiple server devices and terminal devices in the system, and the server devices and terminal devices are all connected to the Internet, but the types of databases on the devices are different. For the project management system, the same system has multiple enterprise users, and the same system will be deployed on the devices of multiple enterprise users to support the business of each enterprise user. Different enterprise users' devices support different database types. However, when the system is upgraded, sometimes the database needs to be adjusted. At this time, the same upgrade content is involved, and it needs to be executed on multiple databases of different types. When developing upgrade content, technicians need to consider the upgrade statement and verification statement of each database, which will lead to bloated code for project development, seriously affect development efficiency, and affect the stability and reliability of the database.
如表1所示,列举了本实施例支持的部分标准升级语句,标准升级语句是以高级语言表示的表达式。每个标准升级语句均关联有标准验证语句。表1中所示标准升级语句分别为在表中增加字段、设置或更改字段的属性以及删除字段。相应的标准验证语句为检查表中是否存在相应字段,以及字段的属性是否为指定属性。若存在且属性相符,则标准验证语句输出为真,反之,则输出为假。对于增加字段和设置字段属性,当标准验证语句的输出为真,则表明数据库升级成功。对于删除字段,当标准验证语句的输出为假,则表明数据库升级成功。技术人员在开发项目时,只需要写入标准升级语句和标准验证语句即可。不需要考虑不同的数据库类型。As shown in Table 1, some standard upgrade statements supported by this embodiment are listed. A standard upgrade statement is an expression expressed in a high-level language. Each standard upgrade statement is associated with a standard verification statement. The standard upgrade statements shown in Table 1 are respectively adding a field in a table, setting or changing attributes of a field, and deleting a field. The corresponding standard verification statement is to check whether the corresponding field exists in the table, and whether the attribute of the field is the specified attribute. If it exists and the attributes match, the output of the standard verification statement is true, otherwise, the output is false. For adding fields and setting field attributes, when the output of the standard verification statement is true, it indicates that the database upgrade is successful. For deleted fields, when the output of the standard validation statement is false, it indicates that the database upgrade was successful. When developing a project, technicians only need to write standard upgrade statements and standard verification statements. There is no need to consider different database types.
表1本实施例建立的标准升级语句及标准验证语句Table 1 Standard upgrade statement and standard verification statement established in this embodiment
请参阅附图2,生成标准升级语句的方法包括:Please refer to accompanying drawing 2, the method of generating standard upgrade statement includes:
步骤B01)罗列多种数据库的升级语句,将相同功能的升级语句分组;Step B01) List the upgrade statements of various databases, and group the upgrade statements with the same function;
步骤B02)为每组升级语句关联语义替换语句,语义替换语句包括用于表示数据库操作的功能标识符以及用于记录语句参数的若干个参数占位符;Step B02) associating a semantic replacement statement for each group of upgrade statements, the semantic replacement statement includes a function identifier for representing database operations and several parameter placeholders for recording statement parameters;
步骤B03)为每组的每个升级语句关联用于指示参数占位符与升级语句内容映射关系的映射符,形成升级语句对照表;Step B03) Associating each upgrade statement in each group with a mapping symbol for indicating the mapping relationship between the parameter placeholder and the upgrade statement content, forming an upgrade statement comparison table;
步骤B04)根据升级内容编写任意一种数据库的升级语句而后转换为对应的语义替换语句,或者直接编写语义替换语句,语义替换语句即为标准升级语句。Step B04) Write an upgrade statement of any type of database according to the upgrade content and then convert it into a corresponding semantic replacement statement, or directly write a semantic replacement statement, which is a standard upgrade statement.
表2本实施例建立的部分升级语句对照表Table 2 Comparison table of partial upgrade statements established in this embodiment
如表2所示,为本实施例建立的标准升级语句UpgradeAdd()的升级语句对照表。表中记录了不同数据库类型相应的执行语句。其中的表名、C1、T1、L1、B1、C2、T2、L2及B2为参数占位符。同时,参数占位符的名称也指示了参数占位符与升级语句内容映射关系,即同时作为映射符。如UpgradeAdd(op,A,x1,int),则对应于MySQL数据库,相应的升级语句为ALTERTABLEAADDCOLUMNx1int,对于SQLServer数据库则为AltertableAaddx1int。升级语句对照表记录了全部支持的标准升级语句在多种数据库类型下相应的执行语句,只要是升级语句对照表记录的数据库类型,均可以实现将标准升级语句转换为相应数据库类型的执行语句,完成数据库升级。为了提高数据库升级的稳定性,建议每次仅操作一个字段或者操作一个表。As shown in Table 2, it is an upgrade statement comparison table of the standard upgrade statement UpgradeAdd() established in this embodiment. The corresponding execution statements of different database types are recorded in the table. The table name, C1, T1, L1, B1, C2, T2, L2, and B2 are parameter placeholders. At the same time, the name of the parameter placeholder also indicates the mapping relationship between the parameter placeholder and the content of the upgrade statement, that is, it also serves as a mapper. For example, UpgradeAdd(op,A,x1,int) corresponds to the MySQL database, and the corresponding upgrade statement is ALTERTABLEAADDCOLUMNx1int, and it is AltertableAaddx1int for the SQLServer database. The upgrade statement comparison table records the corresponding execution statements of all supported standard upgrade statements under various database types. As long as it is the database type recorded in the upgrade statement comparison table, the standard upgrade statement can be converted into the execution statement of the corresponding database type. Complete the database upgrade. In order to improve the stability of the database upgrade, it is recommended to operate only one field or one table at a time.
请参阅附图3,生成标准验证语句的方法包括:Please refer to accompanying drawing 3, the method of generating standard verification statement includes:
步骤C01)为每个升级语句关联验证执行语句和验证条件语句,验证执行语句为数据库操作语句,验证条件语句根据数据库的输出判断升级结果;Step C01) Associating a verification execution statement and a verification condition statement for each upgrade statement, the verification execution statement is a database operation statement, and the verification condition statement judges the upgrade result according to the output of the database;
步骤C02)同组升级语句关联的验证执行语句划分为一组,为每组验证执行语句关联标准验证执行语句,标准验证执行语句包括用于表示数据库操作的功能标识符以及用于记录语句参数的若干个参数占位符;Step C02) The verification execution statements associated with the same group of upgrade statements are divided into one group, and each group of verification execution statements is associated with a standard verification execution statement. The standard verification execution statement includes a function identifier for representing a database operation and an identifier for recording statement parameters. Several parameter placeholders;
步骤C03)为每个验证执行语句关联指示参数占位符与标准验证执行语句映射关系的映射符,形成验证语句对照表,如表4所示;Step C03) Associating each verification execution statement with a mapper indicating the mapping relationship between the parameter placeholder and the standard verification execution statement, forming a comparison table of verification statements, as shown in Table 4;
步骤C04)同组升级语句关联的验证条件语句划分为一组,为每组验证条件语句生成标准条件语句,标准条件语句包括属性提取词、属性条件词以及条件参数占位符;Step C04) The verification condition statements associated with the same group of upgrade statements are divided into one group, and a standard condition statement is generated for each group of verification condition statements. The standard condition statement includes attribute extraction words, attribute condition words and condition parameter placeholders;
步骤C05)为每个标准验证执行语句关联记录条件参数占位符与验证条件语句映射关系的映射符,形成条件语句对照表,如表5所示;Step C05) For each standard verification execution statement, associate and record the mapper of the mapping relationship between the condition parameter placeholder and the verification condition statement to form a condition statement comparison table, as shown in Table 5;
步骤C06)根据验证语句对照表和条件语句对照表,获得升级语句对应的标准验证执行语句和标准条件语句,标准验证执行语句和标准条件语句构成标准验证语句。Step C06) According to the verification statement comparison table and the conditional statement comparison table, the standard verification execution statement and the standard conditional statement corresponding to the upgrade statement are obtained, and the standard verification execution statement and the standard conditional statement constitute the standard verification statement.
表3本实施例建立升级语句、验证执行语句和验证条件语句关联表Table 3 This embodiment establishes the association table of upgrade statement, verification execution statement and verification condition statement
如表3所示,记录了同组的在表中添加字段的升级语句的验证执行语句和条件语句。表3中记录的验证执行语句和条件语句分别为同组的验证执行语句和条件语句。为同组的验证执行语句和条件语句关联标准验证执行语句和标准条件语句。表3显示标准验证执行语句与举例的数据库类型的验证执行语句形式上相同,这是因为多种数据库类型,采用了恰好相同的语句。As shown in Table 3, the verification execution statement and the conditional statement of the upgrade statement that adds fields to the table in the same group are recorded. The verification execution statement and conditional statement recorded in Table 3 are respectively the verification execution statement and conditional statement of the same group. Associate the standard verification execution statement and the standard condition statement for the same group of verification execution statements and conditional statements. Table 3 shows that the standard verification execution statement is the same in form as the verification execution statement of the example database type, because various database types use exactly the same statement.
其中,OUT表示标准验证执行语句执行的输出,标准条件语句OUT=R中的属性提取词为OUT,即提取标准验证执行语句的全部输出,属性条件词为=,即条件为等于,条件参数占位符为R。标准条件语句OUT!=R的属性条件词为!=,其余与标准条件语句OUT=R相同。当写标准升级语句UpgradeAdd()的标准条件语句时,应同时将R赋值为true。Wherein, OUT represents the output that the standard verification execution statement executes, and the attribute extraction word in the standard condition statement OUT= R is OUT, promptly extracts the whole output of the standard verification execution statement, and the attribute condition word is =, that is, the condition is equal to, and the condition parameter accounts for The bit symbol is R. The standard conditional statement OUT! = The attribute condition word of R is! =, and the rest are the same as the standard conditional statement OUT= R . When writing the standard condition statement of the standard upgrade statement UpgradeAdd(), R should be assigned a value of true at the same time.
表4本实施例建立的部分验证语句对照表Table 4 Part of the verification statement comparison table established in this embodiment
表5本实施例建立的部分条件语句对照表Table 5 The comparison table of some conditional statements established in this embodiment
将升级语句对照表、验证语句对照表及条件语句对照表上传到网络存储设备。请参阅附图4,目标设备将标准升级语句解析成与本地数据库类型相符的升级语句的方法为:Upload the upgrade statement comparison table, verification statement comparison table, and condition statement comparison table to the network storage device. Please refer to Figure 4, the method for the target device to parse the standard upgrade statement into an upgrade statement that matches the type of the local database is as follows:
步骤D01)查询升级语句对照表,获得标准升级语句所在组中符合目标设备数据库类型的升级语句;Step D01) Query the upgrade statement comparison table, and obtain the upgrade statement that meets the target device database type in the group where the standard upgrade statement is located;
步骤D02)将标准升级语句中的参数按照映射符映射到升级语句中,完成解析;Step D02) The parameters in the standard upgrade statement are mapped to the upgrade statement according to the mapping symbols, and the analysis is completed;
将标准验证语句解析成与本地数据库类型相符的验证语句的方法为:The method of parsing the standard verification statement into a verification statement that matches the type of the local database is:
步骤D03)查询验证语句对照表,获得与标准验证执行语句所在组中符合目标数合并数据库类型的验证执行语句和验证条件语句;Step D03) Query the verification statement comparison table, and obtain the verification execution statement and the verification condition statement that meet the target number in the group where the standard verification execution statement is located;
步骤D04)将标准验证执行语句中的参数按照映射符映射到验证执行语句中,将标准条件语句中的参数按照映射符映射到验证条件语句中,完成解析。将升级语句对照表、验证语句对照表下发给每个终端,或者上传到网络存储设备,通过访问链接读取升级语句对照表、验证语句对照表。云端设备或终端设备查询升级语句对照表及验证语句对照表,即可获得对应本地数据库类型的升级语句、验证执行语句和验证条件语句。Step D04) The parameters in the standard verification execution statement are mapped to the verification execution statement according to the mapping symbols, and the parameters in the standard condition statement are mapped to the verification condition statements according to the mapping symbols to complete the parsing. Send the upgrade statement comparison table and verification statement comparison table to each terminal, or upload it to the network storage device, and read the upgrade statement comparison table and verification statement comparison table through the access link. The cloud device or terminal device can query the upgrade statement comparison table and the verification statement comparison table to obtain the upgrade statement, verification execution statement and verification condition statement corresponding to the local database type.
目标设备执行升级语句的方法包括:Methods for target devices to execute upgrade statements include:
判断升级语句的执行对象,若执行对象为数据库,则直接执行升级语句;Determine the execution object of the upgrade statement, if the execution object is a database, execute the upgrade statement directly;
若执行对象为数据库的表,则建立表的副本,表的副本保持表的结构,且复制若干条表的数据;If the execution object is a table of the database, create a copy of the table, the copy of the table maintains the structure of the table, and copies the data of several tables;
将执行语句的执行对象更换为表的副本,在表的副本上执行;Replace the execution object of the execution statement with a copy of the table, and execute it on the copy of the table;
使用验证语句验证表的副本的升级结果,若升级成功,则执行下一步骤,若升级失败,则删除表的副本并结束数据库升级;Use the verification statement to verify the upgrade result of the copy of the table. If the upgrade is successful, execute the next step. If the upgrade fails, delete the copy of the table and end the database upgrade;
删除表的副本,复原执行语句的执行对象并执行;Delete the copy of the table, restore the execution object of the execution statement and execute it;
使用验证语句验证升级结果。Use the verify statement to verify the result of the upgrade.
若执行对象为数据库的一个表,则制作该表的副本,副本具有相同的表的结构,并复制若干行数据至副本。在副本上先执行升级,若升级成功,则在原表上执行升级。若执行不成功,则终止数据库升级操作。If the execution object is a table of the database, make a copy of the table, the copy has the same table structure, and copy several rows of data to the copy. Perform the upgrade on the replica first, and if the upgrade is successful, perform the upgrade on the original table. If the execution is unsuccessful, the database upgrade operation is terminated.
本实施例的有益技术效果为:制作数据库升级语句和验证语句的标准语句,使技术人员在制作代码时无需考虑具体的数据库类型,提高技术人员的效率,加快项目研发进度;带有验证语句能够及时判断数据库升级是否成功,有助于及早排查故障,提高数据库升级的安全性。The beneficial technical effects of this embodiment are: making standard statements for database upgrade statements and verification statements, so that technicians do not need to consider specific database types when making codes, improve the efficiency of technicians, and speed up the progress of project research and development; Timely judging whether the database upgrade is successful will help to troubleshoot early and improve the security of the database upgrade.
实施例二:Embodiment two:
一种可验证的与数据库技术无关的数据库升级方法,本实施例在实施例一的基础上,提供了加快关联验证执行语句效率的技术方案。请参阅附图5,为每个升级语句关联验证执行语句的方法包括:A verifiable database upgrade method independent of database technology, this embodiment provides a technical solution to speed up the efficiency of association verification execution statements on the basis of the first embodiment. Please refer to accompanying drawing 5, the method for associating verification execution statement with each upgrade statement includes:
步骤E01)人工制作每个数据库类型的验证执行语句集合;Step E01) manually making a set of verification execution statements for each database type;
步骤E02)创建每种数据库类型的数据库实例记为辅助实例,在辅助实例上生成若干个例表;Step E02) Create a database instance of each database type as an auxiliary instance, and generate several example tables on the auxiliary instance;
步骤E03)依次读取升级语句对照表中的升级语句,人工填写语义替换语句中的参数,使参数指向辅助实例和/或例表;Step E03) sequentially read the upgrade statements in the upgrade statement comparison table, manually fill in the parameters in the semantic replacement statement, so that the parameters point to the auxiliary instance and/or the example table;
步骤E04)将语义替换语句中的参数映射到升级语句中,形成可执行的升级语句,将可执行的升级语句在辅助实例上执行;Step E04) Map the parameters in the semantic replacement statement to the upgrade statement to form an executable upgrade statement, and execute the executable upgrade statement on the auxiliary instance;
步骤E05)尝试将语义替换语句中的参数填入到验证执行语句集合中的验证执行语句,并依次在辅助实例上执行验证执行语句;Step E05) Attempt to fill in the parameters in the semantic replacement statement into the verification execution statement in the verification execution statement set, and execute the verification execution statement on the auxiliary instance in turn;
步骤E06)筛除执行错误的验证执行语句,将辅助实例上成功执行的验证执行语句,作为建议关联验证执行语句,供人工选择。Step E06) Screening out the wrong verification execution statements, and using the verification execution statements successfully executed on the auxiliary instance as suggested associated verification execution statements for manual selection.
更为有利的,对于能够成功执行的验证执行语句,获得验证执行语句的输出内容;依次更改可执行的升级语句中的参数,再次执行可执行的升级语句;在任一参数被更改后,得到输出内容不同的验证执行语句,作为建议关联验证执行语句,供人工选择。More advantageously, for the verification execution statement that can be successfully executed, the output content of the verification execution statement is obtained; the parameters in the executable upgrade statement are changed in turn, and the executable upgrade statement is executed again; after any parameter is changed, the output Verification execution sentences with different content are used as suggestions to associate verification execution sentences for manual selection.
相对于实施例一,本实施例能够为人工提供关联验证执行语句和验证条件语句的推荐语句,使人工关联验证执行语句时更为方便快捷,提高人工关联验证执行语句效率,进一步提高项目研发效率。Compared with Embodiment 1, this embodiment can provide manuals with recommended sentences for associated verification execution sentences and verification condition sentences, making it more convenient and quicker to manually associate verification execution sentences, improve the efficiency of manual verification execution sentences, and further improve the efficiency of project research and development .
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,熟悉该本领域的技术人员应该明白本发明包括但不限于附图和上面具体实施方式中描述的内容。任何不偏离本发明的功能和结构原理的修改都将包括在权利要求书的范围中。The above is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, and those skilled in the art should understand that the present invention includes but is not limited to the accompanying drawings and the description in the above specific embodiments content. Any modifications that do not depart from the functional and structural principles of the present invention will be included in the scope of the claims.
Claims (7)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2022109282065 | 2022-08-03 | ||
| CN202210928206 | 2022-08-03 |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN115687292A true CN115687292A (en) | 2023-02-03 |
| CN115687292B CN115687292B (en) | 2023-06-23 |
Family
ID=85062579
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211121679.0A Active CN115687292B (en) | 2022-08-03 | 2022-09-15 | A Verifiable Database Technology-Independent Method for Database Upgrade |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115687292B (en) |
Citations (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103186468A (en) * | 2013-04-10 | 2013-07-03 | 华为技术有限公司 | Method and device for testing and verifying software upgrading accuracy |
| CN104065528A (en) * | 2013-03-15 | 2014-09-24 | 美国网件公司 | Method and apparatus for analyzing and verifying functionality of a plurality of network devices |
| US9092741B1 (en) * | 2014-04-21 | 2015-07-28 | Amber Flux Private Limited | Cognitive platform and method for energy management for enterprises |
| CN106445618A (en) * | 2016-10-17 | 2017-02-22 | 成都知道创宇信息技术有限公司 | Automatic database updating method |
| CN107657038A (en) * | 2017-09-29 | 2018-02-02 | 北京酷我科技有限公司 | A kind of database method for quickly reading |
| US20190135434A1 (en) * | 2016-07-05 | 2019-05-09 | SZ DJI Technology Co., Ltd. | Verification method and apparatus |
| CN110333894A (en) * | 2019-07-10 | 2019-10-15 | 中国民航信息网络股份有限公司 | Method for upgrading system and device |
| CN110825413A (en) * | 2019-11-04 | 2020-02-21 | 江苏金智教育信息股份有限公司 | Database upgrading method and device and application deployment upgrading method and device |
| CN111309581A (en) * | 2020-02-28 | 2020-06-19 | 中国工商银行股份有限公司 | Application performance detection method and device in database upgrading scene |
| CN112231395A (en) * | 2020-09-14 | 2021-01-15 | 苏宁金融科技(南京)有限公司 | Transaction data synchronization method and server |
| CN112615865A (en) * | 2020-12-21 | 2021-04-06 | 曹佳乐 | Data anti-intrusion method based on big data and artificial intelligence and big data server |
| CN113268470A (en) * | 2021-06-17 | 2021-08-17 | 重庆富民银行股份有限公司 | Efficient database rollback scheme verification method |
| CN113721948A (en) * | 2021-07-21 | 2021-11-30 | 北京中科江南信息技术股份有限公司 | Database upgrading method, system and storage medium |
| CN114756569A (en) * | 2022-03-25 | 2022-07-15 | 北京友友天宇系统技术有限公司 | Multi-layer parsing method of structured query statement, computer device and storage medium |
-
2022
- 2022-09-15 CN CN202211121679.0A patent/CN115687292B/en active Active
Patent Citations (15)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN104065528A (en) * | 2013-03-15 | 2014-09-24 | 美国网件公司 | Method and apparatus for analyzing and verifying functionality of a plurality of network devices |
| CN103186468A (en) * | 2013-04-10 | 2013-07-03 | 华为技术有限公司 | Method and device for testing and verifying software upgrading accuracy |
| US9092741B1 (en) * | 2014-04-21 | 2015-07-28 | Amber Flux Private Limited | Cognitive platform and method for energy management for enterprises |
| US20210387725A1 (en) * | 2016-07-05 | 2021-12-16 | SZ DJI Technology Co., Ltd. | Verification method and apparatus |
| US20190135434A1 (en) * | 2016-07-05 | 2019-05-09 | SZ DJI Technology Co., Ltd. | Verification method and apparatus |
| CN106445618A (en) * | 2016-10-17 | 2017-02-22 | 成都知道创宇信息技术有限公司 | Automatic database updating method |
| CN107657038A (en) * | 2017-09-29 | 2018-02-02 | 北京酷我科技有限公司 | A kind of database method for quickly reading |
| CN110333894A (en) * | 2019-07-10 | 2019-10-15 | 中国民航信息网络股份有限公司 | Method for upgrading system and device |
| CN110825413A (en) * | 2019-11-04 | 2020-02-21 | 江苏金智教育信息股份有限公司 | Database upgrading method and device and application deployment upgrading method and device |
| CN111309581A (en) * | 2020-02-28 | 2020-06-19 | 中国工商银行股份有限公司 | Application performance detection method and device in database upgrading scene |
| CN112231395A (en) * | 2020-09-14 | 2021-01-15 | 苏宁金融科技(南京)有限公司 | Transaction data synchronization method and server |
| CN112615865A (en) * | 2020-12-21 | 2021-04-06 | 曹佳乐 | Data anti-intrusion method based on big data and artificial intelligence and big data server |
| CN113268470A (en) * | 2021-06-17 | 2021-08-17 | 重庆富民银行股份有限公司 | Efficient database rollback scheme verification method |
| CN113721948A (en) * | 2021-07-21 | 2021-11-30 | 北京中科江南信息技术股份有限公司 | Database upgrading method, system and storage medium |
| CN114756569A (en) * | 2022-03-25 | 2022-07-15 | 北京友友天宇系统技术有限公司 | Multi-layer parsing method of structured query statement, computer device and storage medium |
Non-Patent Citations (1)
| Title |
|---|
| 宋遇刚等: "基于形式化描述和模板对数据帧解析技术的研究", 产业与科技论坛, pages 52 - 54 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN115687292B (en) | 2023-06-23 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111061817B (en) | Adaptive business construction system, method and computer readable medium | |
| CN104866426B (en) | Software test integrated control method and system | |
| US10621211B2 (en) | Language tag management on international data storage | |
| US20230376408A1 (en) | Application programming interface test method and apparatus | |
| CN105786998B (en) | Database middleware system and the method for handling data using it | |
| CN112235311B (en) | OVSDB client code automatic generation method, system, device and medium | |
| CN112783916A (en) | SQL statement auditing method and device, storage medium and electronic equipment | |
| CN112328489A (en) | Test case generation method and device, terminal equipment and storage medium | |
| CN110188568A (en) | Confidential information identification method, device, device and computer-readable storage medium | |
| CN118245050B (en) | Front end frame assembly automatic conversion method, system, electronic device and storage medium | |
| CN118228698A (en) | Dynamic form generation method, device, equipment and storage medium | |
| US20210124752A1 (en) | System for Data Collection, Aggregation, Storage, Verification and Analytics with User Interface | |
| CN115577032A (en) | Method, device, terminal and storage medium for converting JSON (Java Server object notation) into SQL (structured query language) | |
| CN114090428A (en) | Information processing method, information processing device, computer-readable storage medium and computer equipment | |
| CN119048294A (en) | Contract numbering method and device, storage medium and terminal equipment | |
| CN115687292B (en) | A Verifiable Database Technology-Independent Method for Database Upgrade | |
| CN118633076A (en) | System construction equipment | |
| CN112799638B (en) | Non-invasive rapid development method, platform, terminal and storage medium | |
| CN116185853A (en) | Code verification method and device | |
| CN115756460A (en) | A method, device, electronic device and storage medium for generating a file management page | |
| CN114625755A (en) | Script checking method and device, electronic equipment and storage medium | |
| CN118733061B (en) | Automatic deployment method, system, equipment and medium for database | |
| CN118626879B (en) | BUFR data processing method, device and equipment based on template recognition | |
| CN116501753A (en) | Data processing method and device based on rule engine and rule engine system | |
| CN119576339A (en) | Script code processing method and device, and non-volatile storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| EE01 | Entry into force of recordation of patent licensing contract |
Application publication date: 20230203 Assignee: Hangzhou Haolian Intelligent Technology Co.,Ltd. Assignor: Hangzhou new China and the big Polytron Technologies Inc. Contract record no.: X2024980042943 Denomination of invention: A verifiable database upgrade method independent of database technology Granted publication date: 20230623 License type: Common License Record date: 20241231 |
|
| EE01 | Entry into force of recordation of patent licensing contract |