CN111382198B - Data recovery method, device, equipment and storage medium - Google Patents
Data recovery method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN111382198B CN111382198B CN201811629215.4A CN201811629215A CN111382198B CN 111382198 B CN111382198 B CN 111382198B CN 201811629215 A CN201811629215 A CN 201811629215A CN 111382198 B CN111382198 B CN 111382198B
- Authority
- CN
- China
- Prior art keywords
- data
- value
- predetermined
- field
- tables
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种数据还原方法、装置、设备及存储介质,所述的方法包括:根据预定表中的预定字段,确定与所述预定字段关联的至少一张表;根据所述预定表与所述至少一张表之间的关联关系,形成表之间的关联关系模板;根据所述关联关系模板,采集并备份与所述预定字段的至少一个值中的每个值相关联的表数据;在所述备份的表数据中获取与所述至少一个值中的目标值相关联的表数据,以进行数据还原。根据本发明实施例,能够提高关系型数据库批量同步效率和降低成本,而且不依赖人工干预即可定时、定量完成自动回归测试。
The invention discloses a data restoration method, device, equipment and storage medium. The method includes: determining at least one table associated with the predetermined field according to the predetermined field in the predetermined table; The association relationship between the at least one table forms an association relationship template between the tables; according to the association relationship template, table data associated with each value of at least one value of the predetermined field is collected and backed up. ; Obtain table data associated with the target value in the at least one value from the backed up table data to perform data restoration. According to the embodiments of the present invention, the batch synchronization efficiency of the relational database can be improved and the cost can be reduced, and automatic regression testing can be completed regularly and quantitatively without relying on manual intervention.
Description
技术领域Technical field
本发明属于计算机领域,尤其涉及一种数据还原方法、装置、设备及存储介质。The invention belongs to the field of computers, and in particular relates to a data restoration method, device, equipment and storage medium.
背景技术Background technique
众所周知,数据库是不可缺失的重要组成部分。在软件开发、调试、测试过程中,程序员需要不停地对当前应用测试以确保软件的正确性、准确性和健壮性。大部分的测试是验证应用能否对数据库内特定的数据完成预期的增删改查操作。As we all know, the database is an indispensable and important component. During the process of software development, debugging, and testing, programmers need to constantly test the current application to ensure the correctness, accuracy, and robustness of the software. Most of the testing is to verify whether the application can complete the expected addition, deletion, modification and query operations on specific data in the database.
其中一些测试数据内容属于不可再生资源,比如对数据库一条数据做增加操作的测试后,目标预期数据已经存在,往往会被主键、唯一性索引或业务规则限制,不能再使用当前数据内容做新增操作。除非使用人工操作的方式删除当前数据内容,或者另外寻找一条符合测试要求的数据内容,或者对数据库中的数据进行恢复。目前有两种方式实现数据恢复:Some of the test data contents are non-renewable resources. For example, after adding a piece of data to the database, the target expected data already exists. It is often restricted by primary keys, unique indexes or business rules, and the current data content cannot be used to add new data. operate. Unless manual operation is used to delete the current data content, or find another piece of data content that meets the test requirements, or restore the data in the database. There are currently two ways to achieve data recovery:
一、关系型数据库批量恢复1. Batch recovery of relational database
主流关系型数据库主要通过备份数据批量同步或数据快照的方式完成批量应用数据还原,数据来源是备份库、日志。其目的主要是应对数据库信息安全,在断电等突发故障中最大程度保留客户数据。Mainstream relational databases mainly complete batch application data restoration through batch synchronization of backup data or data snapshots. The data sources are backup libraries and logs. Its purpose is mainly to deal with database information security and retain customer data to the greatest extent in sudden failures such as power outages.
如主流的Oracle、MySQL数据库,通过自身应用功能、辅以SQLLOAD、goodenGate等内部或第三方工具,支持大批量数据同步;Oracle自身根据底层能力,可以应急回复几分钟甚至几小时内发生的数据。For example, mainstream Oracle and MySQL databases support large-volume data synchronization through their own application functions, supplemented by internal or third-party tools such as SQLLOAD and goodenGate; Oracle itself can respond to data that occurs within minutes or even hours based on its underlying capabilities.
二、非关系型数据库批量恢复2. Batch recovery of non-relational databases
主流的非关系型数据库,包括Hadoop、Hbase、MonggoDB等数据库,主要通过内部主备和应急机制,采用1备N的方式存储数据,但一个数据存储节点发生故障导致数据不可用或者数据遗失时,管理节点会自动启用并执行安全策略,同步其他数据节点的数据,持续保持一份数据1备N的数据持久状态。Mainstream non-relational databases, including Hadoop, Hbase, MongoDB and other databases, mainly use internal active-standby and emergency mechanisms to store data in a 1-standby-N mode. However, when a data storage node fails and the data is unavailable or lost, The management node will automatically enable and execute security policies, synchronize the data of other data nodes, and continuously maintain a data persistence state of one copy of data.
非关系型数据库的数据源来自存储自身,采用高可用机制,其目的主要是应对数据库信息安全,在故障节点、宕机等突发故障中最大程度保留客户数据。The data source of non-relational databases comes from the storage itself and adopts a high-availability mechanism. Its main purpose is to deal with database information security and retain customer data to the greatest extent possible in sudden failures such as failed nodes and downtime.
三、人力手工维护少量数据同步3. Manual maintenance of small amounts of data synchronization
无论是关系型数据库、非关系数据库,均可以通过人工编撰数据操作脚本,如结构化查询语言(Structured Query Language,SQL)脚本的方式,对少量目标数据做增删改查操作。并通过反向编写回滚脚本和本地上线脚本备份等方式,基本做到少量目标数据的还原。Regardless of whether it is a relational database or a non-relational database, you can manually compile data operation scripts, such as Structured Query Language (SQL) scripts, to add, delete, modify, and query a small amount of target data. And by reverse writing rollback scripts and local online script backup, a small amount of target data can be basically restored.
人工脚本数据维护的可操作性强,适用范围广,灵活性极强,一般用于日常数据维护。其中也包括应用开发、测试过程中的应用数据还原功能。Manual script data maintenance is highly operable, has a wide range of applications, and is extremely flexible. It is generally used for daily data maintenance. This also includes the application data restoration function during application development and testing.
现有技术的缺点:Disadvantages of existing technology:
1、批量数据恢复成本较高,不能满足随时随需快速测试需求:定期对测试数据库、研发数据库做数据恢复固然可以解决目标数据被改变导致测试数据内容不可用问题,但面对大型的行业应用,一个测试场景可能涉及多个数据库并行恢复,代价高昂;同时,恢复后的数据内容在测试使用后仍然不可用,需要另寻目标或等待下一次批量恢复。1. Batch data recovery costs are high and cannot meet the demand for rapid testing at any time: regular data recovery of test databases and R&D databases can solve the problem of unavailability of test data content due to changes in target data, but in the face of large-scale industry applications , a test scenario may involve parallel recovery of multiple databases, which is expensive; at the same time, the recovered data content is still unavailable after test use, and you need to find another target or wait for the next batch recovery.
2、人工维护效率低,资源难以共享:通过人工脚本的方式恢复测试数据是软件研发过程中比较常用的做法。程序员或测试员根据应用和业务场景认知,临时编写回退脚本,方便下一次调试使用。临时编撰的脚本往往只针对一个或几个特定场景,一但测试完成,脚本往往被作废,下次重新编写。2. Manual maintenance is inefficient and resources are difficult to share: Restoring test data through manual scripts is a common practice in the software development process. Programmers or testers temporarily write rollback scripts based on their understanding of the application and business scenarios to facilitate next debugging. Temporarily compiled scripts often only target one or a few specific scenarios. Once the test is completed, the script is often scrapped and rewritten next time.
3、行业应用数据的复杂性问题:无论是人工编撰回复脚本还是批量数据库数据恢复,都面临行业应用数据的复杂性问题。比如:时间问题,昨天,上个月能够使用的测试数据,在今天或本月因为业务规则的限制不能使用,具体如:当月办理优惠打折扣,则上个月的数据无论是人工恢复还是数据库恢复,均不可用。此时需要人工将订购日期修改(UPDATE)为当月某一天,即软件行业常见的“造数据”现象。3. The complexity of industry application data: Whether it is manual compilation of reply scripts or batch database data recovery, we are faced with the complexity of industry application data. For example: time issue, the test data that could be used yesterday and last month cannot be used today or this month due to business rules restrictions. For example, if there is a discount for the current month, then the data last month will be restored either manually or by database recovery. , are all unavailable. At this time, you need to manually modify (UPDATE) the order date to a certain day of the month, which is a common "data creation" phenomenon in the software industry.
发明内容Contents of the invention
本发明实施例提供一种数据还原方法、装置、设备及存储介质,能够解决关系型数据库批量同步低效和高成本问题,而且不依赖人工干预即可定时、定量完成自动回归测试。Embodiments of the present invention provide a data restoration method, device, equipment and storage medium, which can solve the problems of inefficiency and high cost of batch synchronization of relational databases, and can complete automatic regression testing regularly and quantitatively without relying on manual intervention.
第一方面,本发明实施例提供一种数据还原方法,所述方法包括:In a first aspect, an embodiment of the present invention provides a data restoration method, which method includes:
根据预定表中的预定字段,确定与所述预定字段关联的至少一张表;Determine at least one table associated with the predetermined field according to the predetermined field in the predetermined table;
根据所述预定表与所述至少一张表之间的关联关系,形成表之间的关联关系模板;Form an association relationship template between tables according to the association relationship between the predetermined table and the at least one table;
根据所述关联关系模板,采集并备份与所述预定字段的至少一个值中的每个值相关联的表数据;According to the association relationship template, collect and back up table data associated with each value of at least one value of the predetermined field;
在所述备份的表数据中获取与所述至少一个值中的目标值相关联的表数据,以进行数据还原。Obtain table data associated with the target value in the at least one value from the backed up table data to perform data restoration.
第二方面,本发明实施例提供了一种数据还原装置,所述的包括:In a second aspect, an embodiment of the present invention provides a data restoration device, which includes:
关联表确定模块,用于根据预定表中的预定字段,确定与所述预定字段关联的至少一张表;An association table determination module, configured to determine at least one table associated with the predetermined field according to the predetermined field in the predetermined table;
模板形成模块,用于根据所述预定表与所述至少一张表之间的关联关系,形成表之间的关联关系模板;A template forming module, configured to form an association relationship template between tables based on the association relationship between the predetermined table and the at least one table;
数据采集模块,用于根据所述关联关系模板,采集并备份与所述预定字段的至少一个值中的每个值相关联的表数据;A data collection module configured to collect and back up table data associated with each value of at least one value of the predetermined field according to the association relationship template;
数据还原模块,用于在所述备份的表数据中获取与所述至少一个值中的目标值相关联的表数据,以进行数据还原。A data restoration module, configured to obtain table data associated with the target value in the at least one value from the backed up table data to perform data restoration.
第三方面,本发明实施例提供了一种数据还原设备,所述设备包括:处理器以及存储有计算机程序指令的存储器;In a third aspect, embodiments of the present invention provide a data restoration device, which includes: a processor and a memory storing computer program instructions;
所述处理器执行所述计算机程序指令时实现所述的数据还原方法。The processor implements the data restoration method when executing the computer program instructions.
第四方面,本发明实施例提供了一种计算机存储介质,所述计算机存储介质上存储有计算机程序指令,所述计算机程序指令被处理器执行时实现所述的数据还原方法。In a fourth aspect, embodiments of the present invention provide a computer storage medium. Computer program instructions are stored on the computer storage medium. When the computer program instructions are executed by a processor, the data restoration method is implemented.
本发明实施例的数据还原方法、装置、设备及存储介质,能够从具体场景出发,通过一个或多个目标值相关联的表数据进行数据还原,数据还原效率高,在短时间内可完成一个测试用例的数据还原,测试后可重复使用,解决关系型数据库批量同步低效和高成本问题。而且,引入关联关系模板解决行业数据还原的复杂性问题,可根据具体场景的需要自定义各个表的字段,并且实现数据自动化还原,大幅提升复用性。进一步地,可支持大规模海量后台回归测试,测试场景和数据还原建立后,不依赖人工干预即可定时、定量完成自动回归测试。The data restoration method, device, equipment and storage medium of the embodiment of the present invention can proceed from a specific scenario and perform data restoration through table data associated with one or more target values. The data restoration efficiency is high and a data restoration process can be completed in a short time. The data of test cases can be restored and reused after testing, solving the problems of inefficiency and high cost of batch synchronization of relational databases. Moreover, association relationship templates are introduced to solve the complexity problem of industry data restoration. The fields of each table can be customized according to the needs of specific scenarios, and automatic data restoration can be realized, greatly improving reusability. Furthermore, it can support large-scale and massive background regression testing. After the test scenarios and data restoration are established, automatic regression testing can be completed regularly and quantitatively without relying on manual intervention.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用的附图作简单的介绍,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the embodiments of the present invention more clearly, the drawings required to be used in the embodiments of the present invention will be briefly introduced below. For those of ordinary skill in the art, without exerting creative efforts, they can also Additional drawings can be obtained from these drawings.
图1示出了本发明一个实施例提供的数据还原方法的流程示意图;Figure 1 shows a schematic flow chart of a data restoration method provided by an embodiment of the present invention;
图2示出了本发明一个实施例的数据表中字段的示意图;Figure 2 shows a schematic diagram of fields in a data table according to an embodiment of the present invention;
图3示出了本发明一个实施例的字段间关联关系的示意图;Figure 3 shows a schematic diagram of the association between fields according to an embodiment of the present invention;
图4示出了本发明一个实施例的表间关联关系的示意图;Figure 4 shows a schematic diagram of the association between tables according to an embodiment of the present invention;
图5示出了本发明另一个实施例的数据表中字段的示意图;Figure 5 shows a schematic diagram of fields in a data table according to another embodiment of the present invention;
图6示出了本发明另一个实施例的字段间关联关系的示意图;Figure 6 shows a schematic diagram of the association between fields according to another embodiment of the present invention;
图7示出了本发明另一个实施例的表间关联关系的示意图;Figure 7 shows a schematic diagram of the association between tables according to another embodiment of the present invention;
图8示出了本发明一个实施例的表间关联关系简化的示意图;Figure 8 shows a simplified schematic diagram of the association between tables according to an embodiment of the present invention;
图9示出了本发明另一个实施例提供的数据还原方法的流程示意图;Figure 9 shows a schematic flow chart of a data restoration method provided by another embodiment of the present invention;
图10示出了本发明的一个实施例的配置关联关系模板的流程示意图;Figure 10 shows a schematic flowchart of configuring an association relationship template according to an embodiment of the present invention;
图11示出了本发明的一个实施例的采集表数据的流程示意图;Figure 11 shows a schematic flow chart of collecting table data according to one embodiment of the present invention;
图12示出了本发明的一个实施例的模板还原处理的流程示意图;Figure 12 shows a schematic flow chart of template restoration processing according to an embodiment of the present invention;
图13示出了本发明的一个实施例的数据还原装置的结构示意图;Figure 13 shows a schematic structural diagram of a data restoration device according to an embodiment of the present invention;
图14示出了本发明实施例提供的数据还原设备的硬件结构示意图。Figure 14 shows a schematic diagram of the hardware structure of a data restoration device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将详细描述本发明的各个方面的特征和示例性实施例,为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及具体实施例,对本发明进行进一步详细描述。应理解,此处所描述的具体实施例仅被配置为解释本发明,并不被配置为限定本发明。对于本领域技术人员来说,本发明可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本发明的示例来提供对本发明更好的理解。Features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are configured only to explain the invention and not to limit the invention. It will be apparent to one skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is merely intended to provide a better understanding of the invention by illustrating examples of the invention.
需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that these entities or operations are mutually exclusive. any such actual relationship or sequence exists between them. Furthermore, the terms "comprises," "comprises," or any other variations thereof are intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also those not expressly listed other elements, or elements inherent to the process, method, article or equipment. Without further limitation, an element defined by the statement "comprising..." does not exclude the presence of additional identical elements in a process, method, article, or device that includes the stated element.
为了解决现有技术问题,本发明实施例提供了一种数据还原方法、装置、设备及计算机存储介质。下面首先对本发明实施例所提供的数据还原方法进行介绍。In order to solve the existing technical problems, embodiments of the present invention provide a data restoration method, device, equipment and computer storage medium. The following first introduces the data restoration method provided by the embodiment of the present invention.
图1示出了本发明一个实施例提供的数据还原方法的流程示意图。如图1所示,该方法包括:Figure 1 shows a schematic flowchart of a data restoration method provided by an embodiment of the present invention. As shown in Figure 1, the method includes:
S101,根据预定表中的预定字段,确定与预定字段关联的至少一张表。S101: Determine at least one table associated with the predetermined field based on the predetermined field in the predetermined table.
S102,根据预定表与至少一张表之间的关联关系,形成表之间的关联关系模板。S102: Form an association relationship template between tables based on the association relationship between the predetermined table and at least one table.
S103,根据关联关系模板,采集并备份与预定字段的至少一个值中的每个值相关联的表数据。S103: Collect and back up table data associated with each value of at least one value of the predetermined field according to the association relationship template.
S104,在备份的表数据中获取与至少一个值中的目标值相关联的表数据,以进行数据还原。S104: Obtain table data associated with at least one target value in the backed-up table data for data restoration.
比如,在S103之后进行测试,由于测试或者其他原因导致数据发生变化,可以执行S104以进行数据还原。For example, if testing is performed after S103, if the data changes due to testing or other reasons, S104 can be executed to restore the data.
需要说明的是,本发明实施例基于关系型数据库中数据表之间的字段关联关系实现局部数据的自动还原。在已知一个数据表的一个字段值时,可据此字段值自动还原整个数据库中前一笔交易所影响的数据表中涉及该笔交易的所有关联对象内容。如:在移动通信行业中,对一个手机号码做产品变更测试后,将当前数据库环境下该手机号码所涉及的一系列表中的数据行内容还原,进而可以方便的做二次测试或其他测试工作。It should be noted that the embodiment of the present invention realizes automatic restoration of local data based on field associations between data tables in a relational database. When a field value of a data table is known, all related object contents involved in the transaction in the data table affected by the previous transaction in the entire database can be automatically restored based on the field value. For example: in the mobile communications industry, after testing a product change on a mobile phone number, restore the data row contents in a series of tables related to the mobile phone number in the current database environment, so that secondary testing or other tests can be conveniently done. Work.
在本发明实施例中,首先,从具体场景出发,通过一个或多个目标值相关联的表数据进行数据还原,数据还原效率高,在短时间(2分钟左右)内可完成一个测试用例的数据还原,测试后可重复使用,解决关系型数据库批量同步低效和高成本问题。其次,引入关联关系模板解决行业数据还原的复杂性问题,可根据具体场景的需要自定义各个表的字段,并且实现数据自动化还原,大幅提升复用性,解决行业应用数据的复杂性问题。最后,数据可复用、自定义特殊字段特征,可支持大规模海量后台回归测试,测试场景和数据还原建立后,不依赖人工干预即可定时、定量完成自动回归测试。In the embodiment of the present invention, first, starting from the specific scenario, data restoration is performed through table data associated with one or more target values. The data restoration efficiency is high, and a test case can be completed in a short time (about 2 minutes). Data restoration can be reused after testing, solving the problems of inefficiency and high cost of batch synchronization of relational databases. Secondly, association relationship templates are introduced to solve the complexity problem of industry data restoration. The fields of each table can be customized according to the needs of specific scenarios, and automatic data restoration is realized, which greatly improves reusability and solves the complexity problem of industry application data. Finally, data can be reused and special field characteristics can be customized to support large-scale and massive background regression testing. After the test scenarios and data restoration are established, automatic regression testing can be completed regularly and quantitatively without relying on manual intervention.
在本发明的一个实施例中,S101包括:In one embodiment of the present invention, S101 includes:
将预定字段作为起始字段;查找与起始字段相关联的字段,将该字段所在的表作为待处理表;将待处理表中的每个字段作为新的起始字段,返回执行查找的步骤,直到满足第一预定条件时为止;将得到的所有待处理表作为至少一张表。Use the predetermined field as the starting field; find the field associated with the starting field, and use the table where the field is located as the pending table; use each field in the pending table as a new starting field, and return to the steps to perform the search , until the first predetermined condition is met; use all the obtained tables to be processed as at least one table.
其中,第一预定条件包括:查找不到与起始字段相关联的字段或者得到的待处理表满足测试场景需求。The first predetermined condition includes: the field associated with the starting field cannot be found or the obtained table to be processed meets the test scenario requirements.
需要说明的是,数据库在实际生产应用工作中,基于效率、业务复杂度等因素,设计和研发并不完全使用数据库主外键维护数据一致性,而是通过上层WEB或中间件应用,在业务逻辑代码中维护业务数据一致性。图2示出了本发明一个实施例的数据表中字段的示意图。如图2所示,通过各个字段的外框形状来区分字段之间的关系,当然还可以通过表中各个字段的颜色来区分字段之间的关系。在图2中,数据表A中的字段1和数据表B中的字段2都是正方形的外框,即数据表A中的字段1和数据表B中的字段2具有关联关系。同理,数据表B中的字段1和数据表C中的字段1具有关联关系,数据表C中的字段3和数据表D中的字段1具有关联关系。It should be noted that in actual production and application work of the database, based on factors such as efficiency and business complexity, the design and R&D do not completely use the database's primary and foreign keys to maintain data consistency, but use upper-layer WEB or middleware applications to ensure data consistency in the business. Maintain business data consistency in logical code. Figure 2 shows a schematic diagram of fields in a data table according to an embodiment of the present invention. As shown in Figure 2, the relationship between fields is distinguished by the shape of the outer frame of each field. Of course, the relationship between fields can also be distinguished by the color of each field in the table. In Figure 2, field 1 in data table A and field 2 in data table B are both square frames, that is, field 1 in data table A and field 2 in data table B have an associated relationship. In the same way, field 1 in data table B is related to field 1 in data table C, and field 3 in data table C is related to field 1 in data table D.
根据图2中各个表中的字段关联关系,可以得出如图3所示的字段间关联关系的示意图。如图3所示,A1与B2具有关联关系,B1与C1具有关联关系,C3与D1具有关联关系,A1表示数据表A中的字段1,B2表示数据表B中的字段2,B1、C1、C3、D1的含义可以以此类推。According to the field correlation relationships in each table in Figure 2, a schematic diagram of the correlation relationships between fields can be drawn as shown in Figure 3. As shown in Figure 3, A1 is associated with B2, B1 is associated with C1, C3 is associated with D1, A1 represents field 1 in data table A, B2 represents field 2 in data table B, B1, C1 , C3, D1 can be deduced in the same way.
图2枚举4张数据表的关联关系,即当获取A1的实例值(如用户手机号码PHONE_NO)后,可以立即通过SQL语句获取一个或一组B2的实例值,一个或一组取决于A1和B2的一对一、一对多或多对多关系。Figure 2 enumerates the relationships between four data tables. That is, after obtaining the instance value of A1 (such as the user's mobile phone number PHONE_NO), you can immediately obtain one or a group of B2 instance values through a SQL statement. One or a group depends on A1. One-to-one, one-to-many or many-to-many relationship with B2.
在基于A1得到的B2后,可以在B2所在的数据B表中直接得到B1,进而得到一组或多组C1。同理,依赖所有得出的C1字段的列表可以得到所有D1字段的列表。After obtaining B2 based on A1, you can directly obtain B1 in the data table B where B2 is located, and then obtain one or more groups of C1. In the same way, depending on the list of all C1 fields obtained, the list of all D1 fields can be obtained.
图4示出了本发明一个实施例的表间关联关系的示意图,其中A表数据行依赖A1获取,B表数据行依赖A1获取,这两种均是直接获取;C表数据行依赖A1得到的B2数据获取,D表数据行依赖B1得到的C1数据内容中的C3数据获取,这两种均是间接获取。图4中实线代表直接获取关系,虚线代表间接获取关系。Figure 4 shows a schematic diagram of the association between tables in an embodiment of the present invention. The data rows of table A depend on A1 to obtain, and the data rows of table B depend on A1 to obtain. Both of them are obtained directly; the data rows of table C depend on A1 to obtain. B2 data acquisition, D table data rows rely on C3 data acquisition in the C1 data content obtained by B1, both are indirect acquisitions. In Figure 4, the solid line represents the direct acquisition relationship, and the dotted line represents the indirect acquisition relationship.
实际应用中,数据模型设计依据具体应用需要设计且大多增量演进,故一般行业交易类数据表关联关系结果会出现图状结构。本发明实施例将图状关联关系转换为二叉树状关联关系。In actual applications, data model design is designed based on specific application needs and mostly evolves incrementally, so the association results of transaction data tables in general industries will have a graph-like structure. The embodiment of the present invention converts the graph-like association relationship into a binary tree-like association relationship.
图5示出了本发明另一个实施例的数据表中字段的示意图。如图5所示,在用户基本信息(数据表A),用户订购信息(数据表B),用户订购属性信息(数据表C),以及用户属性配置信息表(数据表D)四张表的基础上,因业务需求新增业务操作规则记录表X,其字段间关联关系如图6所示。在图6中,字段关联关系复杂且冗余,在已知数据A1某字段实例值的情况下,有多种方式获取B、C、D表的数据行内容,如图7所示,如果已知A1需要获取B表数据,可以通过:A1-B2,A1-X1-B1,A1-X1-C3-B1等三种以上的方式关联获取,如果通过这三种方式获取B表,将导致采集的表数据冗余和数据还原时重复操作,增加研发落地成本,降低处理效率。Figure 5 shows a schematic diagram of fields in a data table according to another embodiment of the present invention. As shown in Figure 5, there are four tables of user basic information (data table A), user ordering information (data table B), user ordering attribute information (data table C), and user attribute configuration information table (data table D). Based on this, a new business operation rule record table X is added due to business needs, and the correlation between its fields is shown in Figure 6. In Figure 6, the field relationships are complex and redundant. When the instance value of a field in data A1 is known, there are many ways to obtain the data row contents of tables B, C, and D, as shown in Figure 7. If the Knowing that A1 needs to obtain table B data, it can be obtained through more than three methods: A1-B2, A1-X1-B1, A1-X1-C3-B1, etc. If table B is obtained through these three methods, it will result in collection Redundant table data and repeated operations during data restoration increase R&D implementation costs and reduce processing efficiency.
基于以上问题,在本发明的一个实施例中,该方法还包括:Based on the above problems, in one embodiment of the present invention, the method further includes:
在得到多个待处理表之后,判断多个待处理表中是否存在重复的表;若存在重复的表,则保留重复的表中的一张表,删除重复的表中的其他表。After obtaining multiple to-be-processed tables, determine whether there are duplicate tables in the multiple to-be-processed tables; if there are duplicate tables, retain one of the duplicate tables and delete the other tables in the duplicate tables.
关联关系模板为二叉树状的关联关系模板。The association relationship template is a binary tree-shaped association relationship template.
在发明实施例中,对于重复的表,只保留一个表,其他表删除,比如,表A和表B重复,那么保留表A和表B中的一个表,另一个表删除。避免出现重复的表,导致存在多种关联方式、冗余存储和重复还原问题,从而实现关联复杂度降低、提升恢复效率。如图8所示,剔除重复的表,极大地简化了表之间的关联关系。In the embodiment of the invention, for duplicate tables, only one table is retained and the other tables are deleted. For example, if table A and table B are duplicated, then one of table A and table B is retained and the other table is deleted. Avoid duplicate tables, which lead to multiple association methods, redundant storage and repeated restoration problems, thereby reducing association complexity and improving recovery efficiency. As shown in Figure 8, eliminating duplicate tables greatly simplifies the relationship between tables.
在本发明的一个实施例中,S103包括:In one embodiment of the present invention, S103 includes:
对至少一个值中的每个值,执行预定步骤,以得到与至少一个值中的每个值相关联的表数据。For each of the at least one value, predetermined steps are performed to obtain table data associated with each of the at least one value.
其中,预定步骤包括:Among them, the predetermined steps include:
将至少一个值中的当前待处理值作为起始值;根据关联关系模板中表的次序,依次采集与起始值相关联的至少一个待采集表;将每个待采集表中的字段值作为新的起始值,返回执行与新的起始值相关联的至少一个待采集表,直到满足第二预定条件时为止;将得到的所有待采集表中的数据,作为与当前待处理值相关联的表数据。Use the current value to be processed in at least one value as the starting value; according to the order of the tables in the association relationship template, collect at least one table to be collected associated with the starting value; use the field value in each table to be collected as New starting value, return and execute at least one to-be-collected table associated with the new starting value until the second predetermined condition is met; use all obtained data in the to-be-collected table as related to the current to-be-processed value linked table data.
其中,第二预定条件包括:在预定的采集范围内不存在与起始值相关联的待采集表。The second predetermined condition includes: there is no table to be collected associated with the starting value within the predetermined collection range.
作为一个示例,基于A1的字段值可以得到A、B、C和D表所有涉及的数据行内容,将数据行内容记录备份后即可用于后续的数据还原操作。As an example, based on the field value of A1, you can obtain the contents of all data rows involved in tables A, B, C, and D. After backing up the data row content records, you can use them for subsequent data restoration operations.
举例来说:在获取与某个具体的手机号码相关联的表数据时,将该手机号码作为起始值,根据关联关系模板中表的次序,先采集与该手机号码相关联的用户订购信息表;其次,将用户订购信息表中的字段值作为新的起始值,采集与该新的起始值相关联的用户订购属性信息表;再次,将用户订购属性信息表中的字段值作为新的起始值,采集与该新的起始值相关联的用户属性配置信息表。因此,根据关联关系模板中表的次序,依次采集用户订购信息表、用户订购属性信息表、以及用户属性配置信息表中的数据。For example: when obtaining table data associated with a specific mobile phone number, use the mobile phone number as the starting value, and first collect the user ordering information associated with the mobile phone number according to the order of the tables in the association template. table; secondly, use the field values in the user ordering information table as the new starting value, and collect the user ordering attribute information table associated with the new starting value; thirdly, use the field values in the user ordering attribute information table as A new starting value, and collecting the user attribute configuration information table associated with the new starting value. Therefore, according to the order of the tables in the association template, data in the user ordering information table, the user ordering attribute information table, and the user attribute configuration information table are collected sequentially.
在本发明的一个实施例中,S104包括:In one embodiment of the present invention, S104 includes:
在进行数据还原时,将预定的还原范围内的表数据替换成与目标值相关联的表数据。When performing data restoration, the table data within the predetermined restoration range is replaced with table data associated with the target value.
在本发明的一个实施例中,S104包括:In one embodiment of the present invention, S104 includes:
通过删除指令删除预定的还原范围内的表的数据,并通过插入指令插入与目标值相关联的表数据。Delete the data of the table within the predetermined restoration range through the delete instruction, and insert the table data associated with the target value through the insert instruction.
图9示出了本发明另一个实施例提供的数据还原方法的流程示意图。如图9所示,该方法包括:Figure 9 shows a schematic flowchart of a data restoration method provided by another embodiment of the present invention. As shown in Figure 9, the method includes:
S201,基于字段的关联关系,配置关联关系模板。S201: Configure an association template based on the field association relationship.
其中,S201包括:Among them, S201 includes:
S2011,根据业务测试、自动测试需要,选择预定表和预定字段并记录。如:移动行业中,由用户基本表下的手机号码开始,直接、间接关联出的数据表和数据行,其数据记录和还原后可满足约95%以上的业务测试需求。S2011, according to the needs of business testing and automatic testing, select the reservation table and reservation fields and record them. For example: In the mobile industry, starting from the mobile phone number under the basic user table, the data tables and data rows are directly or indirectly associated. After the data is recorded and restored, it can meet more than 95% of business testing needs.
S2012,梳理映射关系,将预定字段作为起始字段,在数据库中查找与起始字段所有直接关联的表并记录(或备份)。在记录时剔除已经记录的表。在记录时定义下一步数据采集的优先级次序。S2012: Sort out the mapping relationship, use the predetermined field as the starting field, search for all tables directly related to the starting field in the database and record (or back up) them. Exclude already logged tables when logging. Define the priority sequence for next data collection while recording.
S2013,以步骤S2012所得数据表中的字段为新的起始字段,重复S2012中的查找表的动作,直到将步骤S2012所得数据表中的全部字段查找完。在记录时剔除已经记录的表。S2013, use the fields in the data table obtained in step S2012 as new starting fields, and repeat the table lookup action in S2012 until all fields in the data table obtained in step S2012 are searched. Exclude already logged tables when logging.
S2014,以S2013所得数据表中的字段为新的起始字段,重复S2012中的查找表的动作,直到S2013步骤所得数据结果满足测试场景需求。在记录时剔除已经记录的数据表。S2014, use the field in the data table obtained in S2013 as the new starting field, and repeat the lookup table action in S2012 until the data result obtained in step S2013 meets the test scenario requirements. Exclude already recorded data tables during recording.
S2015,持久化存储S2014的结果,对于预定表的预定字段,之后无需再次执行S201操作。S2015, persistently stores the results of S2014. For the scheduled fields of the scheduled table, there is no need to perform the S201 operation again.
至此,基于预定字段的关联关系模板配置完成,交付一个二叉树形结果的业务测试维度数据表与字段之间的关系数据实例结果,即关联关系模板。该关联关系模板不依赖预定表、预定字段的具体值,任何不为空的字段值均可套用此关联关系模板直接或间接定位数据还原场景所需要的全量数据表中的数据行。At this point, the configuration of the association relationship template based on the predetermined fields is completed, and the relationship data instance result between the business test dimension data table and the fields is delivered as a binary tree result, that is, the association relationship template. This association template does not depend on the specific values of the predetermined table or predetermined fields. Any field value that is not empty can be applied to this association template to directly or indirectly locate the data rows in the full data table required for the data restoration scenario.
图10示出了本发明的一个实施例的配置关联关系模板的流程示意图。如图10所示,模板配置应用负责存储人为梳理后的目标数据库中的业务关联关系,并录入管理数据库的配置码表,此时的配置以伪SQL为主,即SQL语句的赋值部分中存在一些需在采集执行或还原执行时才可动态获取的变量,如操作时间、操作流水等。Figure 10 shows a schematic flowchart of configuring an association relationship template according to an embodiment of the present invention. As shown in Figure 10, the template configuration application is responsible for storing the business relationships in the target database that have been artificially sorted out, and entering the configuration code table of the management database. The configuration at this time is mainly pseudo-SQL, that is, there is a value in the assignment part of the SQL statement. Some variables that need to be dynamically obtained during collection execution or restoration execution, such as operation time, operation flow, etc.
S202,基于至少一个字段值和关联关系模板,采集表中的数据,并备份该采集的数据。S202: Collect data in the table based on at least one field value and association relationship template, and back up the collected data.
S202的交付是用于数据还原场景所需要的全量数据表内数据行的具体数据,用以采集数据还原场景中操作前的数据记录。不同的起始表和该起始表中的字段值,采集不同的数据。The delivery of S202 is the specific data of the data rows in the full data table required for the data restoration scenario to collect the data records before the operation in the data restoration scenario. Different starting tables and field values in the starting table collect different data.
其中,S202包括:Among them, S202 includes:
S2021:向系统应用输入存量目标模板和预定字段的至少一个有效的字段值。目标模板用以定义数据采集和数据还原的范围,有效的字段值是具体一次还原操作的数据起点。S2021: Input the stock target template and at least one valid field value of the predetermined field to the system application. The target template is used to define the scope of data collection and data restoration. The valid field value is the data starting point for a specific restore operation.
S2022:系统自动依据有效的字段值,将该字段值作为起始值,采集与该起始值关联的表的数据行全部内容。依据关联关系模板中表的次序,依次采集该起始值关联的每张表的数据,并备份。S2022: The system automatically uses the valid field value as the starting value and collects all the data row contents of the table associated with the starting value. According to the order of the tables in the relationship template, the data of each table associated with the starting value is collected in sequence and backed up.
S2023:以步骤S2022所得表中的字段值为新的起始值,重复步骤S2021中的操作动作,直到步骤S2022所得数据内容完整全面。S2023: Use the field value in the table obtained in step S2022 as the new starting value, and repeat the operation in step S2021 until the data content obtained in step S2022 is complete.
S2024:以步骤S2023得到的数据结果为新的起始值,重复步骤S2022,直到S2023步骤中关联关系模板中的配置关系全部处理一遍。S2024: Use the data result obtained in step S2023 as the new starting value, and repeat step S2022 until all configuration relationships in the association relationship template in step S2023 are processed.
S2025:持久化存储S2024的结果,以后每次测试场景数据还原无需执行S202操作。S2025: The results of S2024 are stored persistently. There is no need to perform the S202 operation every time the test scene data is restored in the future.
至此,基于至少一个字段值和关联关系模板,采集表中的数据,并完成备份该采集的数据,交付一个二叉树形结果的业务测试操作前记录的结果集。该结果集不依赖任意测试场景,所有操作表范围的测试均可重复使用。如:在移动通信行业中,由用户基本表下的手机号码完成S202操作后,可满足约95%以上的业务测试需求。At this point, based on at least one field value and association relationship template, the data in the table is collected, the collected data is backed up, and a result set recorded before the business test operation of a binary tree result is delivered. This result set does not depend on any test scenario and can be reused across all action table scope tests. For example: in the mobile communications industry, after the S202 operation is completed by the mobile phone number under the user's basic table, more than 95% of the business testing needs can be met.
图11示出了本发明的一个实施例的采集表数据的流程示意图。如图11所示,模板采集应用在内部主要由通用变量池和伪SQL执行块两个应用实体组成,前者作为通用访问区,以键值对的方式依次记录遇到的伪SQL变量K-V,后者根据数据模型的配置的常量、环境变量或SQL语句去动态获取伪SQL中变量的当前取值。如此循环,直到所有采集期间需要的伪SQL取值全部获取。采集伪SQL取值完成后,模型采集应用依据管理数据模型配置依次将删除(DELETE)伪SQL和插入(INSERT)伪SQL,以模板处理数据实例的方式入表。Figure 11 shows a schematic flow chart of collecting table data according to one embodiment of the present invention. As shown in Figure 11, the template collection application is internally mainly composed of two application entities: a general variable pool and a pseudo-SQL execution block. The former serves as a general access area and records the encountered pseudo-SQL variables K-V in the form of key-value pairs. The latter The user can dynamically obtain the current value of the variable in pseudo-SQL based on the configured constants, environment variables or SQL statements of the data model. This cycle continues until all pseudo-SQL values required during collection are obtained. After the collection of pseudo SQL values is completed, the model collection application will delete (DELETE) pseudo SQL and insert (INSERT) pseudo SQL in sequence according to the management data model configuration, and enter the table into the table in the way of template processing data instances.
S203,基于目标字段值、关联关系模板和备份的数据,执行数据库数据还原的操作。S203: Perform a database data restoration operation based on the target field value, the association template and the backed up data.
S203交付测试前数据准备阶段,用于测试的数据还原的所有数据内容。本步骤在关系型数据库中生成,基于S202备份的数据可以展开测试工作。本步骤可任意次重复执行,如:一个手机号执行S203后可用于多次、重复测试,以验证上线前测试环境下系统应用正确性,或严重上线后生产环境下系统的正确性。S203 delivers all data content in the pre-test data preparation phase for test data restoration. This step is generated in a relational database, and testing can be carried out based on the data backed up by S202. This step can be repeated any number of times. For example, after executing S203 on a mobile phone number, it can be used for multiple and repeated tests to verify the correctness of the system application in the test environment before going online, or the correctness of the system in the production environment after serious going online.
其中,S203包括:Among them, S203 includes:
S2031,向系统应用输入存量目标模板和有效的目标值。模板用以定义数据采集和还原范围,目标值是具体一次还原操作的数据起点,目标值是S2021中的至少一个有效的字段值中的值,目标值的数量可以是一个或多个。S2031. Input the stock target template and valid target value to the system application. The template is used to define the scope of data collection and restoration. The target value is the starting point of the data for a specific restore operation. The target value is the value in at least one valid field value in S2021. The number of target values can be one or more.
S2032,系统自动在S202备份的数据中提取目标值相关联的表数据,逐一替换数据删除的伪SQL中的KEY变量,生成删除SQL后执行。In S2032, the system automatically extracts the table data associated with the target value from the data backed up in S202, replaces the KEY variables in the pseudo SQL for data deletion one by one, generates the deletion SQL and executes it.
删除SQL的目的在于删除上一次测试或其他原因产生历史数据。The purpose of deleting SQL is to delete historical data generated by the last test or other reasons.
S2033,根据在S202备份的数据中提取目标值相关联的表数据,逐一替换数据还原的伪SQL中的KEY变量,生成还原SQL后执行。S2033: Extract the table data associated with the target value from the data backed up in S202, replace the KEY variables in the pseudo SQL for data restoration one by one, generate the restoration SQL and execute it.
S2034,步骤S2033全部执行完毕后且全部正确,数据库提交,并向系统上游反馈成功信息。S2033全部执行完毕后且出现错误,数据库回滚,并向系统上游反馈失败信息用于定位漏洞(BUG)。S2034. After all steps S2033 are executed and are correct, the database is submitted and success information is fed back to the upstream of the system. After all S2033 is executed and an error occurs, the database is rolled back, and failure information is fed back to the upstream of the system to locate vulnerabilities (BUGs).
至此,基于目标值、关联关系模板和备份的数据,执行操作后的数据库数据还原完成,交付一笔测试所需要的关系型数据库内容还原。S203在每次具体测试时重复调用、执行并交付。At this point, based on the target value, relationship template and backed-up data, the database data restoration after the operation is completed, and the relational database content restoration required for the test is delivered. S203 is repeatedly called, executed and delivered for each specific test.
图12示出了本发明的一个实施例的模板还原处理的流程示意图。如图12所示,模板还原处理应用内部主要由通用变量池和伪SQL执行块两个应用实体组成,前者作为通用访问区,以键值对的方式依次记录遇到的伪SQL变量K-V,后者根据数据模型的配置的常量、环境变量或SQL语句去动态获取伪SQL中变量的当前取值。如此循环,直到所有还原处理期间需要的伪SQL取值全部获取。Figure 12 shows a schematic flowchart of template restoration processing according to an embodiment of the present invention. As shown in Figure 12, the template restoration processing application mainly consists of two application entities: a general variable pool and a pseudo-SQL execution block. The former serves as a general access area and records the encountered pseudo-SQL variables K-V in the form of key-value pairs. The latter The user can dynamically obtain the current value of the variable in pseudo-SQL based on the configured constants, environment variables or SQL statements of the data model. This cycle continues until all pseudo-SQL values required during the restore process are obtained.
本发明实施例,首先从业务逻辑关系出发,通过模板设计和记录存储后,可有选择的自动还原测试需要的数据,本发明实施例解决了关系型数据库下测试环境维护问题,尤其是移动通信行业支撑系统中的客户关系管理(Customer Relationship Management,CRM)系统,可大幅提升日常开发测试效率。The embodiments of the present invention first start from the business logic relationship. After template design and record storage, the data required for testing can be selectively and automatically restored. The embodiments of the present invention solve the problem of test environment maintenance under the relational database, especially for mobile communications. The Customer Relationship Management (CRM) system in the industry support system can greatly improve the efficiency of daily development and testing.
其次,基于关系型数据库中数据表、字段的业务逻辑关系,实现数据还原场景的应用设计、流程设计和模型设计,解决了数据还原的操作低效问题,而且解决了不同测试场景下不同数据表数据还原的复杂问题,不仅提升测试测试效率,还可用于自动化、大规模系统自动回归测试。Secondly, based on the business logic relationships of data tables and fields in relational databases, the application design, process design and model design of data restoration scenarios are realized, which solves the problem of inefficient data restoration operations and solves the problem of different data tables in different test scenarios. The complex problem of data restoration not only improves test efficiency, but can also be used for automated and large-scale system automatic regression testing.
本发明实施例至少包括如下的四条优点:The embodiments of the present invention include at least the following four advantages:
1、解决关系型数据库批量同步低效和高成本问题,本发明实施例从具体测试场景中的单库局部数据出发,数据还原效率高,在2分钟内可完成一个测试用例的全数据还原,测试后可重复使用。1. Solve the problem of inefficiency and high cost of batch synchronization of relational databases. The embodiment of the present invention starts from the local data of a single database in a specific test scenario, and has high data restoration efficiency. The full data restoration of a test case can be completed within 2 minutes. Can be reused after testing.
2、解决数据维护效率低,资源难以共享问题,本发明实施例采用独立的数据维护体系,自动生成并交付的是测试案例中数据还原的DELETE和INSERT脚本,同一个测试号码可按需使用,只要测试时间(2分钟内)不同时发生就没有异常。2. To solve the problem of low data maintenance efficiency and difficulty in sharing resources, the embodiment of the present invention adopts an independent data maintenance system to automatically generate and deliver DELETE and INSERT scripts for data restoration in test cases. The same test number can be used on demand. As long as the test time (within 2 minutes) does not occur at the same time, there is no exception.
3、解决行业应用数据的复杂性问题,本发明实施例通过多模板、引入外部变量和伪SQL方式解决行业应用数据的复杂性问题,可根据具体场景需要自定义各个数据表的特殊字段,并且数据生成自动化,大幅提升复用性。3. Solve the complexity problem of industry application data. The embodiment of the present invention solves the complexity problem of industry application data through multiple templates, introducing external variables and pseudo-SQL. The special fields of each data table can be customized according to the needs of specific scenarios, and Data generation is automated, greatly improving reusability.
4、基于本提案数据可复用、自定义特殊字段特征,本发明实施例可支持大规模海量后台回归测试,测试场景和数据还原建立后,不依赖人工干预即可定时、定量完成自动回归测试,这是传统方案不能提供的。4. Based on the reusability of data in this proposal and the customization of special field characteristics, embodiments of the present invention can support large-scale and massive background regression testing. After the test scenarios and data restoration are established, automatic regression testing can be completed regularly and quantitatively without relying on manual intervention. , which traditional solutions cannot provide.
图13示出了本发明的一个实施例的数据还原装置的结构示意图。如图13所示,该装置300包括:Figure 13 shows a schematic structural diagram of a data restoration device according to an embodiment of the present invention. As shown in Figure 13, the device 300 includes:
关联表确定模块301,用于根据预定表中的预定字段,确定与预定字段关联的至少一张表。The association table determination module 301 is configured to determine at least one table associated with the predetermined field according to the predetermined field in the predetermined table.
模板形成模块302,用于根据预定表与至少一张表之间的关联关系,形成表之间的关联关系模板。The template forming module 302 is configured to form an association relationship template between tables based on an association relationship between a predetermined table and at least one table.
数据采集并备份模块303,用于根据关联关系模板,采集并备份与预定字段的至少一个值中的每个值相关联的表数据。The data collection and backup module 303 is configured to collect and back up table data associated with each value of at least one value of the predetermined field according to the association relationship template.
数据还原模块304,用于在备份的表数据中获取与至少一个值中的目标值相关联的表数据,以进行数据还原。The data restoration module 304 is configured to obtain table data associated with the target value in at least one value from the backup table data to perform data restoration.
在本发明的一个实施例中,关联表确定模块301包括:In one embodiment of the present invention, the association table determination module 301 includes:
第一起始字段确定模块,用于将预定字段作为起始字段;The first starting field determination module is used to use the predetermined field as the starting field;
表查找模块,用于查找与起始字段相关联的字段,将该字段所在的表作为待处理表。The table lookup module is used to find the field associated with the starting field, and the table where the field is located is used as the to-be-processed table.
第二起始字段确定模块,用于将待处理表中的每个字段作为新的起始字段。The second starting field determination module is used to use each field in the table to be processed as a new starting field.
表查找模块,还用于重复执行查找的步骤,直到满足第一预定条件时为止。The table search module is also used to repeatedly perform the search steps until the first predetermined condition is met.
第一表确定模块,用于将得到的所有待处理表作为至少一张表。The first table determination module is used to treat all the obtained tables to be processed as at least one table.
在本发明的一个实施例中,第一预定条件包括:查找不到与起始字段相关联的字段或者得到的待处理表满足测试场景需求。In one embodiment of the present invention, the first predetermined condition includes: a field associated with the starting field cannot be found or the obtained table to be processed meets the test scenario requirements.
在本发明的一个实施例中,该装置300还包括:In one embodiment of the invention, the device 300 further includes:
判断模块,用于在得到多个待处理表之后,判断多个待处理表中是否存在重复的表;The judgment module is used to judge whether there are duplicate tables in the multiple to-be-processed tables after obtaining multiple to-be-processed tables;
去重模块,用于当存在重复的表时,保留重复的表中的一张表,删除重复的表中的其他表。The deduplication module is used to retain one of the duplicate tables and delete other duplicate tables when there are duplicate tables.
在本发明的一个实施例中,关联关系模板为二叉树状的关联关系模板。In one embodiment of the present invention, the association relationship template is a binary tree-shaped association relationship template.
在本发明的一个实施例中,数据采集并备份模块303包括:In one embodiment of the present invention, the data collection and backup module 303 includes:
数据采集模块,用于对至少一个值中的每个值,执行预定步骤,以得到与至少一个值中的每个值相关联的表数据。The data collection module is configured to perform predetermined steps on each of the at least one value to obtain table data associated with each of the at least one value.
其中,数据采集模块包括:Among them, the data collection module includes:
第一起始值确定模块,用于将至少一个值中的当前待处理值作为起始值。The first starting value determination module is configured to use the current value to be processed in at least one value as the starting value.
表采集模块,用于根据关联关系模板中表的次序,依次采集与起始值相关联的至少一个待采集表。The table collection module is used to sequentially collect at least one to-be-collected table associated with the starting value according to the order of the tables in the association relationship template.
第二起始值确定模块,用于将每个待采集表中的字段值作为新的起始值。The second starting value determination module is used to use the field value in each table to be collected as a new starting value.
表采集模块,还用于重复执行与新的起始值相关联的至少一个待采集表,直到满足第二预定条件时为止。The table collection module is also configured to repeatedly execute at least one table to be collected associated with the new starting value until the second predetermined condition is met.
第二表确定模块,用于将得到的所有待采集表中的数据,作为与当前待处理值相关联的表数据。The second table determination module is used to use the obtained data in all tables to be collected as table data associated with the current value to be processed.
在本发明的一个实施例中,第二预定条件包括:在预定的采集范围内不存在与起始值相关联的待采集表。In one embodiment of the present invention, the second predetermined condition includes: there is no table to be collected associated with the starting value within the predetermined collection range.
在本发明的一个实施例中,数据还原模块304包括:In one embodiment of the present invention, the data restoration module 304 includes:
数据替换模块,用于将预定的还原范围内的表数据替换成与目标值相关联的表数据。The data replacement module is used to replace table data within a predetermined restore range with table data associated with the target value.
在本发明的一个实施例中,数据替换模块包括:In one embodiment of the invention, the data replacement module includes:
数据删除模块,用于通过删除指令删除预定的还原范围内的表的数据。The data deletion module is used to delete the data of the table within the predetermined restoration range through deletion instructions.
数据插入模块,用于通过插入指令插入与目标值相关联的表数据。Data insertion module is used to insert table data associated with target values through insert instructions.
在本发明的一个实施例中,数据采集并备份模块,用于在关系型数据库中采集与预定字段的至少一个值中的每个值相关联的表数据。In one embodiment of the present invention, the data collection and backup module is configured to collect table data associated with each value of at least one value of a predetermined field in a relational database.
数据还原模块,用于根据与目标值相关联的表数据,对关系型数据库中的数据进行还原。The data restoration module is used to restore data in the relational database based on the table data associated with the target value.
图14示出了本发明实施例提供的数据还原设备的硬件结构示意图。Figure 14 shows a schematic diagram of the hardware structure of a data restoration device provided by an embodiment of the present invention.
数据还原设备可以包括处理器401以及存储有计算机程序指令的存储器402。The data restoration device may include a processor 401 and a memory 402 storing computer program instructions.
具体地,上述处理器401可以包括中央处理器(CPU),或者特定集成电路(Application Specific Integrated Circuit,ASIC),或者可以被配置成实施本发明实施例的一个或多个集成电路。Specifically, the above-mentioned processor 401 may include a central processing unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured to implement one or more integrated circuits according to embodiments of the present invention.
存储器402可以包括用于数据或指令的大容量存储器。举例来说而非限制,存储器402可包括硬盘驱动器(Hard Disk Drive,HDD)、软盘驱动器、闪存、光盘、磁光盘、磁带或通用串行总线(Universal Serial Bus,USB)驱动器或者两个或更多个以上这些的组合。在合适的情况下,存储器402可包括可移除或不可移除(或固定)的介质。在合适的情况下,存储器402可在综合网关容灾设备的内部或外部。在特定实施例中,存储器402是非易失性固态存储器。在特定实施例中,存储器402包括只读存储器(ROM)。在合适的情况下,该ROM可以是掩模编程的ROM、可编程ROM(PROM)、可擦除PROM(EPROM)、电可擦除PROM(EEPROM)、电可改写ROM(EAROM)或闪存或者两个或更多个以上这些的组合。Memory 402 may include bulk storage for data or instructions. By way of example and not limitation, the memory 402 may include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a Universal Serial Bus (USB) drive or two or more A combination of many of the above. Memory 402 may include removable or non-removable (or fixed) media, where appropriate. Where appropriate, the memory 402 may be internal or external to the integrated gateway disaster recovery device. In certain embodiments, memory 402 is non-volatile solid-state memory. In certain embodiments, memory 402 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), electrically rewritable ROM (EAROM) or flash memory or A combination of two or more of these.
处理器401通过读取并执行存储器402中存储的计算机程序指令,以实现上述实施例中的任意一种数据还原方法。The processor 401 reads and executes the computer program instructions stored in the memory 402 to implement any of the data restoration methods in the above embodiments.
在一个示例中,数据还原设备还可包括通信接口403和总线410。其中,如图14所示,处理器401、存储器402、通信接口403通过总线410连接并完成相互间的通信。In one example, the data restoration device may also include a communication interface 403 and a bus 410. Among them, as shown in Figure 14, the processor 401, the memory 402, and the communication interface 403 are connected through the bus 410 and complete communication with each other.
通信接口403,主要用于实现本发明实施例中各模块、装置、单元和/或设备之间的通信。The communication interface 403 is mainly used to implement communication between modules, devices, units and/or equipment in the embodiment of the present invention.
总线410包括硬件、软件或两者,将数据还原设备的部件彼此耦接在一起。举例来说而非限制,总线可包括加速图形端口(AGP)或其他图形总线、增强工业标准架构(EISA)总线、前端总线(FSB)、超传输(HT)互连、工业标准架构(ISA)总线、无限带宽互连、低引脚数(LPC)总线、存储器总线、微信道架构(MCA)总线、外围组件互连(PCI)总线、PCI-Express(PCI-X)总线、串行高级技术附件(SATA)总线、视频电子标准协会局部(VLB)总线或其他合适的总线或者两个或更多个以上这些的组合。在合适的情况下,总线410可包括一个或多个总线。尽管本发明实施例描述和示出了特定的总线,但本发明考虑任何合适的总线或互连。Bus 410 includes hardware, software, or both, coupling the components of the data recovery device to one another. By way of example, and not limitation, the bus may include Accelerated Graphics Port (AGP) or other graphics bus, Enhanced Industry Standard Architecture (EISA) bus, Front Side Bus (FSB), HyperTransport (HT) interconnect, Industry Standard Architecture (ISA) Bus, Infinite Bandwidth Interconnect, Low Pin Count (LPC) Bus, Memory Bus, Micro Channel Architecture (MCA) Bus, Peripheral Component Interconnect (PCI) Bus, PCI-Express (PCI-X) Bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local (VLB) bus or other suitable bus or a combination of two or more of these. Where appropriate, bus 410 may include one or more buses. Although embodiments of the invention describe and illustrate a particular bus, the invention contemplates any suitable bus or interconnection.
该数据还原设备可以执行本发明实施例中的数据还原方法,从而实现结合图1和图13描述的数据还原方法和装置。The data restoration device can execute the data restoration method in the embodiment of the present invention, thereby realizing the data restoration method and device described in conjunction with FIG. 1 and FIG. 13 .
另外,结合上述实施例中的数据还原方法,本发明实施例可提供一种计算机存储介质来实现。该计算机存储介质上存储有计算机程序指令;该计算机程序指令被处理器执行时实现上述实施例中的任意一种数据还原方法。In addition, combined with the data restoration method in the above embodiment, the embodiment of the present invention can be implemented by providing a computer storage medium. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the data restoration methods in the above embodiments is implemented.
需要明确的是,本发明并不局限于上文所描述并在图中示出的特定配置和处理。为了简明起见,这里省略了对已知方法的详细描述。在上述实施例中,描述和示出了若干具体的步骤作为示例。但是,本发明的方法过程并不限于所描述和示出的具体步骤,本领域的技术人员可以在领会本发明的精神后,作出各种改变、修改和添加,或者改变步骤之间的顺序。It is to be understood that this invention is not limited to the specific arrangements and processes described above and illustrated in the drawings. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications and additions, or change the order between steps after understanding the spirit of the present invention.
以上所述的结构框图中所示的功能块可以实现为硬件、软件、固件或者它们的组合。当以硬件方式实现时,其可以例如是电子电路、专用集成电路(ASIC)、适当的固件、插件、功能卡等等。当以软件方式实现时,本发明的元素是被用于执行所需任务的程序或者代码段。程序或者代码段可以存储在机器可读介质中,或者通过载波中携带的数据信号在传输介质或者通信链路上传送。“机器可读介质”可以包括能够存储或传输信息的任何介质。机器可读介质的例子包括电子电路、半导体存储器设备、ROM、闪存、可擦除ROM(EROM)、软盘、CD-ROM、光盘、硬盘、光纤介质、射频(RF)链路,等等。代码段可以经由诸如因特网、内联网等的计算机网络被下载。The functional blocks shown in the above structural block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, or the like. When implemented in software, elements of the invention are programs or code segments used to perform the required tasks. The program or code segments may be stored in a machine-readable medium or transmitted over a transmission medium or communications link via a data signal carried in a carrier wave. "Machine-readable medium" may include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, and the like. Code segments may be downloaded via computer networks such as the Internet, intranets, and the like.
还需要说明的是,本发明中提及的示例性实施例,基于一系列的步骤或者装置描述一些方法或系统。但是,本发明不局限于上述步骤的顺序,也就是说,可以按照实施例中提及的顺序执行步骤,也可以不同于实施例中的顺序,或者若干步骤同时执行。It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps. That is to say, the steps may be performed in the order mentioned in the embodiments, or may be different from the order in the embodiments, or several steps may be performed simultaneously.
以上所述,仅为本发明的具体实施方式,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、模块和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。应理解,本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本发明的保护范围之内。The above are only specific implementations of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the above-described systems, modules and units can be referred to the foregoing method embodiments. The corresponding process will not be described again here. It should be understood that the protection scope of the present invention is not limited thereto. Any person familiar with the technical field can easily think of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should be covered. within the protection scope of the present invention.
Claims (13)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811629215.4A CN111382198B (en) | 2018-12-28 | 2018-12-28 | Data recovery method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811629215.4A CN111382198B (en) | 2018-12-28 | 2018-12-28 | Data recovery method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111382198A CN111382198A (en) | 2020-07-07 |
CN111382198B true CN111382198B (en) | 2023-09-19 |
Family
ID=71214753
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811629215.4A Active CN111382198B (en) | 2018-12-28 | 2018-12-28 | Data recovery method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111382198B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112699187B (en) * | 2020-12-29 | 2023-05-16 | 中国联合网络通信集团有限公司 | Associated data processing method, device, equipment, medium and product |
CN113127359B (en) * | 2021-04-23 | 2025-03-07 | 中国工商银行股份有限公司 | A method and device for obtaining test data |
CN113204566B (en) * | 2021-06-09 | 2024-01-26 | 中国银行股份有限公司 | Execution method and device of SQL script |
CN118626472A (en) * | 2024-06-20 | 2024-09-10 | 深圳市银雁科技有限公司 | Database optimization method, device, electronic device and storage medium |
CN118779151A (en) * | 2024-06-24 | 2024-10-15 | 深圳市雁联计算系统有限公司 | Database backup method, device, electronic equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6651077B1 (en) * | 2000-09-27 | 2003-11-18 | Microsoft Corporation | Backup and restoration of data in an electronic database |
WO2007137468A1 (en) * | 2006-05-26 | 2007-12-06 | Huawei Technologies Co., Ltd. | Method and system for creating relational model automatically |
CN102096669A (en) * | 2009-12-14 | 2011-06-15 | 深圳速浪数字技术有限公司 | Data backup method and data backup device |
CN106445727A (en) * | 2015-08-07 | 2017-02-22 | 中国移动通信集团重庆有限公司 | Data backup and recovery method and system |
CN107220251A (en) * | 2016-03-21 | 2017-09-29 | 阿里巴巴集团控股有限公司 | Generate the method and device of description information |
US9959175B1 (en) * | 2015-06-30 | 2018-05-01 | Spanning Cloud Apps, LLC | Restoring deleted objects in a web application |
CN108509485A (en) * | 2018-02-07 | 2018-09-07 | 深圳壹账通智能科技有限公司 | Preprocess method, device, computer equipment and the storage medium of data |
CN108563535A (en) * | 2018-04-27 | 2018-09-21 | 四川巧夺天工信息安全智能设备有限公司 | A kind of restoration methods to the full library of MySQL database |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8117187B2 (en) * | 2005-10-28 | 2012-02-14 | Mediareif Moestl & Reif Kommunikations-Und Informationstechnologien Oeg | Method for controlling a relational database system |
US20130232106A1 (en) * | 2012-03-01 | 2013-09-05 | Cover-All Technologies, Inc. | System and Method For Applying An Update To A Database |
-
2018
- 2018-12-28 CN CN201811629215.4A patent/CN111382198B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6651077B1 (en) * | 2000-09-27 | 2003-11-18 | Microsoft Corporation | Backup and restoration of data in an electronic database |
WO2007137468A1 (en) * | 2006-05-26 | 2007-12-06 | Huawei Technologies Co., Ltd. | Method and system for creating relational model automatically |
CN102096669A (en) * | 2009-12-14 | 2011-06-15 | 深圳速浪数字技术有限公司 | Data backup method and data backup device |
US9959175B1 (en) * | 2015-06-30 | 2018-05-01 | Spanning Cloud Apps, LLC | Restoring deleted objects in a web application |
CN106445727A (en) * | 2015-08-07 | 2017-02-22 | 中国移动通信集团重庆有限公司 | Data backup and recovery method and system |
CN107220251A (en) * | 2016-03-21 | 2017-09-29 | 阿里巴巴集团控股有限公司 | Generate the method and device of description information |
CN108509485A (en) * | 2018-02-07 | 2018-09-07 | 深圳壹账通智能科技有限公司 | Preprocess method, device, computer equipment and the storage medium of data |
CN108563535A (en) * | 2018-04-27 | 2018-09-21 | 四川巧夺天工信息安全智能设备有限公司 | A kind of restoration methods to the full library of MySQL database |
Non-Patent Citations (1)
Title |
---|
王伟平 ; 王子卿. Oracle用户SQL会话还原方法研究.《计算机工程与应用》.2008,全文. * |
Also Published As
Publication number | Publication date |
---|---|
CN111382198A (en) | 2020-07-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111382198B (en) | Data recovery method, device, equipment and storage medium | |
CN107391628B (en) | Data synchronization method and device | |
CN108415835B (en) | Distributed data library test method, device, equipment and computer-readable medium | |
CN113553313A (en) | Data migration method and system, storage medium and electronic device | |
CN114896641B (en) | Data verification method, device, electronic device and computer readable storage medium | |
Kvet et al. | Complex time management in databases | |
CN110609860A (en) | Data ETL processing method, device, equipment and storage medium | |
CN111240891A (en) | Data recovery method and device based on data consistency among multiple tables of database | |
CN114676161A (en) | A data processing method, device, equipment and storage medium | |
CN104748757A (en) | Data updating method and device for navigation electronic map | |
WO2020238348A1 (en) | Block verification method, apparatus and device | |
CN115827636B (en) | Method for storing and reading simulation data of logic system design from waveform database | |
CN112699129A (en) | Data processing system, method and device | |
CN111400299A (en) | Method and system for testing fusion quality of multiple data | |
CN114253930A (en) | Data processing method, apparatus, equipment and storage medium | |
WO2021129005A1 (en) | Blockchain state change-based transaction tracking method and device | |
CN112163024B (en) | A method for exporting and importing configuration information based on hierarchical association structure | |
Pritz et al. | Performance Impact of Parallel Access of Time Series in the Context of Relational, NoSQL and NewSQL Database Management Systems | |
CN114661604A (en) | Data generation method, device, equipment and computer storage medium | |
CN113010495A (en) | Database optimization method and device | |
CN113326268A (en) | Data writing and reading method and device | |
US8326808B2 (en) | Information processing apparatus, and information processing method, program, and recording medium | |
CN111782641A (en) | Data error repairing method and system | |
CN114385644A (en) | Dimensional data processing method, device, device and storage medium | |
US10055297B1 (en) | System, method, and computer program for smart database inflation |
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 |