CN108182203A - Data checking method and device - Google Patents
Data checking method and device Download PDFInfo
- Publication number
- CN108182203A CN108182203A CN201711317304.0A CN201711317304A CN108182203A CN 108182203 A CN108182203 A CN 108182203A CN 201711317304 A CN201711317304 A CN 201711317304A CN 108182203 A CN108182203 A CN 108182203A
- Authority
- CN
- China
- Prior art keywords
- data
- data result
- result set
- result collection
- collection
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2365—Ensuring data consistency and integrity
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Computer Security & Cryptography (AREA)
- 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 data checking method and device.
背景技术Background technique
如今,不同的业务系统大多采用不同的数据库,不同数据库之间可能又需要共用同一部分数据的情况,因此为保证不同数据库中的相关数据的一致性,需要对不同数据库中的相关数据进行核对。Nowadays, different business systems mostly use different databases, and different databases may need to share the same part of data. Therefore, in order to ensure the consistency of related data in different databases, it is necessary to check the related data in different databases.
目前,每一次进行数据核对时,主要是由技术人员利用数据库连接工具逐个的连接需要进行核对的数据库,然后从每一个数据库中均提取出相关数据,并进行一一核对。可见,每一次的数据核对还需要人工干预,用户体验较差。At present, each time data checking is performed, technicians use database connection tools to connect to the databases to be checked one by one, and then extract relevant data from each database and check them one by one. It can be seen that manual intervention is required for each data verification, and the user experience is poor.
发明内容Contents of the invention
本发明实施例提供了一种数据核对方法,能够自动进行数据核对,提高用户体验。The embodiment of the present invention provides a data checking method, which can automatically perform data checking and improve user experience.
第一方面,本发明实施例提供了一种数据核对方法,包括:In a first aspect, an embodiment of the present invention provides a data checking method, including:
从目标数据库中读取所需视图;Read the desired view from the target database;
从所述目标数据库中获取与所述视图相对应的第一数据结果集;Acquiring a first data result set corresponding to the view from the target database;
根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集。According to the first data result set, check the second data result set corresponding to the first data result set in the local database.
优选地,Preferably,
在所述从所述目标数据库中获取与所述视图相对应的第一数据结果集之后,且在根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集之前,进一步包括:After the acquisition of the first data result set corresponding to the view from the target database, and according to the first data result set, checking the first data result set corresponding to the first data result set in the local database Before the second data result set, further include:
在所述本地数据库中创建临时表;creating a temporary table in said local database;
将所述第一数据结果集插入到所述临时表中;inserting the first data result set into the temporary table;
所述根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集,包括:The checking the second data result set corresponding to the first data result set in the local database according to the first data result set includes:
根据所述临时表中插入的所述第一数据结果集,通过调用执行SQL,核对所述本地数据库中的所述第二数据结果集。Checking the second data result set in the local database by calling and executing SQL according to the first data result set inserted in the temporary table.
优选地,Preferably,
在所述根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集之后,进一步包括:After checking the second data result set corresponding to the first data result set in the local database according to the first data result set, further comprising:
当核对出所述第二数据结果集与所述第一数据结果集不一致时,更新所述第二数据结果集,以使更新后的所述第二数据结果集与所述第一数据结果集一致。When it is checked that the second data result set is inconsistent with the first data result set, update the second data result set so that the updated second data result set is consistent with the first data result set unanimous.
优选地,Preferably,
所述更新所述第二数据结果集,包括:The updating the second data result set includes:
根据核对的结果,确定所述第一数据结果集中新增的新增数据;According to the checking result, determine the newly added data added in the first data result set;
将所述新增数据同步至所述第二数据结果集中。Synchronizing the newly added data into the second data result set.
优选地,Preferably,
所述更新所述第二数据结果集,包括:The updating the second data result set includes:
根据核对的结果,确定所述第一数据结果集中更改后的更改数据;According to the checking result, determine the modified data in the first data result set after modification;
将所述第二数据结果集中的目标数据更改为所述更改数据,其中,所述目标数据与所述更改数据相对应;changing target data in the second data result set to the changed data, wherein the target data corresponds to the changed data;
优选地,Preferably,
所述更新所述第二数据结果集,包括:The updating the second data result set includes:
根据核对的结果,确定所述第一数据结果集中已删除的删除数据;According to the result of checking, determine the deleted deleted data in the first data result set;
删除所述第二数据结果集中所包括的所述删除数据。and deleting the deleted data included in the second data result set.
优选地,Preferably,
在所述从目标数据库中读取所需视图之前,进一步包括:Before reading the required view from the target database, further include:
按照预设的核对周期,周期性的根据预设的所述目标数据库的连接信息,建立与所述目标数据库之间的连接。According to the preset checking period, the connection with the target database is established periodically according to the preset connection information of the target database.
优选地,Preferably,
在所述根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集之后,进一步包括:After checking the second data result set corresponding to the first data result set in the local database according to the first data result set, further comprising:
当核对出所述第二数据结果集与所述第一数据结果集不一致时,生成用于指示数据核对不一致的反馈信息;When it is checked that the second data result set is inconsistent with the first data result set, generating feedback information for indicating that the data verification is inconsistent;
将所述反馈信息发送至预设的至少一个目标地址。Send the feedback information to at least one preset target address.
第二方面,本发明实施例提供了一种数据核对装置,包括:In a second aspect, an embodiment of the present invention provides a data checking device, including:
视图读取单元、数据获取单元以及数据核对单元,其中,View reading unit, data acquisition unit and data checking unit, wherein,
所述视图读取单元,用于从目标数据库中读取所需视图;The view reading unit is used to read the required view from the target database;
所述数据获取单元,用于从所述目标数据库中获取与所述视图相对应的第一数据结果集;The data acquisition unit is configured to acquire a first data result set corresponding to the view from the target database;
所述数据核对单元,用于根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集。The data checking unit is configured to check a second data result set corresponding to the first data result set in the local database according to the first data result set.
优选地,Preferably,
进一步包括:创建单元;further includes: creating a unit;
所述创建单元,用于在所述数据获取单元从所述目标数据库中获取与所述视图相对应的第一数据结果集之后,且在所述数据核对单元根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集之前,在所述本地数据库中创建临时表;将所述第一数据结果集插入到所述临时表中;The creating unit is configured to, after the data obtaining unit obtains the first data result set corresponding to the view from the target database, and after the data checking unit according to the first data result set, Before checking the second data result set corresponding to the first data result set in the local database, create a temporary table in the local database; insert the first data result set into the temporary table;
所述数据核对单元,用于根据所述临时表中插入的所述第一数据结果集,通过调用执行SQL,核对所述本地数据库中的所述第二数据结果集。The data checking unit is configured to check the second data result set in the local database by calling and executing SQL according to the first data result set inserted in the temporary table.
优选地,Preferably,
进一步包括:连接单元;Further comprising: a connection unit;
所述连接单元,用于在所述视图读取单元从所述目标数据库中读取所需视图之前,按照预设的核对周期,周期性的根据预设的所述目标数据库的连接信息,建立与所述目标数据库之间的连接。The connection unit is configured to, before the view reading unit reads the required view from the target database, according to the preset checking cycle, periodically establish a view according to the preset connection information of the target database. A connection to the target database.
优选地,Preferably,
进一步包括:更新单元;further comprising: an update unit;
所述更新单元,用于在所述数据核对单元核对出所述第二数据结果集与所述第一数据结果集不一致时,更新所述第二数据结果集,以使更新后的所述第二数据结果集与所述第一数据结果集一致。The updating unit is configured to update the second data result set when the data checking unit checks that the second data result set is inconsistent with the first data result set, so that the updated first data result set The second data result set is consistent with the first data result set.
优选地,Preferably,
所述更新单元,用于根据核对的结果,确定所述第一数据结果集中新增的新增数据;将所述新增数据同步至所述第二数据结果集中。The updating unit is configured to determine the newly added data in the first data result set according to the checking result; and synchronize the added data to the second data result set.
优选地,Preferably,
所述更新单元,用于根据核对的结果,确定所述第一数据结果集中更改后的更改数据;将所述第二数据结果集中的目标数据更改为所述更改数据,其中,所述目标数据与所述更改数据相对应;The update unit is configured to determine the modified data in the first data result set according to the checking result; change the target data in the second data result set to the modified data, wherein the target data Corresponding to said modified data;
优选地,Preferably,
所述更新单元,用于根据核对的结果,确定所述第一数据结果集中已删除的删除数据;删除所述第二数据结果集中所包括的所述删除数据。The updating unit is configured to determine the deleted data in the first data result set according to the checking result; and delete the deleted data included in the second data result set.
本发明实施例提供了一种数据核对方法及装置,每一次进行数据核对时,将会自动从相应的目标数据库读取到所需视图,通过该所需视图,能够从目标数据库中获取到标准的第一数据结果集,这样,接下来就可根据该第一数据结果集,完成对本地数据库中与该第一数据结果集相对应的第二数据结果集的核对。整个数据核对过程无需人工参与,可自动实现,提高了用户体验。The embodiment of the present invention provides a data checking method and device. Each time data checking is performed, the required view will be automatically read from the corresponding target database, and the standard view can be obtained from the target database through the required view. In this way, according to the first data result set, the check of the second data result set corresponding to the first data result set in the local database can be completed. The entire data verification process can be realized automatically without manual participation, which improves the user experience.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are For some embodiments of the present invention, those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1是本发明一个实施例提供的一种数据核对方法的流程图;Fig. 1 is a flow chart of a data checking method provided by an embodiment of the present invention;
图2是本发明另一个实施例提供的一种数据核对方法的流程图;Fig. 2 is a flow chart of a data checking method provided by another embodiment of the present invention;
图3是本发明一个实施例提供的一种数据核对装置的结构示意图;Fig. 3 is a schematic structural diagram of a data checking device provided by an embodiment of the present invention;
图4是本发明另一个实施例提供的一种数据核对装置的结构示意图;Fig. 4 is a schematic structural diagram of a data checking device provided by another embodiment of the present invention;
图5是本发明又一个实施例提供的一种数据核对装置的结构示意图;Fig. 5 is a schematic structural diagram of a data checking device provided by another embodiment of the present invention;
图6是本发明再一个实施例提供的一种数据核对装置的结构示意图。Fig. 6 is a schematic structural diagram of a data checking device provided by another embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例,基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work belong to the protection of the present invention. scope.
如图1所示,本发明实施例提供了一种数据核对方法,该方法可以包括以下步骤:As shown in Figure 1, an embodiment of the present invention provides a data checking method, which may include the following steps:
步骤101:从目标数据库中读取所需视图。Step 101: Read the required view from the target database.
步骤102:从所述目标数据库中获取与所述视图相对应的第一数据结果集。Step 102: Obtain a first data result set corresponding to the view from the target database.
步骤103:根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集。Step 103: Check the second data result set corresponding to the first data result set in the local database according to the first data result set.
本发明实施例提供了一种数据核对方法,每一次进行数据核对时,将会自动从相应的目标数据库读取到所需视图,通过该所需视图,能够从目标数据库中获取到标准的第一数据结果集,这样,接下来就可根据该第一数据结果集,完成对本地数据库中与该第一数据结果集相对应的第二数据结果集的核对。整个数据核对过程无需人工参与,可自动实现,提高了用户体验。The embodiment of the present invention provides a data checking method. Each time data checking is performed, the required view will be automatically read from the corresponding target database, and the standard first view can be obtained from the target database through the required view. A data result set. In this way, the second data result set corresponding to the first data result set in the local database can then be checked according to the first data result set. The entire data verification process can be realized automatically without manual participation, which improves the user experience.
在本发明一个实施例中,在所述步骤102之后,且在所述步骤103之前,进一步包括:在所述本地数据库中创建临时表;将所述第一数据结果集插入到所述临时表中;所述步骤103的具体实施方式,可包括:根据所述临时表中插入的所述第一数据结果集,通过调用执行SQL,核对所述本地数据库中的所述第二数据结果集。In one embodiment of the present invention, after the step 102 and before the step 103, further comprising: creating a temporary table in the local database; inserting the first data result set into the temporary table In; the specific implementation manner of step 103 may include: checking the second data result set in the local database by calling and executing SQL according to the first data result set inserted in the temporary table.
在本发明实施例中,可利用JAVA程序创建临时表。通过将来自不同数据库的数据放在同一个数据库中(也即,将从目标数据库获取到的第一数据结果集放在了本地数据库中),然后通过调用执行SQL,即可快速比对第一数据结果集和第二数据结果集,提高了执行效率,从而本发明实施例能够更快速的实现数据核对。In the embodiment of the present invention, a JAVA program can be used to create a temporary table. By putting data from different databases in the same database (that is, putting the first data result set obtained from the target database in the local database), and then calling and executing SQL, you can quickly compare the first The data result set and the second data result set improve execution efficiency, so that the embodiment of the present invention can realize data verification more quickly.
除此之外,也可通过其它另外一种方式实现。也即,在从目标数据库获取到第一数据结果集之后,不再创建临时表,而是首先获取本地数据库中相应的所需视图(该所需视图与从目标数据库获取到的所需视图是相同的,但是相同的视图在不同的数据库中却有可能对应不同的数据),然后根据该所需视图,可获取到本地数据库中与第一数据结果集相对应的第二数据结果集,接下来就可将从本地数据库中获取到的第二数据结果集与从目标数据库获取到的第一数据结果集进行核对,以查看第二数据结果集是否与第一数据结果集一致。Besides, it can also be realized in another way. That is, after the first data result set is obtained from the target database, no temporary table is created, but the corresponding required view in the local database is firstly obtained (the required view is the same as the required view obtained from the target database same, but the same view may correspond to different data in different databases), then according to the required view, the second data result set corresponding to the first data result set in the local database can be obtained, and then Next, the second data result set obtained from the local database can be checked with the first data result set obtained from the target database to check whether the second data result set is consistent with the first data result set.
需要说明的是,提到的第一数据结果集和第二数据结果集只是方便区分,并没有顺序上的差别。It should be noted that the first data result set and the second data result set mentioned are only for convenience of distinction, and there is no difference in order.
在本发明一个实施例中,为了保证各个数据库中的相关数据的一致性,在所述步骤103之后,可进一步包括:当核对出所述第二数据结果集与所述第一数据结果集不一致时,更新所述第二数据结果集,以使更新后的所述第二数据结果集与所述第一数据结果集一致。In one embodiment of the present invention, in order to ensure the consistency of relevant data in each database, after the step 103, it may further include: when checking that the second data result set is inconsistent with the first data result set , updating the second data result set so that the updated second data result set is consistent with the first data result set.
由于不同的数据库中可能需要共用相关数据,因此在核对出两个数据库中存储的相关数据不一致时,则需要进行同步更新。在本发明实施例中,是以目标数据库中的第一数据结果集为标准,然后对本地数据库中的相关第二数据结果集进行更新。Since different databases may need to share related data, when it is checked that the related data stored in the two databases is inconsistent, a synchronous update is required. In the embodiment of the present invention, the first data result set in the target database is used as a standard, and then the related second data result set in the local database is updated.
值得说明的是,提到的目标数据库可以是任意一个数据库,如,也可以是第三方数据库。It is worth noting that the mentioned target database can be any database, for example, it can also be a third-party database.
在本发明一个实施例中,所述更新所述第二数据结果集,包括:根据核对的结果,确定所述第一数据结果集中新增的新增数据;将所述新增数据同步至所述第二数据结果集中。In an embodiment of the present invention, the updating of the second data result set includes: determining the newly added data in the first data result set according to the result of checking; synchronizing the added data to the the second data result set.
例如,以待核对的数据为财务部门的员工信息为例,假设本地数据库中的第二数据结果集中共包含“张三”和“李四”两个员工的基本信息,而从目标数据库中获取到的第一数据结果集中共包含“张三”、“李四”和“王五”三个员工的基本信息(假设“张三”和“李四”两个员工的基本信息在本地数据库和目标数据库中均是相同的),则通过核对可以知晓,“王五”的基本信息为目标数据库中的新增数据,因此为了保证数据的一致性,应该将“王五”的基本信息也同步到本地数据库中的第二数据结果集中。For example, taking the data to be checked as the employee information of the financial department as an example, assuming that the second data result set in the local database contains the basic information of two employees, "Zhang San" and "Li Si", and the information obtained from the target database The obtained first data result set contains the basic information of three employees "Zhang San", "Li Si" and "Wang Wu" (assuming that the basic information of the two employees "Zhang San" and "Li Si" is stored in the local database and are the same in the target database), it can be known by checking that the basic information of "Wang Wu" is new data in the target database, so in order to ensure data consistency, the basic information of "Wang Wu" should also be synchronized to the second data result set in the local database.
在本发明一个实施例中,所述更新所述第二数据结果集,包括:根据核对的结果,确定所述第一数据结果集中更改后的更改数据;将所述第二数据结果集中的目标数据更改为所述更改数据,其中,所述目标数据与所述更改数据相对应。In one embodiment of the present invention, the updating of the second data result set includes: determining the modified data in the first data result set according to the checking result; The data is changed to the changed data, wherein the target data corresponds to the changed data.
同样,以待核对的数据为财务部门的员工信息为例,且本地数据库中的第二数据结果集中共包含“张三”和“李四”两个员工的基本信息,从目标数据库获取到的第一数据结果集也共包含“张三”和“李四”两个员工的基本信息,只不过第一数据结果集中的“张三”基本信息中的年龄更改为30岁(假设其它数据一致),则通过核对可以知晓,“张三”的基本信息中的年龄30岁即为更改数据,所以在更新第二数据结果集时,需要将第二数据结果集中的“张三”的年龄也更改为30,从而保证与第一数据结果集中的数据一致性。Similarly, taking the data to be checked as the employee information of the financial department as an example, and the second data result set in the local database contains the basic information of two employees "Zhang San" and "Li Si", the information obtained from the target database The first data result set also contains the basic information of two employees "Zhang San" and "Li Si", but the age in the basic information of "Zhang San" in the first data result set is changed to 30 years old (assuming that other data are consistent ), then it can be known by checking that the age of 30 years old in the basic information of "Zhang San" is the changed data, so when updating the second data result set, the age of "Zhang San" in the second data result set needs to be also Change it to 30 to ensure data consistency with the first data result set.
在本发明一个实施例中,所述更新所述第二数据结果集,包括:根据核对的结果,确定所述第一数据结果集中已删除的删除数据;删除所述第二数据结果集中所包括的所述删除数据。In an embodiment of the present invention, the updating the second data result set includes: determining the deleted data in the first data result set according to the result of checking; deleting the deleted data included in the second data result set of the deleted data.
同样,也以待核对的数据为财务部门的员工信息为例,且本地数据库中的第二数据结果集中共包含“张三”和“李四”两个员工的基本信息,而从目标数据库获取到的第一数据结果集中共包含“张三”一个员工的基本信息(假设该员工的基本信息与本地数据库中的该员工的基本信息一致),则通过核对可以知晓,“李四”的基本信息即为删除数据,所以接下来在更新本地数据库中的第二数据结果集时,应该将第二数据结果集中的“李四”的基本信息进行删除,从而保证了与目标数据库中的第一数据结果集的数据一致性。Similarly, the data to be checked is the employee information of the financial department as an example, and the second data result set in the local database contains the basic information of two employees "Zhang San" and "Li Si" in total, while the information obtained from the target database The first data result set obtained contains the basic information of an employee "Zhang San" (assuming that the basic information of the employee is consistent with the basic information of the employee in the local database), then it can be known through checking that the basic information of "Li Si" The information is the deleted data, so when updating the second data result set in the local database, the basic information of "Li Si" in the second data result set should be deleted, so as to ensure the consistency with the first data in the target database. Data consistency of the data result set.
在本发明一个实施例中,在所述步骤101之前,可进一步包括:按照预设的核对周期,周期性的根据预设的所述目标数据库的连接信息,建立与所述目标数据库之间的连接。In one embodiment of the present invention, before the step 101, it may further include: according to the preset checking cycle, periodically establish the connection information with the target database according to the preset connection information of the target database connect.
本发明实施例中,可有两种与目标数据库建立连接的方式,一种是,通过预设的目标数据库的连接信息,建立一次连接之后,不断开,以通过本次连接间断的从目标数据库获取多次视图,另一种是,每经过一个核对周期均需要与目标数据库建立一次连接,然后再获取所需视图。具体的连接方式的选定,用户可依据实际需求进行设定。In the embodiment of the present invention, there are two ways to establish a connection with the target database. One is to use the preset connection information of the target database. The other is to obtain multiple views, and the other is to establish a connection with the target database every time a checking cycle passes, and then obtain the required views. The selection of the specific connection mode can be set by the user according to the actual needs.
其中,连接信息可以指的是目标数据库的IP、目标数据库的登入用户名以及目标数据库的登入密码等等。Wherein, the connection information may refer to the IP of the target database, the login user name of the target database, the login password of the target database, and the like.
在本发明一个实施例中,在所述步骤103之后,可进一步包括:当核对出所述第二数据结果集与所述第一数据结果集不一致时,生成用于指示数据核对不一致的反馈信息;将所述反馈信息发送至预设的至少一个目标地址。In one embodiment of the present invention, after the step 103, it may further include: when it is checked that the second data result set is inconsistent with the first data result set, generating feedback information for indicating data verification inconsistency ; Send the feedback information to at least one preset target address.
为了能够提醒相关技术人员,可预先设置相关的几个邮箱地址,然后在核对出数据不一致时,则向这几个邮箱地址发送反馈信息,以通知相关的技术人员本次核对不一致,同时还可将具体不一致的数据发送至各个邮箱地址。In order to be able to remind the relevant technical personnel, several related email addresses can be set in advance, and then when the data is inconsistent after checking, send feedback information to these email addresses to notify the relevant technical personnel of the inconsistent verification. Send specific inconsistent data to individual email addresses.
为了能够进行记录,在核对的过程中,还可生成相应的日志,以便后续进行查找。In order to be able to record, in the process of checking, corresponding logs can also be generated for subsequent search.
下面将详细说明本发明实施例提供的一种数据核对方法,如图2所示,该方法可以包括如下步骤:A data verification method provided by an embodiment of the present invention will be described in detail below. As shown in FIG. 2, the method may include the following steps:
步骤201:按照预设的核对周期,周期性的根据预设的目标数据库的连接信息,建立与目标数据库之间的连接。Step 201: Establish a connection with the target database periodically according to the preset connection information of the target database according to the preset checking period.
本发明实施例中,只是以其中一种连接方式进行举例。In the embodiment of the present invention, only one connection manner is used as an example.
例如,核对周期为48小时,目标数据库为第三方数据库。For example, the verification period is 48 hours, and the target database is a third-party database.
步骤202:从目标数据库中读取所需视图。Step 202: Read the required view from the target database.
步骤203:从目标数据库中获取与所需视图相对应的第一数据结果集。Step 203: Obtain the first data result set corresponding to the desired view from the target database.
步骤204:在本地数据库中创建临时表。Step 204: Create a temporary table in the local database.
本发明实施例为了提高数据核对的执行效率,选择将从目标数据库获取到的第一数据结果集放在本地数据库中进行核对。In order to improve the execution efficiency of data checking in the embodiment of the present invention, the first data result set obtained from the target database is selected to be checked in the local database.
步骤205:将第一数据结果集插入到临时表中。Step 205: Insert the first data result set into the temporary table.
步骤206:根据临时表中插入的第一数据结果集,通过调用执行SQL,核对本地数据库中与第一数据结果集对应的第二数据结果集。Step 206: Check the second data result set corresponding to the first data result set in the local database by calling and executing SQL according to the first data result set inserted in the temporary table.
步骤207:当核对出第二数据结果集与第一数据结果集不一致时,更新第二数据结果集,以使更新后的第二数据结果集与第一数据结果集一致。Step 207: When it is checked that the second data result set is inconsistent with the first data result set, update the second data result set so that the updated second data result set is consistent with the first data result set.
在本发明实施例中,目标数据库中的第一数据结果集之前即有可能有新增数据、更改的更改数据,以及删除过一些删除数据,则相应的第二数据结果集在更新时,则也需要新增、更改、删除操作,以使得本地数据库中的第二数据结果集在更新后能够与第一数据结果集中的数据保持一致。In the embodiment of the present invention, before the first data result set in the target database, there may be new data, changed data, and some deleted data, then when the corresponding second data result set is updated, then Operations of adding, changing, and deleting are also required, so that the second data result set in the local database can be kept consistent with the data in the first data result set after being updated.
步骤208:生成用于指示数据核对不一致的反馈信息。Step 208: Generate feedback information for indicating data verification inconsistency.
步骤209:将反馈信息发送至预设的至少一个目标地址。Step 209: Send the feedback information to at least one preset target address.
如图3所示,本发明实施例提供了一种数据核对装置,包括:As shown in Figure 3, an embodiment of the present invention provides a data checking device, including:
视图读取单元301、数据获取单元302以及数据核对单元303,其中,View reading unit 301, data acquiring unit 302 and data checking unit 303, wherein,
所述视图读取单元301,用于从目标数据库中读取所需视图;The view reading unit 301 is configured to read the required view from the target database;
所述数据获取单元302,用于从所述目标数据库中获取与所述视图相对应的第一数据结果集;The data obtaining unit 302 is configured to obtain a first data result set corresponding to the view from the target database;
所述数据核对单元303,用于根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集。The data checking unit 303 is configured to check the second data result set corresponding to the first data result set in the local database according to the first data result set.
如图4所示,在本发明一个实施例中,进一步包括:创建单元401;As shown in FIG. 4, in an embodiment of the present invention, it further includes: a creation unit 401;
所述创建单元401,用于在所述数据获取单元302从所述目标数据库中获取与所述视图相对应的第一数据结果集之后,且在所述数据核对单元303根据所述第一数据结果集,核对本地数据库中与所述第一数据结果集对应的第二数据结果集之前,在所述本地数据库中创建临时表;将所述第一数据结果集插入到所述临时表中;The creating unit 401 is configured to, after the data obtaining unit 302 obtains the first data result set corresponding to the view from the target database, and after the data checking unit 303 obtains the first data result set according to the first data The result set, before checking the second data result set corresponding to the first data result set in the local database, creating a temporary table in the local database; inserting the first data result set into the temporary table;
所述数据核对单元303,用于根据所述临时表中插入的所述第一数据结果集,通过调用执行SQL,核对所述本地数据库中的所述第二数据结果集。The data checking unit 303 is configured to check the second data result set in the local database by calling and executing SQL according to the first data result set inserted in the temporary table.
如图5所示,在本发明一个实施例中,进一步包括:连接单元501;As shown in FIG. 5, in an embodiment of the present invention, it further includes: a connection unit 501;
所述连接单元501,用于在所述视图读取单元301从所述目标数据库中读取所需视图之前,按照预设的核对周期,周期性的根据预设的所述目标数据库的连接信息,建立与所述目标数据库之间的连接。The connection unit 501 is configured to, before the view reading unit 301 reads the required view from the target database, periodically according to the preset connection information of the target database according to the preset checking cycle , to establish a connection with the target database.
如图6所示,在本发明一个实施例中,进一步包括:更新单元601;As shown in FIG. 6, in one embodiment of the present invention, it further includes: an updating unit 601;
所述更新单元601,用于在所述数据核对单元303核对出所述第二数据结果集与所述第一数据结果集不一致时,更新所述第二数据结果集,以使更新后的所述第二数据结果集与所述第一数据结果集一致。The updating unit 601 is configured to update the second data result set when the data checking unit 303 checks that the second data result set is inconsistent with the first data result set, so that all updated data results The second data result set is consistent with the first data result set.
在本发明一个实施例中,所述更新单元,用于根据核对的结果,确定所述第一数据结果集中新增的新增数据;将所述新增数据同步至所述第二数据结果集中。In an embodiment of the present invention, the update unit is configured to determine the newly added data added in the first data result set according to the checking result; and synchronize the added data to the second data result set .
在本发明一个实施例中,所述更新单元,用于根据核对的结果,确定所述第一数据结果集中更改后的更改数据;将所述第二数据结果集中的目标数据更改为所述更改数据,其中,所述目标数据与所述更改数据相对应。In one embodiment of the present invention, the update unit is configured to determine the modified data in the first data result set according to the result of checking; change the target data in the second data result set to the modified data, wherein the target data corresponds to the modification data.
在本发明一个实施例中,所述更新单元,用于根据核对的结果,确定所述第一数据结果集中已删除的删除数据;删除所述第二数据结果集中所包括的所述删除数据。In an embodiment of the present invention, the updating unit is configured to determine the deleted data in the first data result set according to the checking result; and delete the deleted data included in the second data result set.
上述装置内的各单元之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。The information exchange and execution process among the units in the above-mentioned device are based on the same concept as the method embodiment of the present invention, and the specific content can refer to the description in the method embodiment of the present invention, and will not be repeated here.
综上,本发明各个实施例至少具有如下有益效果:To sum up, each embodiment of the present invention has at least the following beneficial effects:
1、在本发明实施例中,每一次进行数据核对时,将会自动从相应的目标数据库读取到所需视图,通过该所需视图,能够从目标数据库中获取到标准的第一数据结果集,这样,接下来就可根据该第一数据结果集,完成对本地数据库中与该第一数据结果集相对应的第二数据结果集的核对。整个数据核对过程无需人工参与,可自动实现,提高了用户体验。1. In the embodiment of the present invention, each time the data is checked, the required view will be automatically read from the corresponding target database, and the standard first data result can be obtained from the target database through the required view In this way, according to the first data result set, the checking of the second data result set corresponding to the first data result set in the local database can be completed. The entire data verification process can be realized automatically without manual participation, which improves the user experience.
2、在本发明实施例中,通过将来自不同数据库的数据放在同一个数据库中(也即,将从目标数据库获取到的第一数据结果集放在了本地数据库中),然后通过调用执行SQL,即可快速比对第一数据结果集和第二数据结果集,提高了执行效率,从而本发明实施例能够更快速的实现数据核对。2. In the embodiment of the present invention, by placing data from different databases in the same database (that is, placing the first data result set obtained from the target database in the local database), and then executing SQL can quickly compare the first data result set and the second data result set, which improves the execution efficiency, so that the embodiment of the present invention can realize data checking more quickly.
3、在本发明实施例中,当核对出目标数据库的第一数据结果集与本地数据库中的第二数据结果集不一致时,通过利用第一数据结果集对第二数据结果集进行更新,能够保证本地数据库中的第二数据结果集与目标数据库中的第一数据结果集的一致性,也即实现了数据同步,保障了使用不同数据库的不同业务系统能够共用相同的数据。3. In the embodiment of the present invention, when it is checked that the first data result set of the target database is inconsistent with the second data result set in the local database, by using the first data result set to update the second data result set, the The consistency between the second data result set in the local database and the first data result set in the target database is guaranteed, that is, data synchronization is realized, and different business systems using different databases can share the same data.
4、在本发明实施例中,通过设置核对周期以及目标数据库的连接信息,那么在每一次需要进行数据核对时,均可自动利用该连接信息与目标数据库之间建立连接,从而接下来能够从目标数据库获取到所需视图,整个过程不再需要人工干预,提高了数据核对的效率。4. In the embodiment of the present invention, by setting the checking cycle and the connection information of the target database, each time data checking is required, the connection information can be automatically used to establish a connection with the target database, so that the following can be performed from The target database obtains the required view, and the whole process no longer requires manual intervention, which improves the efficiency of data verification.
需要说明的是,在本文中,诸如第一和第二之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个〃····〃”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同因素。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 there is a relationship between these entities or operations. There is no such actual relationship or sequence. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising a "..." does not exclude the presence of additional same elements in the process, method, article or apparatus comprising said element.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储在计算机可读取的存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质中。Those of ordinary skill in the art can understand that all or part of the steps to realize the above method embodiments can be completed by program instructions related hardware, and the aforementioned programs can be stored in a computer-readable storage medium. When the program is executed, the It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other various media that can store program codes.
最后需要说明的是:以上所述仅为本发明的较佳实施例,仅用于说明本发明的技术方案,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所做的任何修改、等同替换、改进等,均包含在本发明的保护范围内。Finally, it should be noted that the above descriptions are only preferred embodiments of the present invention, and are only used to illustrate the technical solution of the present invention, and are not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present invention are included in the protection scope of the present invention.
Claims (10)
- A kind of 1. verification of data method, which is characterized in that including:View needed for being read from target database;It is obtained and the corresponding first data result collection of the view from the target database;According to the first data result collection, the second data corresponding with the first data result collection in local data base are checked Result set.
- 2. according to the method described in claim 1, it is characterized in that,After the acquisition from the target database with the corresponding first data result collection of the view, and in basis The first data result collection, check local data base in the second data result collection corresponding with the first data result collection it Before, further comprise:Interim table is created in the local data base;The first data result collection is inserted into the interim table;It is described according to the first data result collection, check in local data base with the first data result collection corresponding second Data result collection, including:According to the first data result collection being inserted into the interim table, structured query language SQL, core are performed by calling To the second data result collection in the local data base.
- 3. according to the method described in claim 1, it is characterized in that,Described according to the first data result collection, check corresponding with the first data result collection the in local data base After two data result collection, further comprise:When checking out the second data result collection and the first data result collection is inconsistent, the second data knot is updated Fruit collects, so that the updated second data result collection is consistent with the first data result collection.
- 4. according to the method described in claim 3, it is characterized in that,Update the second data result collection, including:According to verification as a result, determining that first data result concentrates newly-increased newly-increased data;The newly-increased data are synchronized to second data result to concentrate;And/orUpdate the second data result collection, including:According to verification as a result, determine the first data result concentrative change after change data;The target data that second data result is concentrated is changed to the change data, wherein, the target data and institute It is corresponding to state change data;And/orUpdate the second data result collection, including:According to verification as a result, determining that first data result concentrates deleted deletion data;It deletes second data result and concentrates the included deletion data.
- 5. according to the method described in claim 1, it is characterized in that,Before view needed for reading, further comprise from target database described:According to the preset verification period, periodically according to the link information of the preset target database, establish with it is described Connection between target database.
- 6. method according to any one of claims 1 to 5, which is characterized in thatDescribed according to the first data result collection, check corresponding with the first data result collection the in local data base After two data result collection, further comprise:When checking out the second data result collection and the first data result collection is inconsistent, generation is used to indicate data core To inconsistent feedback information;The feedback information is sent to preset at least one destination address.
- 7. a kind of verification of data device, which is characterized in that including:View reading unit, data capture unit and verification of data unit, wherein,The view reading unit, for view needed for the reading from target database;The data capture unit, for being obtained and corresponding first data result of the view from the target database Collection;The verification of data unit, for according to the first data result collection, checking in local data base and being counted with described first According to the corresponding second data result collection of result set.
- 8. device according to claim 7, which is characterized in thatFurther comprise:Creating unit;The creating unit, it is corresponding with the view for being obtained from the target database in the data capture unit The first data result collection after, and in the verification of data unit according to the first data result collection, check local data In library before the second data result collection corresponding with the first data result collection, created in the local data base interim Table;The first data result collection is inserted into the interim table;The verification of data unit, for according to the first data result collection being inserted into the interim table, being held by calling Row SQL checks the second data result collection in the local data base;And/orFurther comprise:Connection unit;The connection unit before view needed for being read from the target database in the view reading unit, is pressed According to the preset verification period, periodically according to the link information of the preset target database, establish and the number of targets According to the connection between library.
- 9. device according to claim 7, which is characterized in thatFurther comprise:Updating unit;The updating unit, in the verification of data memory cell to going out the second data result collection and first data When result set is inconsistent, the second data result collection is updated, so that the updated second data result collection and described the One data result collection is consistent.
- 10. device according to claim 9, which is characterized in thatThe updating unit, for according to verification as a result, determining that first data result concentrates newly-increased newly-increased data;It will The newly-increased data are synchronized to second data result and concentrate;And/or the updating unit, for according to verification as a result, Determine the change data after the first data result concentrative change;The target data that second data result is concentrated is changed For the change data, wherein, the target data is corresponding with the change data;And/or the updating unit, it is used for According to verification as a result, determining that first data result concentrates deleted deletion data;Delete second data result Concentrate the included deletion data.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711317304.0A CN108182203A (en) | 2017-12-12 | 2017-12-12 | Data checking method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711317304.0A CN108182203A (en) | 2017-12-12 | 2017-12-12 | Data checking method and device |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN108182203A true CN108182203A (en) | 2018-06-19 |
Family
ID=62546018
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201711317304.0A Pending CN108182203A (en) | 2017-12-12 | 2017-12-12 | Data checking method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108182203A (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109857806A (en) * | 2018-12-30 | 2019-06-07 | 贝壳技术有限公司 | The synchronization verification method and device of database table |
| CN111241202A (en) * | 2020-01-19 | 2020-06-05 | 浪潮软件股份有限公司 | Data overall process checking system |
| CN113157787A (en) * | 2021-04-06 | 2021-07-23 | 中信百信银行股份有限公司 | Accounting processing method and device, electronic equipment and readable storage medium |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20120005188A1 (en) * | 2010-06-30 | 2012-01-05 | Oracle International Corporation | Techniques for recommending parallel execution of sql statements |
| CN103605703A (en) * | 2013-11-08 | 2014-02-26 | 北京奇虎科技有限公司 | Method and system for data consistency detection among multiple platforms |
| CN106294075A (en) * | 2016-08-17 | 2017-01-04 | 浪潮软件股份有限公司 | A kind of SQL is monitored method, Apparatus and system |
| CN106682033A (en) * | 2015-11-10 | 2017-05-17 | 北京国双科技有限公司 | Knowledge base check method and device |
-
2017
- 2017-12-12 CN CN201711317304.0A patent/CN108182203A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20120005188A1 (en) * | 2010-06-30 | 2012-01-05 | Oracle International Corporation | Techniques for recommending parallel execution of sql statements |
| CN103605703A (en) * | 2013-11-08 | 2014-02-26 | 北京奇虎科技有限公司 | Method and system for data consistency detection among multiple platforms |
| CN106682033A (en) * | 2015-11-10 | 2017-05-17 | 北京国双科技有限公司 | Knowledge base check method and device |
| CN106294075A (en) * | 2016-08-17 | 2017-01-04 | 浪潮软件股份有限公司 | A kind of SQL is monitored method, Apparatus and system |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109857806A (en) * | 2018-12-30 | 2019-06-07 | 贝壳技术有限公司 | The synchronization verification method and device of database table |
| CN109857806B (en) * | 2018-12-30 | 2021-07-27 | 贝壳技术有限公司 | Synchronous verification method and device for database table |
| CN111241202A (en) * | 2020-01-19 | 2020-06-05 | 浪潮软件股份有限公司 | Data overall process checking system |
| CN113157787A (en) * | 2021-04-06 | 2021-07-23 | 中信百信银行股份有限公司 | Accounting processing method and device, electronic equipment and readable storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN105243067B (en) | A kind of method and device for realizing real-time incremental synchrodata | |
| TWI512491B (en) | Data synchronization methods for synchronizing data in communication systems and communication systems | |
| CN111259006A (en) | A general distributed heterogeneous data integration physical aggregation, organization, publishing and service method and system | |
| CN108647357B (en) | Method and device for data query | |
| CN110674146A (en) | Data synchronization method, synchronization end, end to be synchronized, equipment and storage medium | |
| CN106570086A (en) | Data migration system and method | |
| CN106709851B (en) | Big data retrieval method and device | |
| CN111209344A (en) | Data synchronization method and device | |
| CN105808609A (en) | Discrimination method and equipment of point-of-information data redundancy | |
| US20150365411A1 (en) | Systems and methods for creating and displaying an electronic communication digest | |
| CN102841886B (en) | Split the method and apparatus of document | |
| CN105900093A (en) | A method for updating a data table of a KeyValue database and a device for updating table data | |
| CN108182203A (en) | Data checking method and device | |
| CN103631966A (en) | Configurable multiple-valued matching field analysis method | |
| CN107491558A (en) | Metadata updates method and device | |
| CN110737432B (en) | Script aided design method and device based on root list | |
| CN107992492A (en) | A kind of storage method of data block, read method, its device and block chain | |
| CN108009223A (en) | The consistency detecting method and device of a kind of transaction data | |
| CN111159020B (en) | Method and device applied to synchronous software test | |
| CN106294792A (en) | The method for building up of correlation inquiry system and set up system | |
| CN110019139A (en) | Method, apparatus, electronic equipment and the storage medium of Data Migration | |
| CN104679869B (en) | A kind of method and apparatus that Active Directory data are synchronized to RTX | |
| CN102456023A (en) | Method and system for searching user information | |
| CN105426481B (en) | Handle the method and device of data | |
| JP6752547B2 (en) | Database management method and database management system |
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 | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180619 |