CN111125064B - Method and device for generating database schema definition statement - Google Patents

Method and device for generating database schema definition statement Download PDF

Info

Publication number
CN111125064B
CN111125064B CN201911347549.7A CN201911347549A CN111125064B CN 111125064 B CN111125064 B CN 111125064B CN 201911347549 A CN201911347549 A CN 201911347549A CN 111125064 B CN111125064 B CN 111125064B
Authority
CN
China
Prior art keywords
definition
database
code
model file
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.)
Active
Application number
CN201911347549.7A
Other languages
Chinese (zh)
Other versions
CN111125064A (en
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.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
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 China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN201911347549.7A priority Critical patent/CN111125064B/en
Publication of CN111125064A publication Critical patent/CN111125064A/en
Application granted granted Critical
Publication of CN111125064B publication Critical patent/CN111125064B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/21Design, administration or maintenance of databases
    • G06F16/211Schema design and management
    • G06F16/212Schema design and management with details for data modelling support
    • 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
    • G06F16/2228Indexing 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages

Landscapes

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

Abstract

The invention discloses a method and a device for generating database mode definition sentences, and relates to the technical field of computers. One embodiment of the method comprises the following steps: importing a model file, and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information; calling a code definition template according to the database definition parameters and generating a field definition code; and filling the field definition codes into the code definition templates to generate database schema definition statements. The implementation mode can solve the technical problem of great difficulty in code development.

Description

Method and device for generating database schema definition statement
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for generating a database schema definition sentence.
Background
In the process of defining the database, a database developer needs to design a logical structure of the database on one hand, and needs to design a partition, storage and other physical parameters related to the logical structure on the other hand. The combination of the two aspects is a final state DDL (Data Definition Language, database schema definition language) statement.
The logical structure design of the database is to convert the basic entity-relation diagram designed in the conceptual structure design stage into a logical structure conforming to the data model supported by the selected database management system product. The physical parameters of the database mainly comprise the partition mode of the database, compression options during the storage of the database, file space allocation options and other parameters. Based on the above, the whole process management of the database definition needs to fuse the above design at the DDL statement level and finally deploy to the background development environment.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
currently, database developers typically need to write a large number of DDL statements and validation scripts and migrate to different test environments for validation. When the database is defined more and the parameter difference between the definitions is large, the operation complexity of the database developer is large and the error rate is high. Especially in the development stage of software, database definition changes relatively frequently, workload and labor cost can be multiplied, and more importantly, timeliness and correctness of the changes directly influence the development and testing work progress.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for generating database schema definition sentences, so as to solve the technical problem of high code development difficulty.
To achieve the above object, according to one aspect of an embodiment of the present invention, there is provided a method of generating a database schema definition sentence, including:
importing a model file, and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information;
calling a code definition template according to the database definition parameters and generating a field definition code;
and filling the field definition codes into the code definition templates to generate database schema definition statements.
Optionally, the model file is an XML file output by a data modeling tool, and the model file includes a structure of a database table and an index structure of the database table.
Optionally, invoking the code definition template and generating the field definition code according to the database definition parameters includes:
matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information;
and calling a corresponding code definition template according to the database name and the partition definition information.
Optionally, before reading the model file, the method further includes:
and updating the model file in response to configuration information input by a user.
In addition, according to another aspect of an embodiment of the present invention, there is provided an apparatus for generating a database schema definition sentence, including:
the analysis module is used for importing a model file and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information;
the definition module is used for calling a code definition template according to the database definition parameters and generating a field definition code;
and the filling module is used for filling the field definition codes into the code definition templates to generate database schema definition sentences.
Optionally, the model file is an XML file output by a data modeling tool, and the model file includes a structure of a database table and an index structure of the database table.
Optionally, the definition module is further configured to:
matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information;
and calling a corresponding code definition template according to the database name and the partition definition information.
Optionally, the parsing module is further configured to:
before reading the model file, the model file is updated in response to configuration information input by a user.
According to another aspect of an embodiment of the present invention, there is also provided an electronic device including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the methods of any of the embodiments described above.
According to another aspect of an embodiment of the present invention, there is also provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements the method according to any of the embodiments described above.
One embodiment of the above invention has the following advantages or benefits: because the technical means of analyzing the database definition parameters of the model file, calling the code definition template according to the database definition parameters and generating the field definition code, and filling the field definition code into the code definition template to generate the database mode definition statement is adopted, the technical problem of high code development difficulty in the prior art is solved. The embodiment of the invention can directly import the general database logic structure design model file, and obtain the code definition template and the field definition code by analyzing the database definition parameters of the model file, thereby generating the database mode definition statement, reducing the code development difficulty and saving the time for writing DDL by database developers. Therefore, the embodiment of the invention greatly shortens the timeliness and convenience of database definition version iteration and simultaneously reduces the labor cost of database management.
In addition, the embodiment of the invention also supports interaction with a background test environment, an effective flow is automatically executed, the generated database mode definition statement can be submitted to the test environment by one key, and the deployment of the database definition is completed.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method of generating database schema definition statements in accordance with an embodiment of the invention;
FIG. 2 is a schematic diagram of the main flow of a method of generating database schema definition statements in accordance with one referenceable embodiment of the invention;
FIG. 3 is a schematic diagram of the main flow of a method of generating database schema definition statements in accordance with another referenceable embodiment of the invention;
FIG. 4 is a schematic diagram of the major modules of an apparatus for generating database schema definition statements in accordance with an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main flow of a method of generating a database schema definition sentence according to an embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the method for generating a database schema definition sentence may include:
and step 101, importing a model file, and reading the model file to analyze database definition parameters of the model file.
Firstly, outputting a model file through a data modeling tool, then importing the model file, and reading the model file, so that database definition parameters of the model file are analyzed. Optionally, the model file is an XML file output by a data modeling tool, and the model file includes a structure of a database table and an index structure of the database table. Alternatively, the data modeling tool may be an ERWIN (Erwin Data Modeler, data modeling tool of ERWIN corporation), and the developer may perform the logical structure design of the database through the ERWIN, and finally output the model file in XML format, where the model file includes the structure of the database table, the structure of the index, and so on. Where a database definition is a definition (e.g., tablespace, table, index, etc.) of a database object. Optionally, the database definition parameters include a field name, a database name, and partition definition information.
Optionally, before reading the model file, the method further comprises: and updating the model file in response to configuration information input by a user. In the embodiment of the invention, after the model file is imported, the model file can be configured. In particular, the developer may add optional configuration parameters (such as database names, partition definition parameters, etc.) to form a new XML model file. Wherein, the configuration information can be field name, database name or partition definition information, etc.
And 102, calling a code definition template according to the database definition parameters and generating a field definition code.
After parsing out the database definition parameters, the code definition templates may be invoked and field definition codes generated according to the database definition parameters. Optionally, step 102 may include: matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information; and calling a corresponding code definition template according to the database name and the partition definition information. In the embodiment of the invention, the corresponding relation between each database name and each field name and the type definition information is required to be preconfigured, so that the field definition code is generated according to the matched definition type information. For example, the type definition of the character type in DB2 data is CHAR (n), and the type definition in oracle is CHAR (n); the type definition of numeric value in DB2 data is smallline/int/big, the type definition in oracle is number (n), these correspondences can be stored in enterprise data dictionary. The embodiment of the invention can flexibly set the database differentiation definition information of different legal persons and generate the table definition information of different database types such as DB2, ORACLE and the like.
Therefore, the data modeling tool may only pay attention to field names when designing model relationships, does not need to bring in type information, and supports different types of definitions (different platform differences, such as DB2 and oracle data type definition differences) of the same field. Alternatively, the implementation may be such that the program maps to different database field definition codes according to the underlying type definition in the data dictionary.
Similarly, the corresponding relation between each database name and partition definition information and the code definition template needs to be preconfigured, so that the corresponding code definition template is called according to the database name and the partition definition information.
In addition to field information, other database definition parameters, such as schema, db name, partition definition information, etc., are also parsed. For example, the corresponding code definition template may be called for generating a final database schema definition statement based on the database name and parsed partition definition information.
And step 103, filling the field definition codes into the code definition templates to generate database schema definition sentences.
After the field definition codes and the code definition templates are obtained, the field definition codes are filled into the code definition templates, so that a final database schema definition statement is obtained.
According to the various embodiments described above, it can be seen that the technical means of generating database schema definition sentences by analyzing the database definition parameters of the model file, calling the code definition templates according to the database definition parameters and generating field definition codes, and filling the field definition codes into the code definition templates is provided, so that the technical problem of high difficulty in code development in the prior art is solved. The embodiment of the invention can directly import the general database logic structure design model file, and obtain the code definition template and the field definition code by analyzing the database definition parameters of the model file, thereby generating the database mode definition statement, reducing the code development difficulty and saving the time for writing DDL by database developers. Therefore, the embodiment of the invention greatly shortens the timeliness and convenience of database definition version iteration and simultaneously reduces the labor cost of database management.
Fig. 2 is a schematic diagram of the main flow of a method of generating a database schema definition sentence according to one referenceable embodiment of the present invention. As yet another embodiment of the present invention, as shown in fig. 2, the method for generating a database schema definition sentence may include:
in step 201, a model file is imported.
The model file may be output by a data modeling tool and then imported. Alternatively, the data modeling tool may be ERWIN, and a developer may perform logical structure design of the database through ERWIN, and finally output a model file in XML format, where the model file includes a structure of a database table, an indexed structure, and so on.
And step 202, updating the model file in response to configuration information input by a user.
In the embodiment of the invention, after the model file is imported, the model file can be configured. In particular, the developer may add optional configuration parameters (such as database names, partition definition parameters, etc.) to form a new XML model file. Wherein, the configuration information can be field name, database name or partition definition information, etc.
And 203, reading the model file to analyze database definition parameters of the model file.
And reading the model file so as to analyze database definition parameters of the model file. Optionally, the database definition parameters include a field name, a database name, and partition definition information.
And 204, matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information.
The database names and the correspondence between the field names and the type definition information need to be preconfigured, so that the field definition codes are generated according to the matched definition type information. For example, the type definition of the character type in DB2 data is CHAR (n), and the type definition in oracle is CHAR (n); the type definition of numeric value in DB2 data is smallline/int/big, the type definition in oracle is number (n), these correspondences can be stored in enterprise data dictionary.
And step 205, calling a corresponding code definition template according to the database name and the partition definition information.
The corresponding relation between each database name and partition definition information and the code definition template needs to be pre-configured, so that the corresponding code definition template is called according to the database name and the partition definition information.
And step 206, filling the field definition codes into the code definition templates to generate database schema definition sentences.
After the field definition codes and the code definition templates are obtained, the field definition codes are filled into the code definition templates, so that a final database schema definition statement is obtained.
In addition, in the embodiment of the present invention, the method for generating the database schema definition sentence is described in detail in the above description, so that the description is not repeated here.
FIG. 3 is a schematic diagram of the main flow of a method of generating database schema definition statements in accordance with another referenceable embodiment of the invention. As another embodiment of the present invention, as shown in fig. 3, the method for generating a database schema definition sentence may include:
step 301, importing a model file, and reading the model file to analyze database definition parameters of the model file.
Step 302, matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information.
And step 303, calling a corresponding code definition template according to the database name and the partition definition information.
And step 304, filling the field definition codes into the code definition templates to generate database schema definition sentences.
Step 305, uploading the database schema definition sentence to a test environment, and running the database schema definition sentence in the test environment.
The embodiment of the invention reduces the difficulty of code development, saves the time for writing DDL by a database developer, supports interaction with a background test environment, automatically executes the effective flow, and can submit the generated database mode definition statement to the test environment by one key to complete the deployment of database definition.
In addition, in the embodiment of the present invention, the method for generating the database schema definition sentence is described in detail in the above description, so that the description is not repeated here.
Fig. 4 is a schematic diagram of main modules of an apparatus for generating a database schema definition sentence according to an embodiment of the present invention, and as shown in fig. 4, the apparatus 400 for generating a database schema definition sentence includes a parsing module 401, a defining module 402, and a filling module 403. The parsing module 401 is configured to import a model file, read the model file, and parse database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information; the definition module 402 is configured to invoke a code template and generate a field definition code according to the database definition parameters; the populating module 403 is configured to populate the field definition code into the code definition template to generate a database schema definition statement.
Optionally, the model file is an XML file output by a data modeling tool, and the model file includes a structure of a database table and an index structure of the database table.
Optionally, the definition module 402 is further configured to:
matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information;
and calling a corresponding code definition template according to the database name and the partition definition information.
Optionally, the parsing module 401 is further configured to:
before reading the model file, the model file is updated in response to configuration information input by a user.
According to the various embodiments described above, it can be seen that the technical means of generating database schema definition sentences by analyzing the database definition parameters of the model file, calling the code definition templates according to the database definition parameters and generating field definition codes, and filling the field definition codes into the code definition templates is provided, so that the technical problem of high difficulty in code development in the prior art is solved. The embodiment of the invention can directly import the general database logic structure design model file, and obtain the code definition template and the field definition code by analyzing the database definition parameters of the model file, thereby generating the database mode definition statement, reducing the code development difficulty and saving the time for writing DDL by database developers. Therefore, the embodiment of the invention greatly shortens the timeliness and convenience of database definition version iteration and simultaneously reduces the labor cost of database management.
The details of the implementation of the apparatus for generating a database schema definition sentence according to the present invention are already described in detail in the method for generating a database schema definition sentence, and therefore, the description thereof will not be repeated here.
Fig. 5 illustrates an exemplary system architecture 500 of a method of generating a database schema definition sentence or an apparatus of generating a database schema definition sentence to which an embodiment of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications may be installed on the terminal devices 501, 502, 503, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (by way of example only) providing support for shopping-type websites browsed by users using the terminal devices 501, 502, 503. The background management server may analyze and process the received data such as the article information query request, and feedback the processing result (e.g., the target push information, the article information—only an example) to the terminal device.
It should be noted that, the method for generating the database schema definition sentence provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the device for generating the database schema definition sentence is generally disposed in the server 505. The method for generating the database schema definition sentence provided by the embodiment of the present invention may also be executed by the terminal devices 501, 502, 503, and correspondingly, the apparatus for generating the database schema definition sentence may be provided in the terminal devices 501, 502, 503.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: 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. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. 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 of the foregoing. 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, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes an parsing module, a defining module, and a populating module, wherein the names of the modules do not constitute a limitation on the module itself in some cases.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: importing a model file, and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information; calling a code definition template according to the database definition parameters and generating a field definition code; and filling the field definition codes into the code definition templates to generate database schema definition statements.
According to the technical scheme of the embodiment of the invention, the technical means of analyzing the database definition parameters of the model file, calling the code definition template according to the database definition parameters and generating the field definition code, and filling the field definition code into the code definition template to generate the database mode definition statement are adopted, so that the technical problem of high code development difficulty in the prior art is solved. The embodiment of the invention can directly import the general database logic structure design model file, and obtain the code definition template and the field definition code by analyzing the database definition parameters of the model file, thereby generating the database mode definition statement, reducing the code development difficulty and saving the time for writing DDL by database developers. Therefore, the embodiment of the invention greatly shortens the timeliness and convenience of database definition version iteration and simultaneously reduces the labor cost of database management.
In addition, the embodiment of the invention also supports interaction with a background test environment, an effective flow is automatically executed, the generated database mode definition statement can be submitted to the test environment by one key, and the deployment of the database definition is completed.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (6)

1. A method of generating database schema definition statements, comprising:
importing a model file, and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information;
calling a code definition template according to the database definition parameters and generating a field definition code;
filling the field definition codes into the code definition templates to generate database schema definition statements;
the model file is an XML file output by a data modeling tool, and comprises a structure of a database table and an index structure of the database table;
invoking a code definition template and generating a field definition code according to the database definition parameters, including:
matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information;
calling a corresponding code definition template according to the database name and the partition definition information;
further comprises:
and pre-configuring the corresponding relation between each database name and each field name and the type definition information, and pre-configuring the corresponding relation between each database name and the partition definition information and the code definition template.
2. The method of claim 1, further comprising, prior to reading the model file:
and updating the model file in response to configuration information input by a user.
3. An apparatus for generating database schema definition statements, comprising:
the analysis module is used for importing a model file and reading the model file to analyze database definition parameters of the model file; wherein the database definition parameters comprise field names, database names and partition definition information;
the definition module is used for calling a code definition template according to the database definition parameters and generating a field definition code;
the filling module is used for filling the field definition codes into the code definition templates to generate database mode definition sentences;
the model file is an XML file output by a data modeling tool, and comprises a structure of a database table and an index structure of the database table;
the definition module is further configured to:
matching corresponding type definition information according to the field name and the database name, and generating a field definition code according to the type definition information;
calling a corresponding code definition template according to the database name and the partition definition information;
the definition module is further configured to:
and pre-configuring the corresponding relation between each database name and each field name and the type definition information, and pre-configuring the corresponding relation between each database name and the partition definition information and the code definition template.
4. The apparatus of claim 3, wherein the parsing module is further configured to:
before reading the model file, the model file is updated in response to configuration information input by a user.
5. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of claim 1 or 2.
6. A computer readable medium on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to claim 1 or 2.
CN201911347549.7A 2019-12-24 2019-12-24 Method and device for generating database schema definition statement Active CN111125064B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911347549.7A CN111125064B (en) 2019-12-24 2019-12-24 Method and device for generating database schema definition statement

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911347549.7A CN111125064B (en) 2019-12-24 2019-12-24 Method and device for generating database schema definition statement

Publications (2)

Publication Number Publication Date
CN111125064A CN111125064A (en) 2020-05-08
CN111125064B true CN111125064B (en) 2023-08-29

Family

ID=70501790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911347549.7A Active CN111125064B (en) 2019-12-24 2019-12-24 Method and device for generating database schema definition statement

Country Status (1)

Country Link
CN (1) CN111125064B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767266A (en) * 2020-05-15 2020-10-13 杭州传化智能制造科技有限公司 Entity contact model design method and device, computer equipment and storage medium
CN111966687B (en) * 2020-08-18 2024-04-16 中国银行股份有限公司 Mainframe DB2 database table partitioning method and device
CN113779945A (en) * 2020-08-20 2021-12-10 北京沃东天骏信息技术有限公司 Method and device for generating file
CN112632072B (en) * 2020-12-24 2023-04-07 浪潮软件科技有限公司 Method and device for generating C-format NR database table information based on VB

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106354515A (en) * 2016-09-26 2017-01-25 杭州杉石科技有限公司 SystemC code generation system based on model
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
CN107368346A (en) * 2017-07-06 2017-11-21 万惠投资管理有限公司 A kind of code generating method and device based on metadata and script engine
CN107908394A (en) * 2017-11-21 2018-04-13 中国电子科技集团公司第五十四研究所 A kind of data interchange format source code generation method and instrument
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106873949A (en) * 2015-12-11 2017-06-20 泰康保险集团股份有限公司 Code generating method and its device
CN106354515A (en) * 2016-09-26 2017-01-25 杭州杉石科技有限公司 SystemC code generation system based on model
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN107368346A (en) * 2017-07-06 2017-11-21 万惠投资管理有限公司 A kind of code generating method and device based on metadata and script engine
CN107908394A (en) * 2017-11-21 2018-04-13 中国电子科技集团公司第五十四研究所 A kind of data interchange format source code generation method and instrument

Also Published As

Publication number Publication date
CN111125064A (en) 2020-05-08

Similar Documents

Publication Publication Date Title
CN111125064B (en) Method and device for generating database schema definition statement
CN111177231A (en) Report generation method and report generation device
US20210208854A1 (en) System and method for enhancing component based development models with auto-wiring
CN110543297B (en) Method and apparatus for generating source code
CN111414350B (en) Service generation method and device
CN108108986B (en) Design method and device of customer relationship management system and electronic equipment
CN113760948A (en) Data query method and device
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN113419789A (en) Method and device for generating data model script
CN110222047A (en) A kind of dynamic list generation method and device
US20210124752A1 (en) System for Data Collection, Aggregation, Storage, Verification and Analytics with User Interface
CN113419740A (en) Program data stream analysis method and device, electronic device and readable storage medium
CN113238739A (en) Plug-in development and data acquisition method, device, electronic equipment and medium
CN112579151A (en) Method and device for generating model file
CN114185871A (en) Data migration method, data migration device, medium, and electronic device
US20170161359A1 (en) Pattern-driven data generator
CN113032256A (en) Automatic test method, device, computer system and readable storage medium
CN113762702A (en) Workflow deployment method, device, computer system and readable storage medium
CN113760240A (en) Method and device for generating data model
CN111177183B (en) Method and device for generating database access statement
US20240152511A1 (en) Transliteration of machine interpretable languages for enhanced compaction
CN111401825B (en) Instantiation method and device
US20220147568A1 (en) Mapping expression generator
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN116610706A (en) Data blood-edge analysis method, server and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20220926

Address after: 25 Financial Street, Xicheng District, Beijing 100033

Applicant after: CHINA CONSTRUCTION BANK Corp.

Address before: 25 Financial Street, Xicheng District, Beijing 100033

Applicant before: CHINA CONSTRUCTION BANK Corp.

Applicant before: Jianxin Financial Science and Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant