Movatterモバイル変換


[0]ホーム

URL:


CN116467372A - Automatic database conversion method and device, electronic equipment and storage medium - Google Patents

Automatic database conversion method and device, electronic equipment and storage medium
Download PDF

Info

Publication number
CN116467372A
CN116467372ACN202310146978.8ACN202310146978ACN116467372ACN 116467372 ACN116467372 ACN 116467372ACN 202310146978 ACN202310146978 ACN 202310146978ACN 116467372 ACN116467372 ACN 116467372A
Authority
CN
China
Prior art keywords
target
source
database
field
length
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
Application number
CN202310146978.8A
Other languages
Chinese (zh)
Inventor
罗兵
黄亮
刘树衎
陈琳
尚聪聪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Naval University of Engineering PLA
Original Assignee
Naval University of Engineering PLA
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Naval University of Engineering PLAfiledCriticalNaval University of Engineering PLA
Priority to CN202310146978.8ApriorityCriticalpatent/CN116467372A/en
Publication of CN116467372ApublicationCriticalpatent/CN116467372A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本申请提供一种数据库自动转换方法,涉及数据处理领域。该方法包括:获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。装置用于执行上述方法。本申请通过实现数据库的自动转换,提高了数据处理效率。

The application provides an automatic database conversion method, which relates to the field of data processing. The method includes: acquiring a data request; wherein, the data request includes the database type of the target database, the database type of the source database, and the source data type of the source database; if the data model mapping table contains a mapping relationship between the source database and the target database, then determining the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship; converting the source data type into a corresponding target data type, so as to realize the conversion of the source database into the target database. The device is used to perform the above method. The application improves the data processing efficiency by realizing the automatic conversion of the database.

Description

Translated fromChinese
一种数据库自动转换方法、装置、电子设备及存储介质A database automatic conversion method, device, electronic equipment and storage medium

技术领域technical field

本申请涉及数据处理领域,具体而言,涉及一种数据库自动转换方法、装置、电子设备及存储介质。The present application relates to the field of data processing, in particular, to a database automatic conversion method, device, electronic equipment and storage medium.

背景技术Background technique

随着互联网技术的高速发展,海量数据持续产生,使用数据库可以高效且条理分明地存储数据,同时能够使用户更加迅速和方便地管理数据。但是由于不同类型的数据库存储数据的方式不同,当需要访问另一种类型的数据库时,需要重新创建一个新的数据库,这个过程耗时费力,因此如何实现数据库之间的自动转换是一个非常重要的问题。With the rapid development of Internet technology, massive data continues to be generated. Using a database can store data in an efficient and orderly manner, and at the same time enable users to manage data more quickly and conveniently. However, because different types of databases store data in different ways, when you need to access another type of database, you need to recreate a new database. This process is time-consuming and laborious. Therefore, how to realize automatic conversion between databases is a very important issue.

现有技术中通常是将一种数据库固定转化为另一种数据库,不能根据实际需求实现数据库的转换,使得数据处理的效率不高。In the prior art, one type of database is usually fixedly converted into another type of database, and the conversion of the database cannot be realized according to actual needs, so that the efficiency of data processing is not high.

发明内容Contents of the invention

本申请实施例的目的在于提供一种数据库自动转换方法、装置、电子设备及存储介质,用以实现数据库之间的自动转换,提高数据处理效率。The purpose of the embodiments of the present application is to provide an automatic database conversion method, device, electronic equipment, and storage medium, so as to realize automatic conversion between databases and improve data processing efficiency.

第一方面,本申请实施例提供了一种数据库自动转换方法,该方法包括:获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。In the first aspect, an embodiment of the present application provides an automatic database conversion method, the method comprising: obtaining a data request; wherein, the data request includes a database type of the target database, a database type of the source database, and a source data type of the source database; if the data model mapping table contains a mapping relationship between the source database and the target database, then determine the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship; convert the source data type into a corresponding target data type, so as to realize the conversion of the source database into the target database.

本申请实施例的技术方案中,通过数据模型映射表将源数据库和目标数据库进行连接,并根据映射关系确定目标数据库的目标数据类型,从而将源数据库转换为目标数据库。在这个过程中,通过数据模型映射表确定需要转换成的目标数据库的数据类型,从而完成两个数据库的转换,不需要人为再重新创建目标数据库,提高了数据处理的效率。In the technical solution of the embodiment of the present application, the source database and the target database are connected through the data model mapping table, and the target data type of the target database is determined according to the mapping relationship, so as to convert the source database into the target database. In this process, the data type of the target database that needs to be converted is determined through the data model mapping table, so as to complete the conversion of the two databases, without artificially recreating the target database, which improves the efficiency of data processing.

在一些实施例中,源数据类型包括源字段类型;目标数据类型包括目标字段类型和目标字段长度;根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型,包括:根据数据模型映射表获得每一源字段类型分别对应的源扩容策略、与源字段类型对应的目标字段类型的目标扩容策略;其中,目标扩容策略包括目标字段整数位长度扩容策略;若目标字段整数位长度扩容策略不为空,则根据源扩容策略和目标字段整数位长度扩容策略计算目标字段长度;根据目标字段类型和目标字段长度确定目标数据库的目标数据类型。In some embodiments, the source data type includes a source field type; the target data type includes a target field type and a target field length; determining the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship includes: obtaining a source expansion strategy corresponding to each source field type and a target expansion strategy corresponding to the source field type according to the data model mapping table; wherein the target expansion strategy includes The target field integer bit length expansion policy; if the target field integer bit length expansion policy is not empty, then expand according to the source expansion policy and the target field integer bit length The content policy calculates the target field length; determines the target data type of the target database according to the target field type and the target field length.

本申请实施例通过根据源字段类型的源扩容策略和目标字段类型的目标字段整数位长度扩容策略计算目标数据类型的目标字段长度,从而获得目标数据类型。在这个过程中,基于源数据库的扩容策略进行计算,使得转换后的目标数据库的字段长度是符合转换要求的,而不是任意设置的,为数据库间的正确转换提供了基础。并且只有目标字段整数位长度扩容策略不为空时才进行计算,筛选的过程将不需要进行计算的对象进行剔除,减少了计算时间,进一步提高了数据处理的效率。In the embodiment of the present application, the target data type is obtained by calculating the target field length of the target data type according to the source expansion policy of the source field type and the target field integer bit length expansion policy of the target field type. In this process, the calculation is performed based on the expansion strategy of the source database, so that the field length of the converted target database meets the conversion requirements, rather than being set arbitrarily, which provides a basis for correct conversion between databases. And only when the expansion policy of the integer bit length of the target field is not empty, the calculation will be performed. The screening process will eliminate the objects that do not need to be calculated, which reduces the calculation time and further improves the efficiency of data processing.

在一些实施例中,目标字段长度包括目标字段整数位长度和目标字段小数位长度;所述源扩容策略包括源字段整数位长度扩容策略和源字段小数位长度扩容策略;目标扩容策略还包括目标字段小数位长度扩容策略;根据源扩容策略和目标字段整数位长度扩容策略计算目标字段长度,包括:根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度;根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度;根据目标字段整数位长度和目标字段小数位长度确定目标字段长度。In some embodiments, the target field length includes a target field integer bit length and a target field decimal bit length; the source expansion strategy includes a source field integer bit length expansion strategy and a source field decimal bit length expansion strategy; the target expansion strategy also includes a target field decimal bit length expansion strategy; calculating the target field length according to the source field expansion strategy and the target field integer bit length expansion strategy includes: calculating the target field integer bit length according to the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; The field decimal length expansion strategy calculates the decimal length of the target field; the target field length is determined according to the integer length of the target field and the decimal length of the target field.

本申请实施例通过目标扩容策略还包括目标字段小数位长度扩容策略,使得能分别计算目标数据库的整数位的字段长度和小数位的字段长度,分类计算提高了计算精度,进一步验证数据转换的正确性,从而提高了数据处理的效率。In the embodiment of the present application, the target expansion strategy also includes the target field decimal length expansion strategy, so that the field length of integer bits and the field length of decimal bits of the target database can be calculated respectively, and the classification calculation improves the calculation accuracy, and further verifies the correctness of data conversion, thereby improving the efficiency of data processing.

在一些实施例中,根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度,包括:若源字段整数位长度扩容策略为空,则目标字段整数位长度为目标字段长度的整数位默认长度;若源字段整数位长度扩容策略不为空,则根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略进行三元运算,获得目标字段整数位长度。In some embodiments, calculating the integer bit length of the target field according to the source field integer bit length expansion policy and the target field integer bit length expansion policy includes: if the source field integer bit length expansion policy is empty, then the target field integer bit length is the integer bit default length of the target field length; if the source field integer bit length expansion policy is not empty, then perform a ternary operation according to the source field integer bit length expansion policy and the target field integer bit length expansion policy to obtain the target field integer bit length.

本申请实施例通过源字段整数位长度扩容策略是否为空来判定是否需要对目标字段整数位长度进行计算,这个过程相当于做了一次筛选,筛选的过程减少了计算时间,加快了数据计算的速度,进一步提高了数据处理的效率。In the embodiment of the present application, it is determined whether the integer bit length of the target field needs to be calculated according to whether the expansion policy of the integer bit length of the source field is empty. This process is equivalent to a screening. The screening process reduces the calculation time, speeds up the data calculation speed, and further improves the efficiency of data processing.

在一些实施例中,根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度,包括:若目标字段小数位长度扩容策略为空,则目标字段小数位长度为空;若源字段小数位长度扩容策略为空,则目标字段小数位长度为目标字段长度的小数位默认长度;若源字段小数位长度扩容策略不为空,则根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略进行三元运算,获得目标字段小数位长度。In some embodiments, calculating the decimal place length of the target field according to the source field decimal place length expansion strategy and the target field decimal place length expansion strategy includes: if the target field decimal place length expansion strategy is empty, then the target field decimal place length is empty; if the source field decimal place length expansion strategy is empty, then the target field decimal place length is the default decimal length of the target field length; if the source field decimal place length expansion strategy is not empty, then according to the source field decimal place length expansion strategy and the target field decimal place length The expansion strategy performs a ternary operation to obtain the decimal length of the target field.

本申请实施例通过目标字段小数位长度扩容策略是否为空和源字段小数位长度扩容策略是否为空来判定是否需要对目标字段小数位长度进行计算,这个过程相当于做了一次筛选,筛选的过程减少了计算时间,加快了数据计算的速度,进一步提高了数据处理的效率。In the embodiment of the present application, whether the decimal place length expansion policy of the target field is empty and whether the decimal place length expansion policy of the source field is empty is used to determine whether the calculation of the decimal place length of the target field is required. This process is equivalent to a screening. The screening process reduces calculation time, speeds up data calculation, and further improves the efficiency of data processing.

在一些实施例中,在将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库之后,该方法还包括:解析目标数据库的数据库类型和目标数据类型,生成DDL脚本文件;根据DDL脚本文件,生成目标数据库。In some embodiments, after converting the source data type into a corresponding target data type to realize the conversion of the source database into the target database, the method further includes: parsing the database type and the target data type of the target database to generate a DDL script file; generating the target database according to the DDL script file.

本申请实施例通过解析目标数据库类型和目标数据类型,自动生成DDL脚本文件,从而自动完成目标数据库的创建,提高了此类数据库对应的开发效率,进一步提高了数据处理的效率。The embodiment of the present application automatically generates a DDL script file by analyzing the type of the target database and the type of the target data, thereby automatically completing the creation of the target database, improving the development efficiency corresponding to this type of database, and further improving the efficiency of data processing.

在一些实施例中,在获取数据请求之后,该方法还包括:根据数据模型映射表判断源数据库是否能转换为目标数据库。In some embodiments, after obtaining the data request, the method further includes: judging whether the source database can be converted into the target database according to the data model mapping table.

本申请实施例通过在进行转换之前,利用数据模型映射表先进行判断,如果能够转换才进行转换,不能转换则直接退出,以此剔除一些无效转换,提高了时间利用率,进一步提高了数据处理的效率。In the embodiment of the present application, before conversion, the data model mapping table is used to judge first. If the conversion is possible, the conversion is performed;

第二方面,本申请实施例还提供了一种数据库自动转换装置,该装置包括:获取模块,用于获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;确定模块,用于若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;转换模块,用于将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。In a second aspect, an embodiment of the present application further provides an automatic database conversion device, which includes: an acquisition module for obtaining a data request; wherein the data request includes a database type of the target database, a database type of the source database, and a source data type of the source database; a determination module is used for determining the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship if the data model mapping table contains a mapping relationship between the source database and the target database;

本申请实施例通过数据模型映射表将源数据库和目标数据库进行连接,并根据映射关系确定目标数据库的目标数据类型,从而将源数据库转换为目标数据库。在这个过程中,通过数据模型映射表确定需要转换成的目标数据库的数据类型,从而完成两个数据库的转换,不需要人为再重新创建目标数据库,提高了数据处理的效率。In the embodiment of the present application, the source database and the target database are connected through the data model mapping table, and the target data type of the target database is determined according to the mapping relationship, so as to convert the source database into the target database. In this process, the data type of the target database that needs to be converted is determined through the data model mapping table, so as to complete the conversion of the two databases, without artificially recreating the target database, which improves the efficiency of data processing.

第三方面,本申请实施例提供一种电子设备,包括:处理器、存储器、存储介质和总线,其中,所述处理器和所述存储器通过所述总线完成相互间的通信;所述存储器存储有可被所述处理器执行的程序指令,所述处理器调用所述程序指令能够执行第一方面的方法步骤。In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, a storage medium, and a bus, wherein the processor and the memory communicate with each other through the bus; the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method steps of the first aspect.

第四方面,本申请实施例提供一种非暂态计算机可读存储介质,包括:所述计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行第一方面的方法步骤。In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium, including: the computer-readable storage medium stores computer instructions, and the computer instructions cause the computer to execute the method steps of the first aspect.

本申请的其他特征和优点将在随后的说明书阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请实施例了解。本申请的目的和其他优点可通过在所写的说明书、权利要求书、以及附图中所特别指出的结构来实现和获得。Other features and advantages of the present application will be set forth in the ensuing description and, in part, will be apparent from the description, or can be learned by practicing the embodiments of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.

附图说明Description of drawings

为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the accompanying drawings required in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be considered as limiting the scope. For those of ordinary skill in the art, other related drawings can also be obtained according to these drawings without creative work.

图1为本申请实施例提供的一种数据库自动转换方法的流程图;Fig. 1 is the flow chart of a kind of database automatic conversion method provided by the embodiment of the present application;

图2为本申请实施例提供的一种数据库自动转换方法的具体流程图;Fig. 2 is a specific flowchart of a database automatic conversion method provided by the embodiment of the present application;

图3为本申请实施例提供的一种数据库自动转换装置结构示意图;Fig. 3 is a schematic structural diagram of a database automatic conversion device provided by the embodiment of the present application;

图4为本申请实施例提供的电子设备结构示意图。FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

具体实施方式Detailed ways

为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,应当理解,本申请中附图仅起到说明和描述的目的,并不用于限定本申请的保护范围。另外,应当理解,示意性的附图并未按实物比例绘制。本申请中使用的流程图示出了根据本申请的一些实施例实现的操作。应该理解,流程图的操作可以不按顺序实现,没有逻辑的上下文关系的步骤可以反转顺序或者同时实施。此外,本领域技术人员在本申请内容的指引下,可以向流程图添加一个或多个其他操作,也可以从流程图中移除一个或多个操作。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. It should be understood that the accompanying drawings in the present application are only for the purpose of illustration and description, and are not used to limit the scope of protection of the present application. Additionally, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented in accordance with some embodiments of the application. It should be understood that the operations of the flowcharts may be performed out of order, and steps that have no logical context may be performed in reverse order or concurrently. In addition, those skilled in the art may add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of the present application.

另外,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本申请实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本申请的实施例的详细描述并非旨在限制要求保护的本申请的范围,而是仅仅表示本申请的选定实施例。基于本申请的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本申请保护的范围。In addition, the described embodiments are only some of the embodiments of the application, not all of the embodiments. The components of the embodiments of the application generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of the embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of the application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative efforts belong to the scope of protection of the present application.

需要说明的是,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同;本文中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本申请;本申请的说明书和权利要求书及上述附图说明中的术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。It should be noted that all the technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present application; the terms used herein are only for the purpose of describing specific embodiments, and are not intended to limit the present application; the terms "comprising" and "having" in the specification and claims of the present application and the description of the above drawings, as well as any variations thereof, are intended to cover non-exclusive inclusion.

在本申请实施例的描述中,技术术语“第一”“第二”等仅用于区别不同对象,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量、特定顺序或主次关系。在本申请实施例的描述中,“多个”的含义是两个以上,除非另有明确具体的限定。In the description of the embodiments of the present application, technical terms such as "first" and "second" are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, "plurality" means two or more, unless otherwise specifically defined.

在本申请实施例的描述中,术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。In the description of the embodiment of the present application, the term "and/or" is only an association relationship describing associated objects, which means that there may be three relationships, such as A and/or B, which may mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" in this article generally indicates that the contextual objects are an "or" relationship.

在本申请实施例的描述中,术语“多个”指的是两个以上(包括两个),同理,“多组”指的是两组以上(包括两组),“多片”指的是两片以上(包括两片)。In the description of the embodiments of the present application, the term "multiple" refers to more than two (including two), similarly, "multiple groups" refers to more than two groups (including two), and "multiple pieces" refers to more than two (including two).

可以理解的是,本申请实施例提供的数据库自动转换方法可以应用于终端设备(也可以称为电子设备)以及服务器;其中终端设备具体可以为智能手机、平板电脑、计算机、个人数字助理(Personal Digital Assistant,PDA)等;服务器具体可以为应用服务器,也可以为Web服务器。It can be understood that the automatic database conversion method provided in the embodiment of the present application can be applied to a terminal device (also referred to as an electronic device) and a server; wherein the terminal device can specifically be a smart phone, a tablet computer, a computer, a personal digital assistant (Personal Digital Assistant, PDA), etc.; the server can specifically be an application server or a Web server.

为了便于理解,本申请实施例提供的技术方案,下面以服务器作为执行主体为例,对本申请实施例提供的数据库自动转换方法的应用场景进行介绍。In order to facilitate understanding, the technical solutions provided by the embodiments of the present application will be described below using the server as an execution body as an example to introduce the application scenarios of the automatic database conversion method provided by the embodiments of the present application.

图1为本申请实施例提供的一种数据库自动转换方法的流程图,如图1所示,该方法包括:Fig. 1 is the flow chart of a kind of database automatic conversion method that the embodiment of the present application provides, as shown in Fig. 1, this method comprises:

步骤101,获取数据请求。Step 101, obtain a data request.

在具体实施过程中,获取的数据请求包括但不限于目标数据库的数据库类型、源数据库的数据库类型、源数据库的源数据类型、源数据库名称、源表英文名、源表中文名、源字段英文名、源字段中文名、源字段类型、源字段长度、源字段整数位长度、源字段小数位长度、源字段是否为主键、源字段是否为空、源字段默认值等模型属性值。其中,源数据库是指待转换的数据库,目标数据库是指源数据库转换后的数据库,源数据类型包括但不限于源数据库的源字段类型和源字段长度。需要说明的是,获取的数据请求中包含的信息可根据实际情况进行具体限定,本申请对此不做具体限定。In the specific implementation process, the obtained data request includes but not limited to the database type of the target database, the database type of the source database, the source data type of the source database, the name of the source database, the English name of the source table, the Chinese name of the source table, the English name of the source field, the Chinese name of the source field, the type of the source field, the length of the source field, the integer length of the source field, the decimal length of the source field, whether the source field is the primary key, whether the source field is empty, the default value of the source field and other model attribute values. Wherein, the source database refers to the database to be converted, the target database refers to the converted database of the source database, and the source data type includes but not limited to the source field type and source field length of the source database. It should be noted that the information included in the acquired data request may be specifically limited according to actual conditions, and this application does not specifically limit this.

具体的,获取的数据请求来源于以本申请提供的Excel模板文件中的物理数据模型表进行配置,物理数据模型表具体可称为表SOURCE_DB_DDL。用户通过提前配置该表,可通过该表知道目标数据库的数据库类型、源数据库的详细信息,此处的详细信息可参见上述信息,此处不再赘述。Specifically, the acquired data request comes from the configuration of the physical data model table in the Excel template file provided by this application, and the physical data model table may specifically be called the table SOURCE_DB_DDL. By configuring this table in advance, the user can know the database type of the target database and the detailed information of the source database through this table. For the detailed information here, please refer to the above information, which will not be repeated here.

需要说明的是,本申请提供的Excel模板文件为事先已经设定好的模板文件。Excel表有如下性质:Excel表为标准的二维表的设计,其能够支持通过数据库管理工具将源数据库的物理数据模型统一导出为csv、excel等格式的文件后,再快速导入到本申请提供的物理数据模型Excel模板中。可以理解的是,除了基于excel表以外,还可以根据其它类型的格式数据提供该格式对应的模板文件,如XML格式的数据,可根据实际情况进行具体设定,本申请对此不做具体限定。It should be noted that the Excel template file provided in this application is a pre-set template file. The Excel table has the following properties: the Excel table is a standard two-dimensional table design, which can support the unified export of the physical data model of the source database into csv, excel and other format files through the database management tool, and then quickly import it into the physical data model Excel template provided by this application. It can be understood that, in addition to being based on the excel table, template files corresponding to the format can also be provided according to other types of format data, such as data in XML format, which can be specifically set according to actual conditions, and this application does not specifically limit this.

通过表SOURCE_DB_DDL,初始化源数据库的全部信息和目标数据库的基本信息,将这些信息写入内存,以供生成数据请求。具体初始化过程为通过用户触发执行VBA程序,读取Excel模板文件中的表SOURCE_DB_DDL的配置,写入内存。其中,VBA程序是直接依附于Excel模板文件的宏。Through the table SOURCE_DB_DDL, initialize all the information of the source database and the basic information of the target database, and write these information into the memory for generating data requests. The specific initialization process is to trigger the execution of the VBA program by the user, read the configuration of the table SOURCE_DB_DDL in the Excel template file, and write it into the memory. Among them, the VBA program is a macro directly attached to the Excel template file.

表1给出表SOURCE_DB_DDL的示例以供理解,如表1所示,表头给出数据库模型包含的属性值以及这些属性值对应的具体的参数值。如,在表1中,需要将源数据库类型MYSQL转换为目标数据库类型HIVE,在源数据库类型属性和目标数据库类型属性中间的值为源数据库的详细信息。需要说明的是,表1只是列举几个参数以作实例,在实际应用中,可根据实际情况对表中数据进行增加和删除,本申请对此不做具体限定。Table 1 provides an example of the table SOURCE_DB_DDL for understanding. As shown in Table 1, the table header provides the attribute values contained in the database model and the specific parameter values corresponding to these attribute values. For example, in Table 1, the source database type MYSQL needs to be converted to the target database type HIVE, and the value between the source database type attribute and the target database type attribute is the detailed information of the source database. It should be noted that Table 1 only enumerates several parameters as examples. In practical applications, data in the table can be added or deleted according to actual conditions, and this application does not specifically limit this.

表1Table 1

步骤102,若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型。Step 102, if the data model mapping table contains the mapping relationship between the source database and the target database, then determine the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship.

在具体实施过程中,数据模型映射表包含了不同物理数据模型转换的映射关系,也可简单理解为包含了不同数据库转换的映射关系,该表存储在Excel模板文件中。目标数据类型包括但不限于目标数据库的目标字段类型和目标字段长度。In the specific implementation process, the data model mapping table includes the mapping relationship between different physical data model conversions, and can also be simply understood as including the mapping relationship between different database conversions. This table is stored in the Excel template file. The target data type includes, but is not limited to, the target field type and target field length of the target database.

而根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型,具体可为通过用户触发执行VBA程序;此时VBA程序将读取Excel模板文件中的表MODEL_TRANS_DEFINE的配置,逐行解析表MODEL_TRANS_DEFINE内的每一行配置信息。读取的配置信息包括读取映射关系配置和源数据库类型、源数据库字段类型、目标数据库字段类型、目标字段的整数位最大长度、目标字段的整数位默认长度、整数位长度扩容策略、目标字段的小数位最大长度、目标字段的小数位默认长度、小数位长度扩容策略等的配置。需要说明的是,整数位长度扩容策略包括源字段整数位长度扩容策略和目标字段整数位长度扩容策略;小数位长度扩容策略包括源字段小数位长度扩容策略和目标字段小数位长度扩容策略。并且,源字段整数位长度扩容策略和源字段小数位长度扩容策略统称为源扩容策略,目标字段整数位长度扩容策略和目标字段小数位长度扩容策略统称为目标扩容策略。整数位长度扩容策略指数据字段长度的字段整数位长度能扩展的长度及规则,同理,小数位长度扩容策略指数据字段长度的字段小数位长度能扩展的长度及规则,其中,规则由数据库类型决定。According to the mapping relationship, the target data type of the target database corresponding to the source data type of the source database can be determined by triggering the execution of the VBA program by the user; at this time, the VBA program will read the configuration of the table MODEL_TRANS_DEFINE in the Excel template file, and analyze the configuration information of each row in the table MODEL_TRANS_DEFINE line by line. The read configuration information includes the configuration of the read mapping relationship configuration and source database type, source database field type, target database field type, maximum integer length of the target field, default integer length of the target field, integer bit length expansion strategy, maximum decimal length of the target field, default decimal length of the target field, and decimal length expansion strategy. It should be noted that the integer bit length expansion strategy includes the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; the decimal bit length expansion strategy includes the source field decimal bit length expansion strategy and the target field decimal bit length expansion strategy. In addition, the source field integer bit length expansion policy and the source field fractional bit length expansion policy are collectively referred to as the source capacity expansion policy, and the target field integer bit length expansion policy and the target field decimal bit length expansion policy are collectively referred to as the target field expansion policy. The integer bit length expansion strategy refers to the length and rules that can be extended by the integer bit length of the data field length. Similarly, the decimal bit length expansion strategy refers to the extended length and rules of the decimal bit length of the data field length. The rules are determined by the database type.

其中,VBA程序是直接依附于Excel模板文件的宏,读取映射关系配置时,需要筛选出符合源数据库类型、目标数据库类型和源字段类型的配置行,从而根据源数据库类型、目标数据库类型和源字段类型确定目标字段类型。如,若源字段类型为float型,则目标字段类型可以为decimal型、也可以为double型等,而是为decimal型还是double型或者为其他型则是根据目标数据库的数据库类型进行确定。Among them, the VBA program is a macro directly attached to the Excel template file. When reading the mapping relationship configuration, it is necessary to filter out the configuration lines that match the source database type, target database type, and source field type, so as to determine the target field type according to the source database type, target database type, and source field type. For example, if the source field type is float type, the target field type can be decimal type or double type, etc. Whether it is decimal type, double type or other types is determined according to the database type of the target database.

而读取目标数据库字段类型、目标字段整数位最大长度、目标字段整数位默认长度、整数位长度扩容策略、目标字段小数位最大长度、目标字段小数位的默认长度、小数位长度扩容策略等的配置是为了计算获得目标数据类型中的目标字段长度。The configuration of reading the target database field type, the maximum integer length of the target field, the default integer length of the target field, the expansion policy of the integer bit length, the maximum length of the decimal place of the target field, the default length of the decimal place of the target field, and the expansion strategy of the decimal place length is to calculate and obtain the length of the target field in the target data type.

表2给出了表MODEL_TRANS_DEFINE的示例以作理解,如表2所述,表头给出了数据模型映射表包含的属性值以及这些属性值对应的具体的参数值。如,在表2中,存在源数据库类型HIVE和目标数据库MYSQL的映射关系,并且源数据库字段类型double与目标数据库字段类型double相对应,因此这两个数据库之间可以相互转换。另外,表2还给出目标字段的整数位最大长度为30,目标字段的小数位最大长度为30,目标字段的小数位默认长度为30,其中,表2中所列的整数位长度扩容策略包括源字段整数位长度扩容策略和目标字段整数位长度扩容策略;小数位长度扩容策略包括源字段小数位长度扩容策略和目标字段小数位长度扩容策略。但需要说明的是,表2只是列举几个例子以作实例,在实际应用中,可根据实际情况进行配置,本申请对此不做具体限定。Table 2 gives an example of the table MODEL_TRANS_DEFINE for understanding. As described in Table 2, the header shows the attribute values contained in the data model mapping table and the specific parameter values corresponding to these attribute values. For example, in Table 2, there is a mapping relationship between the source database type HIVE and the target database MYSQL, and the source database field type double corresponds to the target database field type double, so the two databases can be converted to each other. In addition, Table 2 also shows that the maximum length of the integer bits of the target field is 30, the maximum length of the decimal bits of the target field is 30, and the default length of the decimal bits of the target field is 30. The integer bit length expansion strategies listed in Table 2 include the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; the decimal bit length expansion strategy includes the source field decimal bit length expansion strategy and the target field decimal bit length expansion strategy. However, it should be noted that Table 2 only enumerates a few examples as examples. In practical applications, configurations may be made according to actual conditions, and this application does not specifically limit this.

表2Table 2

步骤103,将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。Step 103, converting the source data type into a corresponding target data type, so as to convert the source database into the target database.

在具体实施过程中,获得目标数据库的目标数据类型之后,则可将源数据库转换为目标数据库。In the specific implementation process, after the target data type of the target database is obtained, the source database can be converted into the target database.

本申请实施例的技术方案中,通过数据模型映射表将源数据库和目标数据库进行连接,并根据映射关系确定目标数据库的目标数据类型,从而将源数据库转换为目标数据库。在这个过程中,通过数据模型映射表确定需要转换成的目标数据库的数据类型,从而完成两个数据库的转换,不需要人为再重新创建目标数据库,提高了数据处理的效率。In the technical solution of the embodiment of the present application, the source database and the target database are connected through the data model mapping table, and the target data type of the target database is determined according to the mapping relationship, so as to convert the source database into the target database. In this process, the data type of the target database that needs to be converted is determined through the data model mapping table, so as to complete the conversion of the two databases, without artificially recreating the target database, which improves the efficiency of data processing.

在一些实施例中,源数据类型包括源字段类型;目标数据类型包括目标字段类型和目标字段长度;根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型,包括:根据数据模型映射表获得每一源字段类型分别对应的源扩容策略、与源字段类型对应的目标字段类型的目标扩容策略;其中,目标扩容策略包括目标字段整数位长度扩容策略;若目标字段整数位长度扩容策略不为空,则根据源扩容策略和目标字段整数位长度扩容策略计算目标字段长度;根据目标字段类型和目标字段长度确定目标数据库的目标数据类型。In some embodiments, the source data type includes a source field type; the target data type includes a target field type and a target field length; determining the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship includes: obtaining a source expansion strategy corresponding to each source field type and a target expansion strategy corresponding to the source field type according to the data model mapping table; wherein the target expansion strategy includes The target field integer bit length expansion policy; if the target field integer bit length expansion policy is not empty, then expand according to the source expansion policy and the target field integer bit length The content policy calculates the target field length; determines the target data type of the target database according to the target field type and the target field length.

在具体实施过程中,源字段类型指该字段对应的数据所属的类型,如,该数据是整型、字符型、浮点型或布尔型等;源字段长度与源字段类型是一一对应的关系,其指该字段对应的数据的长度,其中,每个类型都有一个对应的最大长度,而字段对应的数据的实际长度不能超过对应的最大长度。同理可解释目标字段类型和目标字段长度,此处不再赘述。In the specific implementation process, the source field type refers to the type of data corresponding to the field, for example, the data is integer, character, floating point or Boolean, etc.; the source field length and the source field type have a one-to-one correspondence, which refers to the length of the data corresponding to the field, wherein each type has a corresponding maximum length, and the actual length of the data corresponding to the field cannot exceed the corresponding maximum length. Similarly, the target field type and target field length can be explained, and will not be repeated here.

具体的,根据目标字段整数位长度扩容策略和源字段整数位长度扩容策略确定目标字段的整数位长度;根据目标字段小数位长度扩容策略和源字段小数位长度扩容策略确定目标字段的小数位长度,从而获得目标字段长度。Specifically, the integer bit length of the target field is determined according to the target field integer bit length expansion policy and the source field integer bit length expansion policy; the target field length is determined according to the target field decimal bit length expansion policy and the source field decimal bit length expansion policy, thereby obtaining the target field length.

需要说明的是,如果目标字段整数位长度扩容策略为空,则目标字段长度的目标字段整数位长度为空,目标字段长度的目标字段小数位长度为空。其中,目标字段整数位长度扩容策略为空,即当前目标字段长度不做整数位和小数位长度设置,这样的字段长度对应的字段类型有:字符串型(string、char、verchar等)、布尔型(boolean)等。It should be noted that if the target field integer bit length expansion strategy is empty, the target field integer bit length of the target field length is empty, and the target field fractional bit length of the target field length is empty. Among them, the target field integer bit length expansion strategy is empty, that is, the current target field length does not set the integer bit and decimal bit length. The field types corresponding to such a field length include: string type (string, char, verchar, etc.), Boolean type (boolean), etc.

本申请实施例通过根据源字段类型的源扩容策略和目标字段类型的目标字段整数位长度扩容策略计算目标数据类型的目标字段长度,从而获得目标数据类型。在这个过程中,基于源数据库的扩容策略进行计算,使得转换后的目标数据库的字段长度是符合转换要求的,而不是任意设置的,为数据库间的正确转换提供了基础。并且只有目标字段整数位长度扩容策略不为空时才进行计算,筛选的过程将不需要进行计算的对象进行剔除,减少了计算时间,进一步提高了数据处理的效率。In the embodiment of the present application, the target data type is obtained by calculating the target field length of the target data type according to the source expansion policy of the source field type and the target field integer bit length expansion policy of the target field type. In this process, the calculation is performed based on the expansion strategy of the source database, so that the field length of the converted target database meets the conversion requirements, rather than being set arbitrarily, which provides a basis for correct conversion between databases. And only when the expansion policy of the integer bit length of the target field is not empty, the calculation will be performed. The screening process will eliminate the objects that do not need to be calculated, which reduces the calculation time and further improves the efficiency of data processing.

在一些实施例中,目标字段长度包括目标字段整数位长度和目标字段小数位长度;所述源扩容策略包括源字段整数位长度扩容策略和源字段小数位长度扩容策略;目标扩容策略还包括目标字段小数位长度扩容策略;根据源扩容策略和目标字段整数位长度扩容策略计算目标字段长度,包括:根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度;根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度;根据目标字段整数位长度和目标字段小数位长度确定目标字段长度。In some embodiments, the target field length includes a target field integer bit length and a target field decimal bit length; the source expansion strategy includes a source field integer bit length expansion strategy and a source field decimal bit length expansion strategy; the target expansion strategy also includes a target field decimal bit length expansion strategy; calculating the target field length according to the source field expansion strategy and the target field integer bit length expansion strategy includes: calculating the target field integer bit length according to the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; The field decimal length expansion strategy calculates the decimal length of the target field; the target field length is determined according to the integer length of the target field and the decimal length of the target field.

在具体实施过程中,通过源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度;通过源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度。其具体计算过程请参见下述实施例,此处不再赘述。In the specific implementation process, the integer bit length of the target field is calculated through the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; the target field decimal bit length is calculated through the source field decimal bit length expansion strategy and the target field decimal bit length expansion strategy. For the specific calculation process, please refer to the following embodiments, which will not be repeated here.

本申请实施例通过目标扩容策略还包括目标字段小数位长度扩容策略,使得能分别计算目标数据库的整数位的字段长度和小数位的字段长度,分类计算提高了计算精度,进一步验证数据转换的正确性,从而提高了数据处理的效率。In the embodiment of the present application, the target expansion strategy also includes the target field decimal length expansion strategy, so that the field length of integer bits and the field length of decimal bits of the target database can be calculated respectively, and the classification calculation improves the calculation accuracy, and further verifies the correctness of data conversion, thereby improving the efficiency of data processing.

在一些实施例中,根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度,包括:若源字段整数位长度扩容策略为空,则目标字段整数位长度为目标字段长度的整数位默认长度;若源字段整数位长度扩容策略不为空,则根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略进行三元运算,获得目标字段整数位长度。In some embodiments, calculating the integer bit length of the target field according to the source field integer bit length expansion policy and the target field integer bit length expansion policy includes: if the source field integer bit length expansion policy is empty, then the target field integer bit length is the integer bit default length of the target field length; if the source field integer bit length expansion policy is not empty, then perform a ternary operation according to the source field integer bit length expansion policy and the target field integer bit length expansion policy to obtain the target field integer bit length.

在具体实施过程中,具体计算目标字段整数位长度可分如下几种情况:In the specific implementation process, the specific calculation of the integer bit length of the target field can be divided into the following situations:

(1)若目标字段整数位长度扩容策略为0,且源字段整数位长度扩容策略为空,则:目标字段的目标整数位长度=目标字段长度的整数位默认长度。(1) If the integer bit length expansion policy of the target field is 0, and the integer bit length expansion policy of the source field is empty, then: the target integer bit length of the target field = the default integer bit length of the target field length.

(2)若目标字段整数位长度扩容策略为非0,且源字段整数位长度扩容策略为空,则:目标字段的目标整数位长度=目标字段长度的整数位默认长度。(2) If the integer bit length expansion policy of the target field is non-zero, and the integer bit length expansion policy of the source field is empty, then: the target integer bit length of the target field = the default integer bit length of the target field length.

当源字段整数位长度扩容策略不为空时,通过三元运算计算目标字段整数位长度:具体为:When the expansion policy of the integer bit length of the source field is not empty, the integer bit length of the target field is calculated through the ternary operation: specifically:

其中,三元运算又称三目运算,其语法格式为“(条件表达式)?表达式1:表达式2”,其中,如果条件为true,运算后的结果是表达式1;如果条件为false,运算后的结果是表达式2。例如,x>y?y:x,表示的含义是如果x大于y,则取y值,如果x小于等于y,则取x值,其中,x和y可表示任意类型的对象。Among them, the ternary operation is also called the ternary operation, and its grammatical format is "(conditional expression)? expression 1: expression 2", wherein, if the condition is true, the result after the operation is expression 1; if the condition is false, the result after the operation is expression 2. For example, x > y? y: x, which means that if x is greater than y, then take the value of y, if x is less than or equal to y, then take the value of x, where x and y can represent any type of object.

(3)若目标字段整数位长度扩容策略为0,且源字段整数位长度扩容策略非空,则:目标字段长度的目标整数位长度=(目标字段的目标整数位最大长度is not null and源字段长度的整数位长度>目标字段的整数位最大长度)?目标字段的整数位最大长度:源字段长度的整数位长度。(3) If the expansion policy of the integer bit length of the target field is 0, and the expansion policy of the integer bit length of the source field is not empty, then: the target integer bit length of the target field length = (the maximum length of the target integer bit of the target field is not null and the integer bit length of the source field length > the maximum integer bit length of the target field)? Integer bit max length of target field: The integer bit length of the source field length.

(4)若目标字段整数位长度扩容策略为非0,且源字段整数位长度扩容策略非空,则:目标字段长度的目标整数位长度=(目标字段的目标整数位最大长度is not null and源字段长度的整数位长度+目标字段整数位长度扩容策略>目标字段的整数位最大长度)?目标字段的整数位最大长度:(源字段长度的整数位长度+目标字段整数位长度扩容策略)。(4) If the expansion policy of the integer bit length of the target field is non-zero, and the expansion policy of the integer bit length of the source field is not empty, then: the target integer bit length of the target field length = (the maximum length of the target integer bit of the target field is not null and the integer bit length of the source field length + the expansion policy of the integer bit length of the target field > the maximum integer bit length of the target field)? The maximum length of the target field in integer bits: (the integer bit length of the source field length + the target field integer bit length expansion strategy).

本申请实施例通过源字段整数位长度扩容策略是否为空来判定是否需要对目标字段整数位长度进行计算,这个过程相当于做了一次筛选,筛选的过程减少了计算时间,加快了数据计算的速度,进一步提高了数据处理的效率。In the embodiment of the present application, it is determined whether the integer bit length of the target field needs to be calculated according to whether the expansion policy of the integer bit length of the source field is empty. This process is equivalent to a screening. The screening process reduces the calculation time, speeds up the data calculation speed, and further improves the efficiency of data processing.

在一些实施例中,根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度,包括:若目标字段小数位长度扩容策略为空,则目标字段小数位长度为空;若源字段小数位长度扩容策略为空,则目标字段小数位长度为目标字段长度的小数位默认长度;若源字段小数位长度扩容策略不为空,则根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略进行三元运算,获得目标字段小数位长度。In some embodiments, calculating the decimal place length of the target field according to the source field decimal place length expansion strategy and the target field decimal place length expansion strategy includes: if the target field decimal place length expansion strategy is empty, then the target field decimal place length is empty; if the source field decimal place length expansion strategy is empty, then the target field decimal place length is the default decimal length of the target field length; if the source field decimal place length expansion strategy is not empty, then according to the source field decimal place length expansion strategy and the target field decimal place length The expansion strategy performs a ternary operation to obtain the decimal length of the target field.

在具体实施过程中,只有目标字段整数位长度扩容策略不为空时,才会对目标字段小数位长度进行计算。具体计算可分如下几种情况:In the specific implementation process, only when the expansion policy of the integer bit length of the target field is not empty, the decimal bit length of the target field will be calculated. The specific calculation can be divided into the following situations:

(1)若目标字段小数位长度扩容策略为空,则:目标字段长度的目标小数位长度=null。(1) If the expansion policy of the decimal place length of the target field is empty, then: the target decimal place length of the target field length=null.

(2)若目标字段小数位长度扩容策略为0,且源字段小数位长度扩容策略为空,则:目标字段长度的目标小数位长度=目标字段长度的小数位默认长度。(2) If the target field decimal length expansion policy is 0, and the source field decimal length expansion policy is empty, then: the target decimal length of the target field length = the default decimal length of the target field length.

(3)若目标字段小数位长度扩容策略非0,且源字段小数位长度扩容策略为空,则:目标字段长度的目标小数位长度=目标字段长度的小数位默认长度。(3) If the target field decimal length expansion policy is not 0, and the source field decimal length expansion policy is empty, then: the target decimal length of the target field length = the default decimal length of the target field length.

当源字段小数位长度扩容策略不为空时,通过三元运算计算目标字段小数位长度:具体为:When the source field decimal length expansion strategy is not empty, calculate the target field decimal length by ternary operation: specifically:

(4)若目标字段小数位长度扩容策略为0,且源字段小数位长度扩容策略不为空,则:目标字段长度的目标小数位长度=(目标字段的最大小数位长度is not null and源字段长度的小数位长度>目标字段的小数位最大长度)?目标字段的最大小数位长度:源字段长度的小数位长度。(4) If the destination field decimal length expansion strategy is 0, and the source field decimal length expansion strategy is not empty, then: the target decimal length of the target field length = (the maximum decimal length of the target field is not null and the decimal length of the source field length > the maximum decimal length of the target field)? Maximum decimal length of target field: The decimal length of the source field length.

(5)若目标字段小数位长度扩容策略非0,且源字段小数位长度扩容策略不为空,则:目标字段长度的目标小数位长度=(目标字段的最大小数位长度is not null and源字段长度的小数位长度+目标字段小数位长度扩容策略>目标字段的小数位最大长度)?目标字段的最大小数位长度:(源字段长度的小数位长度+目标字段小数位长度扩容策略)。(5) If the destination field decimal length expansion strategy is not 0, and the source field decimal length expansion strategy is not empty, then: the target decimal length of the target field length = (the maximum decimal length of the target field is not null and the decimal length of the source field length + the destination field decimal length expansion strategy > the maximum decimal length of the target field)? The maximum decimal length of the target field: (the decimal length of the source field length + the expansion policy of the decimal length of the target field).

本申请实施例通过目标字段小数位长度扩容策略是否为空和源字段小数位长度扩容策略是否为空来判定是否需要对目标字段小数位长度进行计算,这个过程相当于做了一次筛选,筛选的过程减少了计算时间,加快了数据计算的速度,进一步提高了数据处理的效率。In the embodiment of the present application, whether the decimal place length expansion policy of the target field is empty and whether the decimal place length expansion policy of the source field is empty is used to determine whether the calculation of the decimal place length of the target field is required. This process is equivalent to a screening. The screening process reduces calculation time, speeds up data calculation, and further improves the efficiency of data processing.

在一些实施例中,在将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库之后,该方法还包括:解析目标数据库的数据库类型和目标数据类型,生成DDL脚本文件;根据DDL脚本文件,生成目标数据库。In some embodiments, after converting the source data type into a corresponding target data type to realize the conversion of the source database into the target database, the method further includes: parsing the database type and the target data type of the target database to generate a DDL script file; generating the target database according to the DDL script file.

在具体实施过程中,利用数据模型转换器,自动生成DDL脚本文件。In the specific implementation process, the DDL script file is automatically generated by using the data model converter.

本申请实施例通过解析目标数据库类型和目标数据类型,自动生成DDL脚本文件,从而自动完成目标数据库的创建,解放了数据工程师的生产力,提高了此类数据库对应的开发效率,进一步提高了数据处理的效率。The embodiment of the present application automatically generates a DDL script file by analyzing the target database type and target data type, thereby automatically completing the creation of the target database, liberating the productivity of data engineers, improving the development efficiency corresponding to such databases, and further improving the efficiency of data processing.

在一些实施例中,在获取数据请求之后,该方法还包括:根据数据模型映射表判断源数据库是否能转换为目标数据库。In some embodiments, after obtaining the data request, the method further includes: judging whether the source database can be converted into the target database according to the data model mapping table.

在具体实施过程中,通过VBA程序读取Excel模板文件中的表MODEL_TRANS_DEFINE(如表2所示)的配置,逐行解析表MODEL_TRANS_DEFINE内的每一行配置信息。若配置信息中含有对应的两种数据库的数据类型的转换映射关系时,才执行上述实施例所述的数据库转换方法,若不含有,则直接中断退出转换流程。In the specific implementation process, the configuration of the table MODEL_TRANS_DEFINE (as shown in Table 2) in the Excel template file is read through the VBA program, and the configuration information of each row in the table MODEL_TRANS_DEFINE is analyzed line by line. The database conversion method described in the above embodiment is executed only if the configuration information contains the corresponding conversion mapping relationship of the data types of the two databases, and if it does not, the conversion process is directly interrupted and exited.

本申请实施例通过在进行转换之前,利用数据模型映射表先进行判断,如果能够转换才进行转换,不能转换则直接退出,以此剔除一些无效转换,提高了时间利用率,进一步提高了数据处理的效率。In the embodiment of the present application, before conversion, the data model mapping table is used to judge first. If the conversion is possible, the conversion is performed;

图2为本申请实施例提供的一种数据库自动转换方法的具体流程图,如图2所示,方法具体执行如下:Fig. 2 is a specific flow chart of a database automatic conversion method provided by the embodiment of the present application. As shown in Fig. 2, the specific execution of the method is as follows:

步骤201,开始执行。Step 201, start to execute.

步骤202,读取SOURCE_DB_DDL表,初始化公共变量,具体初始化内容请参见上述实施例或者见图2步骤202包含的内容,此处不再赘述。Step 202, read the SOURCE_DB_DDL table, and initialize public variables. For specific initialization content, please refer to the above-mentioned embodiment or see the content contained in step 202 in FIG. 2 , which will not be repeated here.

步骤203,读取MODEL_TRANS_DEFINE表,逐行解析配置,检查所配置的待转换的物理数据模型映射是否受支持,具体如何判断的过程请参见上述实施例,此处不再赘述。Step 203, read the MODEL_TRANS_DEFINE table, parse the configuration line by line, and check whether the configured physical data model mapping to be converted is supported. Please refer to the above-mentioned embodiment for the specific determination process, which will not be repeated here.

步骤204,读取SOURCE_DB_DDL表,逐行读取每一行配置,获得步骤205的内容,包括源数据库类型、目标数据库类型、源字段类型、源字段整数位长度和源字段小数位长度等内容。需要说明的是,为了便于示例,步骤205的内容只包含部分内容,详细内容可参见图2步骤202包含的内容。Step 204, read the SOURCE_DB_DDL table, read each line of configuration line by line, and obtain the content of step 205, including source database type, target database type, source field type, source field integer bit length and source field decimal bit length, etc. It should be noted that, for the sake of example, the content in step 205 only includes part of the content, and for details, refer to the content in step 202 in FIG. 2 .

步骤206,读取MODEL_TRANS_DEFINE表中的映射关系配置,筛选符合源数据库类型、目标数据库类型、源字段类型的配置行等信息,相关信息请参见上述实施例或参见图2步骤206中包含的内容,此处不再赘述。Step 206, read the mapping relationship configuration in the MODEL_TRANS_DEFINE table, and filter information such as configuration rows that meet the source database type, target database type, and source field type. For related information, please refer to the above-mentioned embodiment or refer to the content contained in step 206 in FIG. 2 , and will not repeat them here.

步骤207,判断目标字段整数位长度扩容策略是否为空,若为空,则执行步骤208,若不为空,则执行步骤209,处理目标字段整数位长度扩容策略,获得目标字段整数位长度,具体处理过程请参见上述实施例,此处不再赘述。Step 207, determine whether the target field integer bit length expansion strategy is empty, if it is empty, then execute step 208, if not, then execute step 209, process the target field integer bit length expansion strategy, and obtain the target field integer bit length, please refer to the above-mentioned embodiments for the specific processing process, and will not repeat them here.

步骤210,在步骤209的基础上执行,处理目标字段小数位长度扩容策略,获得目标字段小数位长度,具体处理过程请参见上述实施例,此处不再赘述。Step 210 is executed on the basis of step 209 to process the target field decimal length expansion strategy to obtain the target field decimal length. For the specific processing process, please refer to the above-mentioned embodiments, which will not be repeated here.

步骤211,获得目标数据库DDL,输出DDL脚本文件,具体过程请参见上述实施例,此处不再赘述。Step 211, obtain the DDL of the target database, and output the DDL script file. For the specific process, please refer to the above-mentioned embodiments, which will not be repeated here.

步骤212,结束流程。Step 212, end the process.

图3为本申请实施例提供的一种数据库自动转换装置结构示意图,如图3所示,该装置包括获取模块301、确定模块302和转换模块303,其中,Fig. 3 is a schematic structural diagram of a database automatic conversion device provided by the embodiment of the present application. As shown in Fig. 3, the device includes an acquisition module 301, a determination module 302 and a conversion module 303, wherein,

获取模块301,用于获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;确定模块302,用于若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;转换模块303,用于将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。The acquisition module 301 is used to obtain a data request; wherein the data request includes the database type of the target database, the database type of the source database and the source data type of the source database; the determination module 302 is used to determine the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship if the data model mapping table contains a mapping relationship between the source database and the target database; the conversion module 303 is used to convert the source data type into a corresponding target data type, so as to realize the conversion of the source database into the target database.

在上述实施例的基础上,源数据类型包括源字段类型;目标数据类型包括目标字段类型和目标字段长度;确定模块302具体用于:根据数据模型映射表获得每一源字段类型分别对应的源扩容策略、与源字段类型对应的目标字段类型的目标扩容策略;其中,目标扩容策略包括目标字段整数位长度扩容策略;若目标字段整数位长度扩容策略不为空,则根据源扩容策略和目标字段整数位长度扩容策略计算目标字段长度;根据目标字段类型和目标字段长度确定目标数据库的目标数据类型。On the basis of the above embodiments, the source data type includes the source field type; the target data type includes the target field type and the target field length; the determination module 302 is specifically used to: obtain the source expansion strategy corresponding to each source field type according to the data model mapping table, and the target expansion strategy of the target field type corresponding to the source field type; wherein, the target expansion strategy includes the target field integer bit length expansion strategy; and target field length determine the target data type for the target database.

在上述实施例的基础上,目标字段长度包括目标字段整数位长度和目标字段小数位长度;所述源扩容策略包括源字段整数位长度扩容策略和源字段小数位长度扩容策略;目标扩容策略还包括目标字段小数位长度扩容策略;确定模块302具体还用于:根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度;根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度;根据目标字段整数位长度和目标字段小数位长度确定目标字段长度。On the basis of the above-mentioned embodiments, the target field length includes the target field integer bit length and the target field decimal bit length; the source expansion strategy includes the source field integer bit length expansion strategy and the source field decimal bit length expansion strategy; the target expansion strategy also includes the target field decimal bit length expansion strategy; the determination module 302 is also specifically used to: calculate the target field integer bit length according to the source field integer bit length expansion strategy and the target field integer bit length expansion strategy; Field decimal length; determine the target field length according to the target field integer bit length and the target field decimal length.

在上述实施例的基础上,确定模块302具体还用于:根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略计算目标字段整数位长度,包括:若源字段整数位长度扩容策略为空,则目标字段整数位长度为目标字段长度的整数位默认长度;若源字段整数位长度扩容策略不为空,则根据源字段整数位长度扩容策略和目标字段整数位长度扩容策略进行三元运算,获得目标字段整数位长度。On the basis of the above embodiments, the determination module 302 is specifically further configured to: calculate the integer bit length of the target field according to the source field integer bit length expansion policy and the target field integer bit length expansion policy, including: if the source field integer bit length expansion policy is empty, then the target field integer bit length is the integer bit default length of the target field length;

在上述实施例的基础上,确定模块302具体还用于:根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略计算目标字段小数位长度,包括:若目标字段小数位长度扩容策略为空,则目标字段小数位长度为空;若源字段小数位长度扩容策略为空,则目标字段小数位长度为目标字段长度的小数位默认长度;若源字段小数位长度扩容策略不为空,则根据源字段小数位长度扩容策略和目标字段小数位长度扩容策略进行三元运算,获得目标字段小数位长度。On the basis of the foregoing embodiments, the determination module 302 is specifically further configured to: calculate the target field decimal length according to the source field decimal length expansion strategy and the target field decimal length expansion strategy, including: if the target field decimal length expansion strategy is empty, then the target field decimal length is empty; if the source field decimal length expansion strategy is empty, then the target field decimal length is the default decimal length of the target field length; if the source field decimal length expansion strategy is not empty, then according to the source field decimal length expansion strategy The length expansion strategy and the target field decimal length expansion strategy perform a ternary operation to obtain the target field decimal length.

在上述实施例的基础上,所述装置还包括:解析模块,用于解析目标数据库的数据库类型和目标数据类型,生成DDL脚本文件;生成模块,用于根据DDL脚本文件,生成目标数据库。On the basis of the above embodiments, the device further includes: a parsing module for parsing the database type and target data type of the target database to generate a DDL script file; a generating module for generating the target database according to the DDL script file.

在上述实施例的基础上,所述装置还包括:判断模块,用于根据数据模型映射表判断源数据库是否能转换为目标数据库。On the basis of the above embodiments, the device further includes: a judging module, configured to judge whether the source database can be converted into the target database according to the data model mapping table.

本申请实施例通过数据模型映射表将源数据库和目标数据库进行连接,并根据映射关系确定目标数据库的目标数据类型,从而将源数据库转换为目标数据库。在这个过程中,通过数据模型映射表确定需要转换成的目标数据库的数据类型,从而完成两个数据库的转换,不需要人为再重新创建目标数据库,提高了数据处理的效率。In the embodiment of the present application, the source database and the target database are connected through the data model mapping table, and the target data type of the target database is determined according to the mapping relationship, so as to convert the source database into the target database. In this process, the data type of the target database that needs to be converted is determined through the data model mapping table, so as to complete the conversion of the two databases, without artificially recreating the target database, which improves the efficiency of data processing.

图4为本申请实施例提供的电子设备结构示意图,如图4所示,所述电子设备,包括处理器(processor)401、存储器(memory)402和总线403;其中,所述处理器401和存储器402通过所述总线403完成相互间的通信。所述处理器401用于调用所述存储器402中的程序指令,以执行上述各方法实施例所提供的方法。FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in FIG. 4 , the electronic device includes a processor (processor) 401, a memory (memory) 402, and a bus 403; wherein, the processor 401 and the memory 402 complete mutual communication through the bus 403. The processor 401 is configured to invoke program instructions in the memory 402 to execute the methods provided by the above method embodiments.

处理器401可以是一种集成电路芯片,具有信号处理能力。上述处理器401可以是通用处理器,包括中央处理器(CentralProcessingUnit,CPU)、网络处理器(NetworkProcessor,NP)等;还可以是数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。其可以实现或者执行本申请实施例中公开的各种方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The processor 401 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor 401 may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. It can realize or execute various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.

存储器402可以包括但不限于随机存取存储器(RandomAccessMemory,RAM),只读存储器(ReadOnlyMemory,ROM),可编程只读存储器(ProgrammableRead-OnlyMemory,PROM),可擦除只读存储器(ErasableProgrammableRead-OnlyMemory,EPROM),电可擦除只读存储器(ElectricallyErasableProgrammableRead-OnlyMemory,EEPROM)等。Memory 402 may include but not limited to random access memory (RandomAccessMemory, RAM), read-only memory (ReadOnlyMemory, ROM), programmable read-only memory (ProgrammableRead-OnlyMemory, PROM), erasable read-only memory (ErasableProgrammableRead-OnlyMemory, EPROM), electrically erasable read-only memory (ElectricallyErasableProgrammableRead-OnlyMemory, EEPROM) wait.

本实施例公开一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,计算机能够执行上述各方法实施例所提供的方法,例如包括:获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。This embodiment discloses a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by the computer, the computer can execute the methods provided by the above method embodiments, for example, including: obtaining a data request; wherein the data request includes the database type of the target database, the database type of the source database, and the source data type of the source database; Target data type; convert the source data type to the corresponding target data type to realize the conversion of the source database to the target database.

本实施例提供一种非暂态计算机可读存储介质,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令使所述计算机执行上述各方法实施例所提供的方法,例如包括:获取数据请求;其中,数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;若数据模型映射表中包含源数据库与目标数据库之间的映射关系,则根据映射关系确定源数据库的源数据类型对应的目标数据库的目标数据类型;将源数据类型转换为对应的目标数据类型,以实现将源数据库转换为目标数据库。This embodiment provides a non-transitory computer-readable storage medium, the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions cause the computer to execute the methods provided in the above method embodiments, for example, including: obtaining a data request; wherein, the data request includes the database type of the target database, the database type of the source database, and the source data type of the source database; type to implement the conversion of the source database to the target database.

在本申请所提供的实施例中,应该理解到,所揭露装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

另外,作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。In addition, the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

再者,在本申请各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。Furthermore, each functional module in each embodiment of the present application may be integrated to form an independent part, each module may exist independently, or two or more modules may be integrated to form an independent part.

在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。In this document, relational terms such as first and second etc. are used only to distinguish one entity or operation from another without necessarily requiring or implying any such actual relationship or order between these entities or operations.

以上所述仅为本申请的实施例而已,并不用于限制本申请的保护范围,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above descriptions are only examples of the present application, and are not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and changes may be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application shall be included within the protection scope of this application.

Claims (10)

Translated fromChinese
1.一种数据库自动转换方法,其特征在于,所述方法包括:1. A database automatic conversion method is characterized in that, the method comprises:获取数据请求;其中,所述数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;Obtaining a data request; wherein, the data request includes the database type of the target database, the database type of the source database, and the source data type of the source database;若数据模型映射表中包含所述源数据库与所述目标数据库之间的映射关系,则根据所述映射关系确定所述源数据库的源数据类型对应的所述目标数据库的目标数据类型;If the data model mapping table contains a mapping relationship between the source database and the target database, then determine the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship;将所述源数据类型转换为对应的所述目标数据类型,以实现将所述源数据库转换为所述目标数据库。converting the source data type into the corresponding target data type, so as to implement converting the source database into the target database.2.根据权利要求1所述的方法,其特征在于,所述源数据类型包括源字段类型;所述目标数据类型包括目标字段类型和目标字段长度;所述根据所述映射关系确定所述源数据库的源数据类型对应的所述目标数据库的目标数据类型,包括:2. The method according to claim 1, wherein the source data type comprises a source field type; the target data type comprises a target field type and a target field length; determining the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship comprises:根据所述数据模型映射表获得每一所述源字段类型分别对应的源扩容策略、与所述源字段类型对应的所述目标字段类型的目标扩容策略;其中,所述目标扩容策略包括目标字段整数位长度扩容策略;According to the data model mapping table, a source expansion strategy corresponding to each source field type and a target expansion strategy of the target field type corresponding to the source field type are obtained; wherein the target expansion strategy includes a target field integer bit length expansion strategy;若所述目标字段整数位长度扩容策略不为空,则根据所述源扩容策略和所述目标字段整数位长度扩容策略计算所述目标字段长度;If the target field integer bit length expansion policy is not empty, then calculate the target field length according to the source expansion policy and the target field integer bit length expansion policy;根据所述目标字段类型和所述目标字段长度确定所述目标数据库的目标数据类型。Determine the target data type of the target database according to the target field type and the target field length.3.根据权利要求2所述的方法,其特征在于,所述目标字段长度包括目标字段整数位长度和目标字段小数位长度;所述源扩容策略包括源字段整数位长度扩容策略和源字段小数位长度扩容策略;所述目标扩容策略还包括目标字段小数位长度扩容策略;所述根据所述源扩容策略和所述目标字段整数位长度扩容策略计算所述目标字段长度,包括:3. The method according to claim 2, wherein the target field length includes a target field integer bit length and a target field decimal bit length; the source expansion strategy includes a source field integer bit length expansion strategy and a source field decimal bit length expansion strategy; the target expansion strategy also includes a target field decimal bit length expansion strategy; and calculating the target field length according to the source expansion strategy and the target field integer bit length expansion strategy includes:根据所述源字段整数位长度扩容策略和所述目标字段整数位长度扩容策略计算所述目标字段整数位长度;calculating the integer bit length of the target field according to the expansion policy of the integer bit length of the source field and the expansion policy of the integer bit length of the target field;根据所述源字段小数位长度扩容策略和所述目标字段小数位长度扩容策略计算所述目标字段小数位长度;calculating the decimal length of the target field according to the expansion policy of the source field decimal length and the expansion policy of the target field decimal length;根据所述目标字段整数位长度和所述目标字段小数位长度确定所述目标字段长度。The target field length is determined according to the target field integer bit length and the target field fractional bit length.4.根据权利要求3所述的方法,其特征在于,所述根据所述源字段整数位长度扩容策略和所述目标字段整数位长度扩容策略计算所述目标字段整数位长度,包括:4. The method according to claim 3, wherein the calculating the integer bit length of the target field according to the expansion policy of the integer bit length of the source field and the expansion policy of the integer bit length of the target field comprises:若所述源字段整数位长度扩容策略为空,则所述目标字段整数位长度为所述目标字段长度的整数位默认长度;If the expansion policy of the integer bit length of the source field is empty, the integer bit length of the target field is the default integer bit length of the target field length;若所述源字段整数位长度扩容策略不为空,则根据所述源字段整数位长度扩容策略和所述目标字段整数位长度扩容策略进行三元运算,获得所述目标字段整数位长度。If the source field integer bit length expansion policy is not empty, perform a ternary operation according to the source field integer bit length expansion policy and the target field integer bit length expansion policy to obtain the target field integer bit length.5.根据权利要求3所述的方法,其特征在于,所述根据所述源字段小数位长度扩容策略和所述目标字段小数位长度扩容策略计算所述目标字段小数位长度,包括:5. The method according to claim 3, wherein the calculating the decimal length of the target field according to the expansion policy of the source field decimal length and the expansion policy of the target field decimal length comprises:若所述目标字段小数位长度扩容策略为空,则所述目标字段小数位长度为空;If the expansion policy of the decimal place length of the target field is empty, then the decimal place length of the target field is empty;若所述源字段小数位长度扩容策略为空,则所述目标字段小数位长度为所述目标字段长度的小数位默认长度;If the source field decimal length expansion policy is empty, then the target field decimal length is the default decimal length of the target field length;若所述源字段小数位长度扩容策略不为空,则根据所述源字段小数位长度扩容策略和所述目标字段小数位长度扩容策略进行三元运算,获得所述目标字段小数位长度。If the source field decimal length expansion policy is not empty, perform a ternary operation according to the source field decimal length expansion policy and the target field decimal length expansion policy to obtain the target field decimal length.6.根据权利要求1所述的方法,其特征在于,在所述将所述源数据类型转换为对应的所述目标数据类型,以实现将所述源数据库转换为所述目标数据库之后,所述方法还包括:6. The method according to claim 1, wherein, after converting the source data type into the corresponding target data type to realize the conversion of the source database into the target database, the method further comprises:解析所述目标数据库的数据库类型和所述目标数据类型,生成DDL脚本文件;Analyzing the database type of the target database and the target data type to generate a DDL script file;根据所述DDL脚本文件,生成所述目标数据库。Generate the target database according to the DDL script file.7.根据权利要求1-6任一项所述的方法,其特征在于,在获取数据请求之后,所述方法还包括:7. The method according to any one of claims 1-6, characterized in that, after obtaining the data request, the method further comprises:根据所述数据模型映射表判断所述源数据库是否能转换为所述目标数据库。Judging whether the source database can be converted to the target database according to the data model mapping table.8.一种数据库自动转换装置,其特征在于,包括:8. A database automatic conversion device, characterized in that, comprising:获取模块,用于获取数据请求;其中,所述数据请求包括目标数据库的数据库类型、源数据库的数据库类型和源数据库的源数据类型;An acquisition module, configured to acquire a data request; wherein, the data request includes the database type of the target database, the database type of the source database, and the source data type of the source database;确定模块,用于若数据模型映射表中包含所述源数据库与所述目标数据库之间的映射关系,则根据所述映射关系确定所述源数据库的源数据类型对应的所述目标数据库的目标数据类型;A determining module, configured to determine the target data type of the target database corresponding to the source data type of the source database according to the mapping relationship if the data model mapping table contains the mapping relationship between the source database and the target database;转换模块,用于将所述源数据类型转换为对应的所述目标数据类型,以实现将所述源数据库转换为所述目标数据库。A conversion module, configured to convert the source data type into the corresponding target data type, so as to convert the source database into the target database.9.一种电子设备,其特征在于,包括:处理器和存储器,所述存储器存储有所述处理器可执行的机器可读指令,所述机器可读指令被所述处理器执行时执行如权利要求1至7任一所述的方法。9. An electronic device, comprising: a processor and a memory, the memory stores machine-readable instructions executable by the processor, and the machine-readable instructions execute the method according to any one of claims 1 to 7 when executed by the processor.10.一种计算机可读存储介质,其特征在于,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行如权利要求1至7任一所述的方法。10. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the method according to any one of claims 1 to 7 is executed.
CN202310146978.8A2023-02-212023-02-21Automatic database conversion method and device, electronic equipment and storage mediumPendingCN116467372A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310146978.8ACN116467372A (en)2023-02-212023-02-21Automatic database conversion method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310146978.8ACN116467372A (en)2023-02-212023-02-21Automatic database conversion method and device, electronic equipment and storage medium

Publications (1)

Publication NumberPublication Date
CN116467372Atrue CN116467372A (en)2023-07-21

Family

ID=87174195

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310146978.8APendingCN116467372A (en)2023-02-212023-02-21Automatic database conversion method and device, electronic equipment and storage medium

Country Status (1)

CountryLink
CN (1)CN116467372A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116186796A (en)*2023-02-212023-05-30中国人民解放军海军工程大学Sequence number generation method, system, electronic equipment and storage medium
CN119692950A (en)*2024-12-042025-03-25中国人民解放军海军工程大学 Task planning execution method, device, equipment and medium based on process engine

Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN103221949A (en)*2010-07-272013-07-24甲骨文国际公司MYSQL database heterogeneous log based replication
CN111291049A (en)*2020-01-192020-06-16软通动力信息技术有限公司Method, device, equipment and storage medium for creating table
CN112860793A (en)*2021-02-032021-05-28浪潮云信息技术股份公司Method for realizing metadata synchronization between different source databases
CN113051259A (en)*2020-12-232021-06-29上海海鼎信息工程股份有限公司Multi-data-source structure difference processing method and system for store operation
CN114077600A (en)*2021-11-262022-02-22山东福生佳信科技股份有限公司ARM (advanced RISC machine) kernel-based data heterogeneous migration visual analysis method
CN114398345A (en)*2022-01-192022-04-26中国平安人寿保险股份有限公司 Data migration method, device, computer equipment and storage medium
CN115599769A (en)*2022-10-262023-01-13中国农业银行股份有限公司(Cn)Data migration method and device, electronic equipment and storage medium
CN115617773A (en)*2021-07-162023-01-17中国电信股份有限公司Data migration method, device and system

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN103221949A (en)*2010-07-272013-07-24甲骨文国际公司MYSQL database heterogeneous log based replication
CN111291049A (en)*2020-01-192020-06-16软通动力信息技术有限公司Method, device, equipment and storage medium for creating table
CN113051259A (en)*2020-12-232021-06-29上海海鼎信息工程股份有限公司Multi-data-source structure difference processing method and system for store operation
CN112860793A (en)*2021-02-032021-05-28浪潮云信息技术股份公司Method for realizing metadata synchronization between different source databases
CN115617773A (en)*2021-07-162023-01-17中国电信股份有限公司Data migration method, device and system
CN114077600A (en)*2021-11-262022-02-22山东福生佳信科技股份有限公司ARM (advanced RISC machine) kernel-based data heterogeneous migration visual analysis method
CN114398345A (en)*2022-01-192022-04-26中国平安人寿保险股份有限公司 Data migration method, device, computer equipment and storage medium
CN115599769A (en)*2022-10-262023-01-13中国农业银行股份有限公司(Cn)Data migration method and device, electronic equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116186796A (en)*2023-02-212023-05-30中国人民解放军海军工程大学Sequence number generation method, system, electronic equipment and storage medium
CN116186796B (en)*2023-02-212024-01-30中国人民解放军海军工程大学Sequence number generation method, system, electronic equipment and storage medium
CN119692950A (en)*2024-12-042025-03-25中国人民解放军海军工程大学 Task planning execution method, device, equipment and medium based on process engine

Similar Documents

PublicationPublication DateTitle
CN116467372A (en)Automatic database conversion method and device, electronic equipment and storage medium
CN111428462A (en)Communication protocol template construction method and terminal equipment
CN109460220A (en)The predefined code generating method of message, device, electronic equipment and storage medium
CN112926008B (en)Method, device, electronic equipment and storage medium for generating form page
CN113568598B (en)Yosys-based FPGA logic synthesis method and device for realizing summation operation
CN111966707A (en)Query statement generation method and device, electronic equipment and computer readable medium
CN112015831A (en)Method, device and equipment for operating relational database based on C language
CN108900320A (en)A kind of internet test envelope topological structure large scale shrinkage in size method and device
WO2020224380A1 (en)Blockchain-based data processing method and device
CN112187713B (en) Method, device, computer equipment and storage medium for message conversion
CN118035502A (en)Power distribution network data graph model construction method and device, electronic equipment and storage medium
CN116303428A (en)Data processing method and device
CN114490651A (en)Data storage method and device
CN114328486A (en)Data quality checking method and device based on model
CN113886647A (en)Data dictionary creating method, terminal device and medium
WO2025152417A1 (en)Data storage system and data storage method
CN118394602A (en)Memory computing method and device for java object and electronic equipment
CN112861368A (en)Power distribution network information model construction method and device and terminal equipment
CN118210479A (en) Interface request encapsulation method and computing device
CN117707478A (en) Demand management methods, devices, equipment and storage media
CN114047926B (en) Array computing expression language conversion method, device, equipment and storage medium
CN116415621A (en) Neural network slicing method, device and electronic equipment
CN114115908B (en) Instruction set generation, program analysis method, device, equipment and storage medium
CN110647568B (en)Method and device for converting graph database data into programming language data
CN116628090A (en)Method, system, equipment and storage medium for synchronizing whole library in real time based on FlinkCDC

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication
RJ01Rejection of invention patent application after publication

Application publication date:20230721


[8]ページ先頭

©2009-2025 Movatter.jp