CN111291049A - Method, device, equipment and storage medium for creating table - Google Patents

Method, device, equipment and storage medium for creating table Download PDF

Info

Publication number
CN111291049A
CN111291049A CN202010062889.1A CN202010062889A CN111291049A CN 111291049 A CN111291049 A CN 111291049A CN 202010062889 A CN202010062889 A CN 202010062889A CN 111291049 A CN111291049 A CN 111291049A
Authority
CN
China
Prior art keywords
database
source
type
target
field
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
CN202010062889.1A
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.)
Isoftstone Information Technology Co ltd
Original Assignee
Isoftstone Information Technology Co ltd
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 Isoftstone Information Technology Co ltd filed Critical Isoftstone Information Technology Co ltd
Priority to CN202010062889.1A priority Critical patent/CN111291049A/en
Publication of CN111291049A publication Critical patent/CN111291049A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a storage medium for creating a table. The method comprises the following steps: acquiring structure information of a source table; acquiring the type of a source database where a source table is located and the type of a target database needing table creation; obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list; and creating the table according to the field type of the table in the target database and the structural information of the source table to obtain the target table. The method comprises the steps of obtaining a field type of a table in a target database through a field type of a source table, a type of a source database where the source table is located and a database table structure matching list configured in advance, wherein the database table structure matching list comprises a table structure field type corresponding relation among different databases, and the target table is created by combining specific content of source table structure information, so that the creating process of the table among heterogeneous databases is accurately and quickly achieved.

Description

Method, device, equipment and storage medium for creating table
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a data synchronization method, a data synchronization device, data synchronization equipment and a storage medium.
Background
In the field of smart cities, smart businesses or internet + government affairs services, a data source of a large data platform warehouse comprises various business systems, and due to different business scenes, the database systems used are various, such as MySQL, DM, Oracle, SQL Server, PostgreSQL, GaussDB, Gbase and the like, and sometimes data aggregation and pushing are performed according to business needs, for example, data aggregation comprises from local to province and province to national platform, and data pushing comprises from country to province and province to local and the like. However, the types of databases used in different regions and different levels are different, and the sharing and exchange of data are circulated among different databases, so that the creation of tables among different databases is an urgent need.
The inventor finds that at least the following problems exist in the prior art: because the types and structures of the databases are different, the creation process between heterogeneous databases is very complicated, and the table creation process between heterogeneous databases is usually realized in a manual operation mode, but the mode is not only low in efficiency, but also low in accuracy of the created table, so that the experience effect of a user is influenced.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a storage medium for creating a table. So as to realize the accurate and efficient creation of the table between heterogeneous databases.
In a first aspect, an embodiment of the present invention provides a method for creating a table, including: acquiring the type of a source database and the type of a target database needing table creation; acquiring structural information of a source table in a source database, wherein the structural information comprises a field name, a field type, a field length and field precision; obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list, wherein the database table structure matching list comprises table field type corresponding relations among different types of databases; and creating a table according to the field type of the table in the target database and the structural information of the source table to obtain a target table.
In a second aspect, an embodiment of the present invention provides an apparatus for creating a table, including: the source database and target database acquisition module is used for acquiring the type of the source database and the type of a target database needing table creation; the structure information acquisition module of the source table is used for acquiring the structure information of the source table in the source database, wherein the structure information comprises a field name, a field type, a field length and a field precision; a field type obtaining module of a table in a target database, configured to obtain the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database, and a pre-stored database table structure matching list, where the database table structure matching list includes table field type correspondence between different types of databases; and the target table creating module is used for creating a table according to the field type of the table in the target database and the structural information of the source table to obtain a target table.
In a third aspect, an embodiment of the present invention provides an apparatus, where the apparatus includes:
one or more processors;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the methods of any of the embodiments of the present invention.
In a fourth aspect, the embodiments of the present invention further provide a computer storage medium, on which a computer program is stored, which when executed by a processor implements the method according to any of the embodiments of the present invention.
According to the technical scheme of the embodiment of the invention, the field type of the table in the target database is obtained according to the structure matching list of the database table configured in advance through the field type of the source table and the type of the source database in which the source table is positioned, the structure matching list of the database table comprises the corresponding relation of the table structure field types among different databases, and the target table is created by combining the specific content of the structure information of the source table, so that the creation process of the table among heterogeneous databases can be accurately and quickly realized.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
FIG. 1(a) is a flowchart of a method for creating a table according to an embodiment of the present invention;
FIG. 1(b) is a diagram illustrating a database schema definition language conversion process according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for creating a table according to a second embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an apparatus for creating a table according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus provided in the fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1(a) is a flowchart of a method for creating a table according to an embodiment of the present invention, where this embodiment is applicable to a case where table creation is performed before a heterogeneous database, and this method may be performed by an apparatus for creating a table according to an embodiment of the present invention, and the apparatus may be implemented in software and/or hardware. As shown in fig. 1(a), the method specifically includes the following operations:
step 101, obtaining the type of a source database and the type of a target database needing table creation.
It should be noted that the types of source databases and target databases in this embodiment include: MySQL, DM, Oracle, SQL Server, PostgreSQL, GaussDB or Gbase, and the type of the source database and the type of the target database are not the same. Of course, this embodiment is merely an example, and does not limit the specific types of the source database and the target database.
Specifically, the type of the target database and the type of the source database may be obtained according to a creation instruction of a user. For example, if the user creates a new table in the Oracle database according to the source table a in the MySQL database, the type of the source database may be determined to be MySQL, and the type of the target database may be determined to be Oracle.
It should be noted that, in the present embodiment, the type of the target database is obtained, and at the same time, the mode information of the target database is also obtained, where the mode information includes the storage location of the newly created table in the target database. And when the type of the source database and the type of the target database are obtained, connection information of the source database and connection information of the target database are also obtained, the connection information comprises user login information of the database, and the login process of the source database or the target database can be realized according to the connection information.
Step 102, obtaining structure information of a source table in a source database.
The structure information includes field name, field type, field length and field precision.
Optionally, the structural information may further include: field default and null identification.
Specifically, in this embodiment, structure extraction may be performed on a source table in a source database, so as to obtain structure information of the source table, for example, the obtained structure information of the source table a includes: field name id, field type bigint, field length 20; a field name, a field type varchar, and a field length of 255; a field name sex, a field type char and a field length 1; the field name birthday, the field type date, and the field length default, and certainly, the user may define the field name birthday, the field type date, and the field length default, and the specific numerical value of the default is not defined in the embodiment of the present application.
And 103, acquiring the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list.
Optionally, obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database, and a pre-stored database table structure matching list, may include: extracting a database table structure matching sub-list from a database table structure matching list according to the type of the source database and the type of the target database, wherein the database table structure matching sub-list comprises the corresponding relation of the table field types between the source database and the target database; and converting the field type of the source table according to the database table structure matching sublist to obtain the field type of the table in the target database.
Optionally, converting the field type of the source table according to the database table structure matching sublist to obtain the field type of the table in the target database, where the converting step includes: and determining whether the field type of the source table has a corresponding relation in the database table structure matching sub-list, if so, performing one-to-one corresponding conversion on the field type of the source table according to the database table structure matching sub-list to obtain the field type of the table in the target database, otherwise, performing conversion on the field type of the source table determined to be absent according to a preset conversion mode to obtain the field type of the table in the target database.
Specifically, a database table structure matching list needs to be configured in advance before creating the table, wherein the database table structure matching list includes table field type corresponding relations among different types of databases, and the table field type corresponding relations among the different types of databases can be created by using a java. Therefore, a database table structure matching sub-list can be extracted from the database table structure matching list according to the type of the source database and the type of the target database, where the database table structure matching sub-list includes a corresponding relationship between table field types between the source database and the target database, for example, if the type of the source database is MySql and the type of the target database is Oracle, the following table 1 shows an example of the database table structure matching sub-list extracted from the database table structure matching list:
TABLE 1
Figure BDA0002375065840000061
Figure BDA0002375065840000071
In a specific implementation, the type of the source database is MySql, the type of the target database is Oracle, and according to the type of the source database and the type of the target database, the database table structure matching sub-list extracted from the database table structure matching list is as shown in table 1 above, and the structure information of the source table a obtained from the source database of the type MySql includes: field name id, field type bigint, field length 20; a field name, a field type varchar, and a field length of 255; a field name sex, a field type char and a field length 1; the field name birthday, the field type date, and the field length default. Therefore, it can be determined that the field types of the source table include bigint, varchar, char, and date, and the field types of the source table are converted in a one-to-one correspondence manner according to the database table structure matching sub-list shown in table 1, so as to obtain the field types of the table in the target database. The value of java.sql.type corresponding to the field type bigint of the source table a is-5, and the field type of the table after conversion in the target database corresponding to the value-5 is number, so that the field type of the table after conversion of the field type bigint of the source table a in the target database is number, the field type of the table after conversion of the field type varchar of the source table a in the target database is varchar2, the field type of the table after conversion of the field type char of the source table a in the target database is clob, and the field type of the table after conversion of the field type date of the source table a in the target database is still date, which remains unchanged.
And 104, creating a table according to the field type of the table in the target database and the structure information of the source table to obtain a target table.
Optionally, creating a table according to the field type of the table in the target database and the structure information of the source table to obtain the target table, where the creating includes: assembling the field type of the table in the target database, and the field name, the field length and the field precision in the corresponding source table to obtain a database mode definition language; and establishing according to the database mode definition language to obtain the target table.
Specifically, in this embodiment, after determining the field type of the table in the target database, before each field type in the table in the target database is not converted, information such as a field name, a field length, and a field precision in the corresponding source table may be obtained and assembled to obtain the database schema definition language, for example, the structure information of the source table a obtained in the source database is: the method comprises the following steps: field name id, field type bigint, field length 20; a field name, a field type varchar, and a field length of 255; a field name sex, a field type char and a field length 1; the field name birthday, the field type date, and the field length default. And the corresponding source database table structure of table 1 matches the sublist, then the database schema definition language obtained for reassembly is:
Figure BDA0002375065840000081
so as to create and obtain the target table a' according to the reassembled database schema definition language, wherein a schematic diagram of the conversion process of the database schema definition language is shown in fig. 1 (b).
According to the technical scheme of the embodiment of the invention, the field type of the table in the target database is obtained according to the structure matching list of the database table configured in advance through the field type of the source table and the type of the source database in which the source table is positioned, the structure matching list of the database table comprises the corresponding relation of the table structure field types among different databases, and the target table is created by combining the specific content of the structure information of the source table, so that the creation process of the table among heterogeneous databases can be accurately and quickly realized.
Example two
Fig. 2 is a flowchart of a method for creating a table according to an embodiment of the present invention, where the embodiment is based on the foregoing embodiment, and in this embodiment, after performing table creation according to a field type of a table in a target database and structure information of a source table to obtain a target table, the method further includes: detecting the structural information of the target table and the adaptability of the target database to obtain a detection result, wherein the detection result comprises successful adaptation and failed adaptation; and under the condition that the adaptation is determined to be failed, adjusting the structural information of the target table according to the parameter threshold of the target database. Correspondingly, the method of the embodiment specifically includes the following operations:
step 201, obtaining the type of the source database and the type of the target database needing table creation.
Step 202, obtaining structure information of a source table in a source database.
And step 203, obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list.
And step 204, creating a table according to the field type of the table in the target database and the structure information of the source table to obtain a target table.
Step 205, detecting the adaptability of the structure information of the target table and the target database to obtain a detection result.
It should be noted that, after the target table is created in the target database in the present embodiment, the target table is only transformed in field type with respect to the source table, other variables of the structure information are identical to those of the source table, so that there may exist a case where the structure information of the created target table is not applicable to the target database, for example, the type of the source database where the source table a is located is MySQL, and the field type int is comprised with a field length of 11, while the target database is of type Oracle, and the field type contained in the target table obtained after the field type int has been converted is number, although the field type is transformed, the field length of the field type number is still 11, but the Oracle type database can carry a maximum field length of 8 for the number field type, and 11 exceeds the parameter threshold of the maximum length, thus determining the detection result as a fitting failure.
And step 206, under the condition that the adaptation is determined to fail, adjusting the structural information of the target table according to the parameter threshold of the target database.
Specifically, in the case of a failed adaptation, the structure information of the target table needs to be adjusted according to the parameter threshold of the target database. For example, the field length of the number field type described above is adjusted from 11 to 8.
According to the technical scheme of the embodiment of the invention, the field type of the table in the target database is obtained according to the structure matching list of the database table configured in advance through the field type of the source table and the type of the source database in which the source table is positioned, the structure matching list of the database table comprises the corresponding relation of the table structure field types among different databases, and the target table is created by combining the specific content of the structure information of the source table, so that the creation process of the table among heterogeneous databases can be accurately and quickly realized. The accuracy and the applicability of the target table are further ensured by detecting the adaptability of the structural information of the target table and the target database and adjusting the structural information of the target table under the condition of failed adaptation.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an apparatus for creating a table according to a third embodiment of the present invention, where the apparatus includes: a source database and target database obtaining module 310, a structure information obtaining module 320 of the source table, a field type obtaining module 330 of the table in the target database, and a target table creating module 340.
The source database and target database obtaining module 320 is configured to obtain a type of the source database and a type of the target database that needs to be subjected to table creation;
a structure information obtaining module 310 of the source table, configured to obtain structure information of the source table in the source database, where the structure information includes a field name, a field type, a field length, and a field precision;
a field type obtaining module 330 of the table in the target database, configured to obtain the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database, and a pre-stored database table structure matching list, where the database table structure matching list includes table field type correspondence between different types of databases;
and the target table creating module 340 is configured to perform table creation according to the field type of the table in the target database and the structure information of the source table to obtain the target table.
The device can execute the method for creating the table provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details not described in detail in this embodiment, reference may be made to the method provided in any embodiment of the present invention.
Example four
Fig. 4 is a schematic structural diagram of an apparatus according to an embodiment of the present invention. Fig. 4 illustrates a block diagram of an exemplary device 412 suitable for use in implementing embodiments of the present invention. The device 412 shown in fig. 4 is only an example and should not impose any limitation on the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 4, device 412 is in the form of a general purpose computing device. The components of device 412 may include, but are not limited to: one or more processors 416, a memory 428, and a bus 418 that couples the various system components (including the memory 428 and the processors 416).
Bus 418 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Device 412 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by device 412 and includes both volatile and nonvolatile media, removable and non-removable media.
The memory 428 is used to store instructions. Memory 428 can include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)430 and/or cache memory 432. The device 412 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 434 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 418 by one or more data media interfaces. Memory 428 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 440 having a set (at least one) of program modules 442 may be stored, for instance, in memory 428, such program modules 442 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. The program modules 442 generally perform the functions and/or methodologies of the described embodiments of the invention.
The device 412 may also communicate with one or more external devices 414 (e.g., keyboard, pointing device, display 424, etc.), with one or more devices that enable a user to interact with the device 412, and/or with any devices (e.g., network card, modem, etc.) that enable the device 412 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 422. Also, the device 412 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) through the network adapter 420. As shown, network adapter 420 communicates with the other modules of device 412 over bus 418. It should be appreciated that although not shown in FIG. 4, other hardware and/or software modules may be used in conjunction with device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor 416, by executing instructions stored in the memory 428, performs various functional applications and data processing, such as implementing the method of creating a table provided by embodiments of the present invention: acquiring the type of a source database and the type of a target database needing table creation; acquiring structural information of a source table in a source database, wherein the structural information comprises a field name, a field type, a field length and field precision; obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list, wherein the database table structure matching list comprises table field type corresponding relations among different types of databases; and creating the table according to the field type of the table in the target database and the structural information of the source table to obtain the target table.
EXAMPLE five
Fifth embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for creating a table as provided in all the embodiments of the present invention of the present application:
the method for creating the table comprises the following steps: acquiring the type of a source database and the type of a target database needing table creation; acquiring structural information of a source table in a source database, wherein the structural information comprises a field name, a field type, a field length and field precision; obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list, wherein the database table structure matching list comprises table field type corresponding relations among different types of databases; and creating the table according to the field type of the table in the target database and the structural information of the source table to obtain the target table.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method of creating a table, comprising:
acquiring the type of a source database and the type of a target database needing table creation;
acquiring structural information of a source table in the source database, wherein the structural information comprises a field name, a field type, a field length and field precision;
obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database and a pre-stored database table structure matching list, wherein the database table structure matching list comprises table field type corresponding relations among different types of databases;
and creating a table according to the field type of the table in the target database and the structural information of the source table to obtain a target table.
2. The method of claim 1, wherein the type of the source database and the type of the target database comprise: MySQL, DM, Oracle, SQL Server, PostgreSQL, GaussDB, or Gbase.
3. The method of claim 2, wherein obtaining the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database, and a pre-stored database table structure matching list comprises:
extracting a database table structure matching sub-list from the database table structure matching list according to the type of the source database and the type of the target database, wherein the database table structure matching sub-list comprises the corresponding relation of the table field types between the source database and the target database;
and converting the field type of the source table according to the database table structure matching sublist to obtain the field type of the table in the target database.
4. The method of claim 3, wherein the converting the field type of the source table according to the database table structure matching sublist to obtain the field type of the table in the target database comprises:
determining whether the field type of the source table has a corresponding relation in the database table structure matching sublist, if so, performing one-to-one corresponding conversion on the field type of the source table according to the database table structure matching sublist to obtain the field type of the table in the target database, otherwise,
and converting the field type of the source table which is determined to be absent according to a preset conversion mode to obtain the field type of the table in the target database.
5. The method of claim 1, wherein the table creation according to the field type of the table in the target database and the structure information of the source table to obtain the target table comprises:
assembling the field type of the table in the target database, and the field name, the field length and the field precision in the corresponding source table to obtain a database mode definition language;
and establishing according to the database mode definition language to obtain the target table.
6. The method of claim 5, wherein after the table creation according to the field type of the table in the target database and the structure information of the source table to obtain the target table, the method further comprises:
detecting the structural information of the target table and the adaptability of the target database to obtain a detection result, wherein the detection result comprises the success of adaptation and the failure of adaptation;
and under the condition that the adaptation is determined to be failed, adjusting the structural information of the target table according to the parameter threshold of the target database.
7. The method according to any one of claims 1 to 6, wherein the structure information further comprises: field default and null identification.
8. An apparatus for creating a table, comprising:
the source database and target database acquisition module is used for acquiring the type of the source database and the type of a target database needing table creation;
the system comprises a structure information acquisition module of a source table, a data processing module and a data processing module, wherein the structure information acquisition module is used for acquiring the structure information of the source table in a source database, and the structure information comprises field names, field types, field lengths and field precision;
a field type obtaining module of a table in a target database, configured to obtain the field type of the table in the target database according to the field type of the source table, the type of the source database, the type of the target database, and a pre-stored database table structure matching list, where the database table structure matching list includes table field type correspondence between different types of databases;
and the target table creating module is used for creating a table according to the field type of the table in the target database and the structural information of the source table to obtain a target table.
9. An apparatus, characterized in that the apparatus comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer storage medium on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202010062889.1A 2020-01-19 2020-01-19 Method, device, equipment and storage medium for creating table Pending CN111291049A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010062889.1A CN111291049A (en) 2020-01-19 2020-01-19 Method, device, equipment and storage medium for creating table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010062889.1A CN111291049A (en) 2020-01-19 2020-01-19 Method, device, equipment and storage medium for creating table

Publications (1)

Publication Number Publication Date
CN111291049A true CN111291049A (en) 2020-06-16

Family

ID=71021257

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010062889.1A Pending CN111291049A (en) 2020-01-19 2020-01-19 Method, device, equipment and storage medium for creating table

Country Status (1)

Country Link
CN (1) CN111291049A (en)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767346A (en) * 2020-07-02 2020-10-13 深圳新贝奥科技有限公司 Database data synchronization method, device, equipment and storage medium
CN111858760A (en) * 2020-07-13 2020-10-30 中国工商银行股份有限公司 Data processing method and device for heterogeneous database
CN111930819A (en) * 2020-08-14 2020-11-13 工银科技有限公司 ETL script generation method and device
CN112328696A (en) * 2020-11-17 2021-02-05 北京金和网络股份有限公司 Method and device for synchronizing data in MySQL database to SQL Server database
CN112631586A (en) * 2020-12-24 2021-04-09 软通动力信息技术(集团)股份有限公司 Application development method and device, electronic equipment and storage medium
CN112732242A (en) * 2021-01-12 2021-04-30 中国邮政储蓄银行股份有限公司 Wide table processing script generation method and device
CN112948250A (en) * 2021-03-03 2021-06-11 浪潮云信息技术股份公司 Structure detection method and system based on data standard
CN114153909A (en) * 2021-11-26 2022-03-08 北京人大金仓信息技术股份有限公司 Database table structure translation method and device based on Velocity template engine
CN114661723A (en) * 2022-03-29 2022-06-24 杭州数梦工场科技有限公司 Data processing method and device and electronic equipment
CN116467372A (en) * 2023-02-21 2023-07-21 中国人民解放军海军工程大学 Automatic database conversion method and device, electronic equipment and storage medium
CN117033519A (en) * 2023-09-28 2023-11-10 北京谷器数据科技有限公司 Method and system for synchronizing relational heterogeneous database data
CN114153909B (en) * 2021-11-26 2024-06-07 北京人大金仓信息技术股份有限公司 Database table structure translation method and device based on vector template engine

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090248710A1 (en) * 2008-03-27 2009-10-01 Microsoft Corporation Database Part Table Junctioning
CN104281704A (en) * 2014-10-22 2015-01-14 新华瑞德(北京)网络科技有限公司 Database data copying method and device
CN105069033A (en) * 2015-07-22 2015-11-18 北京京东尚科信息技术有限公司 Method and device for creating database table model
US20170161291A1 (en) * 2015-12-03 2017-06-08 Sap Se Database table conversion
CN108053545A (en) * 2017-12-29 2018-05-18 百度在线网络技术(北京)有限公司 Certificate verification method and apparatus, server, storage medium
CN109783555A (en) * 2018-12-13 2019-05-21 东软集团股份有限公司 Form templat storage method, device, storage medium and electronic equipment
CN109992595A (en) * 2019-04-11 2019-07-09 北京启迪区块链科技发展有限公司 Different database conversion method, apparatus, equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090248710A1 (en) * 2008-03-27 2009-10-01 Microsoft Corporation Database Part Table Junctioning
CN104281704A (en) * 2014-10-22 2015-01-14 新华瑞德(北京)网络科技有限公司 Database data copying method and device
CN105069033A (en) * 2015-07-22 2015-11-18 北京京东尚科信息技术有限公司 Method and device for creating database table model
US20170161291A1 (en) * 2015-12-03 2017-06-08 Sap Se Database table conversion
CN108053545A (en) * 2017-12-29 2018-05-18 百度在线网络技术(北京)有限公司 Certificate verification method and apparatus, server, storage medium
CN109783555A (en) * 2018-12-13 2019-05-21 东软集团股份有限公司 Form templat storage method, device, storage medium and electronic equipment
CN109992595A (en) * 2019-04-11 2019-07-09 北京启迪区块链科技发展有限公司 Different database conversion method, apparatus, equipment and storage medium

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767346A (en) * 2020-07-02 2020-10-13 深圳新贝奥科技有限公司 Database data synchronization method, device, equipment and storage medium
CN111858760A (en) * 2020-07-13 2020-10-30 中国工商银行股份有限公司 Data processing method and device for heterogeneous database
CN111858760B (en) * 2020-07-13 2024-03-22 中国工商银行股份有限公司 Data processing method and device for heterogeneous database
CN111930819A (en) * 2020-08-14 2020-11-13 工银科技有限公司 ETL script generation method and device
CN111930819B (en) * 2020-08-14 2024-03-15 中国工商银行股份有限公司 ETL script generation method and device
CN112328696A (en) * 2020-11-17 2021-02-05 北京金和网络股份有限公司 Method and device for synchronizing data in MySQL database to SQL Server database
CN112631586B (en) * 2020-12-24 2023-05-26 软通动力信息技术(集团)股份有限公司 Application development method and device, electronic equipment and storage medium
CN112631586A (en) * 2020-12-24 2021-04-09 软通动力信息技术(集团)股份有限公司 Application development method and device, electronic equipment and storage medium
CN112732242A (en) * 2021-01-12 2021-04-30 中国邮政储蓄银行股份有限公司 Wide table processing script generation method and device
CN112948250B (en) * 2021-03-03 2024-02-02 浪潮云信息技术股份公司 Structure detection method and system based on data standard
CN112948250A (en) * 2021-03-03 2021-06-11 浪潮云信息技术股份公司 Structure detection method and system based on data standard
CN114153909A (en) * 2021-11-26 2022-03-08 北京人大金仓信息技术股份有限公司 Database table structure translation method and device based on Velocity template engine
CN114153909B (en) * 2021-11-26 2024-06-07 北京人大金仓信息技术股份有限公司 Database table structure translation method and device based on vector template engine
CN114661723A (en) * 2022-03-29 2022-06-24 杭州数梦工场科技有限公司 Data processing method and device and electronic equipment
CN116467372A (en) * 2023-02-21 2023-07-21 中国人民解放军海军工程大学 Automatic database conversion method and device, electronic equipment and storage medium
CN117033519A (en) * 2023-09-28 2023-11-10 北京谷器数据科技有限公司 Method and system for synchronizing relational heterogeneous database data

Similar Documents

Publication Publication Date Title
CN111291049A (en) Method, device, equipment and storage medium for creating table
CN110083639B (en) Intelligent data blood source tracing method and device based on cluster analysis
CN111709527A (en) Operation and maintenance knowledge map library establishing method, device, equipment and storage medium
CN111813804B (en) Data query method and device, electronic equipment and storage medium
US8862563B2 (en) Getting dependency metadata using statement execution plans
CN110020358B (en) Method and device for generating dynamic page
CN109165209B (en) Data verification method, device, equipment and medium for object types in database
CN112328631A (en) Production fault analysis method and device, electronic equipment and storage medium
CN114691161A (en) Key-Value-based software system configuration method and device and electronic equipment
CN112783482B (en) Visual form generation method, device, equipment and storage medium
CN111984745B (en) Database field dynamic expansion method, device, equipment and storage medium
US20070282804A1 (en) Apparatus and method for extracting database information from a report
WO2019071907A1 (en) Method for identifying help information based on operation page, and application server
CN115759040A (en) Electronic medical record analysis method, device, equipment and storage medium
CN110825802A (en) Multi-type database data backup method, device, equipment and storage medium
CN114265966A (en) Data processing method and device, electronic equipment and storage medium
CN115391322A (en) Data checking method, device, equipment, storage medium and program product
CN114519071A (en) Generation method, matching method, system, device and medium of rule matching model
CN114154468A (en) Report synthesis method and device, electronic equipment and storage medium
CN114090124A (en) Data processing method, data processing device, computer equipment and storage medium
CN113722296A (en) Agricultural information processing method and device, electronic equipment and storage medium
CN114661751B (en) Data production method, device, system, equipment and medium based on SQL (structured query language) knowledge base
CN111262727A (en) Service capacity expansion method, device, equipment and storage medium
CN116644035B (en) File batch warehousing method, device, equipment and storage medium
CN113742225B (en) Test data generation method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination