CN116841982A - Database migration method, device, equipment, storage medium and program product - Google Patents
Database migration method, device, equipment, storage medium and program product Download PDFInfo
- Publication number
- CN116841982A CN116841982A CN202310730284.9A CN202310730284A CN116841982A CN 116841982 A CN116841982 A CN 116841982A CN 202310730284 A CN202310730284 A CN 202310730284A CN 116841982 A CN116841982 A CN 116841982A
- Authority
- CN
- China
- Prior art keywords
- database
- statement
- building
- test
- sentence
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 69
- 230000005012 migration Effects 0.000 title claims abstract description 36
- 238000013508 migration Methods 0.000 title claims abstract description 36
- 238000012360 testing method Methods 0.000 claims description 113
- 238000004590 computer program Methods 0.000 claims description 27
- 230000004048 modification Effects 0.000 claims description 18
- 238000012986 modification Methods 0.000 claims description 18
- 238000012795 verification Methods 0.000 claims description 13
- 230000002159 abnormal effect Effects 0.000 claims description 5
- 238000006243 chemical reaction Methods 0.000 claims description 4
- 238000012937 correction Methods 0.000 claims description 4
- 238000012217 deletion Methods 0.000 claims description 3
- 230000037430 deletion Effects 0.000 claims description 3
- 238000010276 construction Methods 0.000 description 10
- 238000004891 communication Methods 0.000 description 8
- 230000008569 process Effects 0.000 description 7
- 238000012545 processing Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000003993 interaction Effects 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 238000010998 test method Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 230000004807 localization Effects 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/214—Database migration support
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
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 application discloses a migration method, a migration device, migration equipment, a storage medium and a program product of a database. The application relates to the technical field of databases. The method comprises the following steps: comprising the following steps: acquiring configuration information of a new database and a first table-building statement of an original database; converting the first list-building sentence based on the configuration information to obtain a second list-building sentence of the new database; and creating a table structure in the new database according to the second table creating sentence so as to migrate the table structure of the database. According to the database migration method provided by the embodiment of the application, the first table-building sentence is converted based on the configuration information to obtain the second table-building sentence of the new database, so that the table structure is created in the new database according to the second table-building sentence, the migration of the database table structure is realized, and the efficiency and the integrity of the database migration can be improved.
Description
Technical Field
Embodiments of the present application relate to the field of database technologies, and in particular, to a method, an apparatus, a device, a storage medium, and a program product for migrating a database.
Background
Databases are one of the important infrastructures for enterprises to store sensitive data, which may be monitored and stolen if the database software provider is located overseas. While relying on overseas database software providers, the enterprise will be subject to technical limitations. In the conventional financial industry, the stock system mostly uses an overseas database, so that the migration of the financial system database into an inner database is particularly important.
The existing database localization migration mode is still remained in the way of using manual analysis to comb each system transaction, and manual transformation and test are performed. The method has the advantages that the method is complicated and more in files, high in requirements on developers, and prone to generating omission so as to influence production stable operation.
Disclosure of Invention
The embodiment of the application provides a database migration method, a device, equipment, a storage medium and a program product, which can improve the efficiency and the integrity of database migration.
In a first aspect, an embodiment of the present application provides a migration method for a database, including:
acquiring configuration information of a new database and a first table-building statement of an original database;
converting the first list-building sentence based on the configuration information to obtain a second list-building sentence of the new database;
and creating a table structure in the new database according to the second table creating sentence so as to migrate the table structure of the database.
In a second aspect, an embodiment of the present application further provides a migration apparatus for a database, including:
the acquisition module is used for acquiring configuration information of the new database and a first table-building statement of the original database;
the table-building sentence conversion module is used for converting the first table-building sentence based on the configuration information to obtain a second table-building sentence of the new database;
and the table structure creation module is used for creating a table structure in the new database according to the second table creating sentence so as to migrate the table structure of the database.
In a third aspect, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements migration of a database according to the embodiment of the present application when the processor executes the program.
In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the program when executed by a processor implements a method for migrating a database according to an embodiment of the present application.
In a fifth aspect, embodiments of the present application further provide a computer program product comprising a computer program which, when executed by a processor, implements a method of migrating a database as described in embodiments of the present application.
The embodiment of the application discloses a migration method, a migration device, migration equipment, a storage medium and a program product for a database, wherein configuration information of a new database and a first table-building statement of an original database are obtained; converting the first table-building sentence based on the configuration information to obtain a second table-building sentence of the new database; and creating a table structure in the new database according to the second table-building statement so as to migrate the table structure of the database. According to the database migration method provided by the embodiment of the application, the first table-building sentence is converted based on the configuration information to obtain the second table-building sentence of the new database, so that the table structure is created in the new database according to the second table-building sentence, the migration of the database table structure is realized, and the efficiency and the integrity of the database migration can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for migrating a database according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for migrating a database according to an embodiment of the present application;
FIG. 3 is a flow chart of testing a new database after migration according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a migration apparatus for a database according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
It should be noted that: like reference numerals and letters denote like items in the following figures, and thus once an item is defined in one figure, no further definition or explanation thereof is necessary in the following figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only to distinguish the description, and are not to be construed as indicating or implying relative importance. The technical scheme of the application obtains, stores, uses, processes and the like the data, which all meet the relevant regulations of national laws and regulations.
At present, in the process of migrating a database table structure, developers often encounter the situation that the constraints of creating sentences, tables, fields, primary keys, indexes and the like between different original databases and new databases are inconsistent. This requires a deep understanding of the knowledge about the two databases by the developer, which, once biased, can affect the progress of the subsequent databases on-line. In addition, the modification workload for each system is huge, the functions, storage processes, sequences, views and the like among the databases need to be changed one by one, but the system and the database operation have a many-to-many relationship, which is extremely easy to cause errors in the migration process of the databases.
Fig. 1 is a flowchart of a method for migrating a database according to an embodiment of the present application, where the method is applicable to migrating a table structure of a database, and the method may be performed by a migration device of the database, where the device may be implemented in a form of software and/or hardware, and optionally, may be implemented by an electronic device, where the electronic device may be a mobile terminal, a PC side, a server, or the like. As shown in fig. 1, the method includes:
s110, acquiring configuration information of the new database and a first table-building statement of the original database.
The new database may be understood as a newly created database, and the original database may be understood as an old database, and in this embodiment, the table structure in the original database needs to be migrated to the new database. The configuration information may include a database type name and a table-building grammar, the table-building grammar in the configuration information may be determined by a type of the database, and the type of the database may be determined by a developer and version of the database.
In this embodiment, the manner of obtaining the configuration information of the new database may be: determining type information of a new database; configuration information input by a user based on the type information is received.
The configuration information comprises a database type name and a table construction grammar of a new database. If the type of the new database is the existing type, directly acquiring the configuration information of the database of the type; if the type of the new database is not available at present, a developer self-defines the type of the new database through an interactive interface and inputs configuration information of the new database through the interactive interface, wherein the table-building grammar can be understood as writing rules of information such as multiple fields, multiple indexes, a main key external key and the like.
The first table-building statement may be understood as a table-building statement of the original database, where the table-building statement includes table structure information in the original database. In this embodiment, the first table-building statement may be directly extracted from the original database system.
S120, converting the first list-building sentence based on the configuration information to obtain a second list-building sentence of the new database.
In this embodiment, the method for building the table of the new database is learned by identifying keywords in the table-building grammar in the configuration information. Converting the first list-building sentence based on the configuration information may be understood as: and converting the first list-building sentence by a list-building method identified by the list-building grammar in the configuration information to obtain a second list-building sentence of the new database. The process may be: and re-combining the fields contained in the first table-building statement according to the table structure information of the new database, thereby obtaining a second table-building statement of the new database.
Optionally, before converting the first table-building sentence based on the configuration information, the method further includes the following steps: acquiring first server address information of a new database and second server address information of an original database; testing connectivity between the new database and the original database based on the first server address information and the second server address information; accordingly, the process of converting the first table-building sentence based on the configuration information may be: if the connectivity test between the new database and the original database is passed, converting the first table-building sentence based on the configuration information.
The first server address information may be understood as an address of a server corresponding to the new database, and the second server address information may be understood as an address of a server corresponding to the original database. In this embodiment, the manner of testing connectivity between the new database and the original database based on the first server address information and the second server address information may be: logging in a first server through address information of the first server, then sending an access request to a second server through address information of the second server in the first server, and if the first server receives response information returned by the second server, testing connectivity between the first server and the second server; logging in a second server through the address information of the second server, then sending an access request to the first server through the address information of the first server in the second server, and if the second server receives response information returned by the first server, testing connectivity between the first server and the second server.
In this embodiment, if the connectivity test between the new database and the original database passes, the new database may access the original database, so as to facilitate the subsequent migration of the data in the original database to the new database.
S130, creating a table structure in the new database according to the second table creating statement so as to migrate the table structure of the database.
In this embodiment, after the second table-creating sentence is obtained, the table structure may be created in the new database directly according to the second table-creating sentence, so as to implement migration of the database table structure from the original database to the new database. The manner of creating the table structure in the new database based on the second table creating statement may refer to any existing manner, and is not limited herein.
Optionally, before creating the table structure in the new database according to the second table creating statement, the method further comprises the steps of: checking the second list-building sentence to obtain a second list-building sentence which does not pass the checking; displaying the second list-building sentence which is not checked; and receiving the correction of the second table-building statement which is not passed by the verification by the user, and obtaining the corrected second table-building statement.
Wherein verifying the second list creation statement may be understood as verifying whether the second list creation statement is able to successfully create a list structure in the new database.
Specifically, the second table-building sentence is checked, and the mode of obtaining the second table-building sentence which does not pass the check may be: pre-building a table based on the second table building sentence; and determining the second list building statement with failed or abnormal pre-built list as a second list building statement with failed verification.
The method for pre-building the table based on the second table building sentence can be as follows: and pre-creating a table structure in a preset storage space according to the second table-building statement, and determining whether the second table-building statement can successfully create the table structure. When the pre-built table fails or is abnormal, the second table-building sentence is indicated to have a problem, the second table-building sentence is confirmed to be failed in verification and needs to be corrected, at the moment, the second table-building sentence failed in verification is displayed, and a user manually corrects the second table-building sentence failed in verification to obtain a corrected second table-building sentence. In this embodiment, the second table-building sentence is checked, so that the efficiency and accuracy of the subsequent table structure migration can be improved.
On the basis of the above embodiment, fig. 2 is a flowchart of a method for migrating a database in an embodiment of the present application, as shown in fig. 2, and the method includes the following steps:
s210, determining the type information of the new database.
S220, receiving a database type name and a new database list construction grammar input by a user based on the type information.
S230, acquiring the first server address information of the new database and the second server address information of the original database;
and S240, testing connectivity between the new database and the original database based on the first server address information and the second server address information.
S250, if the connectivity test between the new database and the original database is passed, converting the first list-building sentence based on the configuration information.
S260, performing pre-construction of the table based on the second construction sentence, and displaying the second construction sentence with failed pre-construction or abnormal construction;
s270, receiving correction of the second list construction statement which is not passed by the verification by the user, and obtaining a corrected second list construction statement;
s280, creating a table structure in the new database according to the second table creation statement so as to migrate the table structure of the database.
Optionally, after creating the table structure in the new database according to the second table-building statement, the method further comprises the steps of: acquiring a database operation statement; generating a test case based on the database operation statement; and performing data operation test on the new database based on the test cases.
Wherein the database operation statement (Structured Query Language, SQL) comprises: adding sentences, deleting sentences, modifying sentences and inquiring sentences. The test cases comprise database operation data and corresponding test data. In this embodiment, the database operation statement is obtained by parsing a database operation file, which may be an xml format file. Test data may be generated based on a table field type corresponding to the database operation statement.
Specifically, the method for acquiring the database operation statement may be: acquiring a database operation file; and analyzing the database operation file to obtain a database operation statement.
The method for acquiring the database operation file may be: firstly, a catalog storing database operation (xml format) files is obtained, and then all database operation files under the catalog and sub-catalog are extracted. After the data operation file is obtained, the database operation file is analyzed, and the database operation statement is obtained.
Optionally, before parsing the database operation file, the method further includes the following steps: checking the database operation file, and displaying the database operation file which does not pass the checking; and receiving marks or modifications of the database operation files which are not checked by the user.
In this embodiment, it is first checked whether the database operation files conform to the specifications of the database framework, and for the database operation files that do not conform to the specifications, the database operation files are displayed to the user in the form of a list, and the user may mark the database operation files as not tested or correct the database operation files.
Specifically, the manner of generating the test cases based on the database operation statement may be: acquiring a table field type corresponding to a database operation statement; generating test data based on the table field type; and generating a test case according to the database operation statement and the test data.
The table field type may be a character type, a date type, a number type, a boolean type, a binary type, and the like. Generating test data based on table field type can be understood as: if the table field type is a character string type, randomly generating test data of the character string type; if the table field type is a date type, randomly generating test data of the date type; if the table field type is the Boolean type, randomly generating test data of the Boolean type; if the table field type is binary type, test data of binary type is randomly generated. And finally, combining the database operation statement and the test data to obtain a test case.
Specifically, the data operation test method for the new database based on the test cases can be as follows: if the database operation statement is any one of a deletion statement, a modification statement and a query statement, inserting test data into a table structure corresponding to the database operation statement in the new database; and carrying out corresponding data operation test on the new database based on the database operation statement.
In this embodiment, if the database operation statement is a delete statement, the test data corresponding to the delete statement is inserted into the table structure corresponding to the delete statement in the new database, and then the delete operation is performed on the database based on the delete statement. If the database operation statement is a modification statement, inserting test data corresponding to the modification statement into a table structure corresponding to the modification statement in the new database, and then carrying out modification operation on the database based on the modification statement. If the database operation statement is a query statement, inserting test data corresponding to the query statement into a table structure corresponding to the query statement in the new database, and then carrying out query operation on the database based on the query statement.
Specifically, the data operation test method for the new database based on the test cases can be as follows: and if the data operation statement is an add statement, performing an add operation test on the new database based on the add statement.
Optionally, after the data manipulation test is performed on the new database based on the test cases, the method further comprises the following steps: acquiring a test case which does not pass the test; correcting the database operation sentences in the test cases which do not pass the test; and re-performing corresponding data operation test on the new database based on the corrected test cases.
Wherein, the test failure can be understood as that the database operation statement cannot execute the corresponding operation or fails to execute the operation on the new database. For an add statement, test failing may be understood as the add statement failing to perform the add data operation or add data failure on the new database; the add statement is revised and the data adding operation is performed again on the new database based on the revised add statement. For a delete statement, test failing may be interpreted as the delete statement failing to perform the operation of deleting data or failing to delete data on the new database; the delete statement is revised and the delete operation is performed again on the new database based on the revised delete statement. For a modification statement, the test does not pass or can be understood as that the modification statement cannot execute the operation of modifying the data on the new database or fails to modify the data; the modification statement is revised, and the data modification operation is carried out on the new database again based on the revised modification statement. For a query statement, a test failing may be understood as the query statement failing to perform an operation of querying data on a new database or failing to query data. The query statement is revised, and the operation of querying the data is carried out again on the new database based on the revised query statement.
Based on the above embodiment, fig. 3 is a flowchart of testing a new database after migration in the embodiment of the present application, and as shown in fig. 3, the method includes the following steps:
s310, acquiring a database operation file.
S320, checking the database operation file, displaying the database operation file which is not checked, and receiving the mark or modification of the database operation file which is not checked by the user.
S330, analyzing the database operation file to obtain a database operation sentence.
S340, obtaining the table field type corresponding to the database operation statement, generating test data based on the table field type, and generating a test case according to the database operation statement and the test data.
S350, performing data operation test on the new database based on the test cases.
S360, acquiring test cases which are not passed by the test, correcting database operation sentences in the test cases which are not passed by the test, and carrying out corresponding operation test on the new database again based on the corrected test cases.
Fig. 4 is a schematic structural diagram of a migration apparatus for a database according to an embodiment of the present application, as shown in fig. 4, where the apparatus includes:
an obtaining module 410, configured to obtain configuration information of a new database and a first table-building statement of an original database;
the table-building sentence conversion module 420 is configured to convert the first table-building sentence based on the configuration information to obtain a second table-building sentence of the new database;
the table structure creation module 430 is configured to create a table structure in the new database according to the second table creation statement, so as to perform migration of the table structure of the database.
Optionally, the obtaining module 410 is further configured to:
determining type information of a new database;
receiving configuration information input by a user based on type information; the configuration information comprises a database type name and a table construction grammar of a new database.
Optionally, the method further comprises: connectivity test module for:
acquiring first server address information of a new database and second server address information of an original database;
testing connectivity between the new database and the original database based on the first server address information and the second server address information;
correspondingly, the table-building sentence conversion module 420 is further configured to:
if the connectivity test between the new database and the original database is passed, converting the first table-building sentence based on the configuration information.
Optionally, the method further comprises: the table-building sentence verification module is used for:
checking the second list-building sentence to obtain a second list-building sentence which does not pass the checking;
displaying the second list-building sentence which is not checked;
and receiving the correction of the second table-building statement which is not passed by the verification by the user, and obtaining the corrected second table-building statement.
Optionally, the table-building sentence verification module is further configured to:
pre-building a table based on the second table building sentence;
and determining the second list building statement with failed or abnormal pre-built list as a second list building statement with failed verification.
Optionally, the method further comprises: the test module is used for:
acquiring a database operation statement; wherein the database operation statement comprises: adding sentences, deleting sentences, modifying sentences and inquiring sentences;
generating a test case based on the database operation statement; the test cases comprise database operation data and corresponding test data;
and performing data operation test on the new database based on the test cases.
Optionally, the test module is further configured to:
acquiring a database operation file;
and analyzing the database operation file to obtain a database operation statement.
Optionally, the test module is further configured to:
checking the database operation file, and displaying the database operation file which does not pass the checking;
and receiving marks or modifications of the database operation files which are not checked by the user.
Optionally, the test module is further configured to:
acquiring a table field type corresponding to a database operation statement;
generating test data based on the table field type;
and generating a test case according to the database operation statement and the test data.
Optionally, the test module is further configured to:
if the database operation statement is any one of a deletion statement, a modification statement and a query statement, inserting test data into a table structure corresponding to the database operation statement in the new database;
and carrying out corresponding data operation test on the new database based on the database operation statement.
Optionally, the test module is further configured to:
and if the data operation statement is an add statement, performing an add operation test on the new database based on the add statement.
Optionally, the test module is further configured to:
acquiring a test case which does not pass the test;
correcting the database operation sentences in the test cases which do not pass the test;
and re-performing corresponding data operation test on the new database based on the corrected test cases.
Fig. 5 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the application. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein.
As shown in fig. 5, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as a database migration method.
In some embodiments, the method of database migration may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the database migration method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the migration method of the database in any other suitable way (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present application, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
Embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, implements a method of migrating a database as provided by any of the embodiments of the present application.
Computer program product in the implementation, the computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present application and the technical principle applied. It will be understood by those skilled in the art that the present application 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 application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the application, which is set forth in the following claims.
Claims (16)
1. A method for migrating a database, comprising:
acquiring configuration information of a new database and a first table-building statement of an original database;
converting the first list-building sentence based on the configuration information to obtain a second list-building sentence of the new database;
and creating a table structure in the new database according to the second table creating sentence so as to migrate the table structure of the database.
2. The method of claim 1, wherein obtaining configuration information for a new database comprises:
determining type information of a new database;
receiving configuration information input by a user based on the type information; wherein the configuration information includes a database type name and a table building grammar of the new database.
3. The method of claim 1, further comprising, prior to converting the first list-building sentence based on the configuration information:
acquiring first server address information of the new database and second server address information of the original database;
testing connectivity between the new database and the original database based on the first server address information and the second server address information;
correspondingly, the converting the first table-building sentence based on the configuration information comprises the following steps:
and if the connectivity test between the new database and the original database is passed, converting the first list-building sentence based on the configuration information.
4. The method of claim 1, further comprising, prior to creating a table structure in the new database from the second table-building sentence:
checking the second list-building sentence to obtain a second list-building sentence which does not pass the checking;
displaying the second list-building sentence which is not checked;
and receiving the correction of the second table-building statement which is not passed by the verification by the user, and obtaining the corrected second table-building statement.
5. The method of claim 4, wherein verifying the second build sentence to obtain a second build sentence that does not pass the verification comprises:
pre-building a table based on the second table building sentence;
and determining the second list building statement with failed or abnormal pre-built list as a second list building statement with failed verification.
6. The method of claim 1, further comprising, after creating a table structure in the new database from the second table-building sentence:
acquiring a database operation statement; wherein the database operation statement includes: adding sentences, deleting sentences, modifying sentences and inquiring sentences;
generating a test case based on the database operation statement; the test cases comprise the database operation data and the corresponding test data;
and performing data operation test on the new database based on the test cases.
7. The method of claim 6, wherein retrieving database operation statements comprises:
acquiring a database operation file;
and analyzing the database operation file to obtain a database operation statement.
8. The method of claim 7, further comprising, prior to parsing the database operation file:
checking the database operation file, and displaying the database operation file which does not pass the checking;
and receiving marks or modifications of the database operation files which are not checked by the user.
9. The method of claim 6, wherein generating test cases based on the database operation statement comprises:
acquiring a table field type corresponding to the database operation statement;
generating test data based on the table field type;
and generating a test case according to the database operation statement and the test data.
10. The method of claim 6, wherein performing a data manipulation test on the new database based on the test cases comprises:
if the database operation statement is any one of a deletion statement, a modification statement and a query statement, inserting the test data into a table structure corresponding to the database operation statement in the new database;
and carrying out corresponding data operation test on the new database based on the database operation statement.
11. The method of claim 6, wherein performing a data manipulation test on the new database based on the test cases comprises:
and if the data operation statement is an add statement, performing an add operation test on the new database based on the add statement.
12. The method of claim 6, further comprising, after performing a data manipulation test on the new database based on the test cases:
acquiring a test case which does not pass the test;
correcting the database operation sentences in the test cases which do not pass the test;
and re-performing corresponding data operation test on the new database based on the corrected test cases.
13. A database migration apparatus, comprising:
the acquisition module is used for acquiring configuration information of the new database and a first table-building statement of the original database;
the table-building sentence conversion module is used for converting the first table-building sentence based on the configuration information to obtain a second table-building sentence of the new database;
and the table structure creation module is used for creating a table structure in the new database according to the second table creating sentence so as to migrate the table structure of the database.
14. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable by the processor, wherein the processor implements a method of migrating a database according to any of claims 1-12 when executing the computer program.
15. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when executed by a processor, implements a method of migrating a database according to any of claims 1-12.
16. A computer program product comprising a computer program which, when executed by a processor, implements the method of migrating a database according to any of claims 1-12.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310730284.9A CN116841982A (en) | 2023-06-19 | 2023-06-19 | Database migration method, device, equipment, storage medium and program product |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310730284.9A CN116841982A (en) | 2023-06-19 | 2023-06-19 | Database migration method, device, equipment, storage medium and program product |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116841982A true CN116841982A (en) | 2023-10-03 |
Family
ID=88171747
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310730284.9A Pending CN116841982A (en) | 2023-06-19 | 2023-06-19 | Database migration method, device, equipment, storage medium and program product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116841982A (en) |
-
2023
- 2023-06-19 CN CN202310730284.9A patent/CN116841982A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111309343A (en) | Development deployment method and device | |
US20230012642A1 (en) | Method and device for snapshotting metadata, and storage medium | |
CN116089258A (en) | Data migration test method, device, equipment, storage medium and program product | |
CN115455091A (en) | Data generation method and device, electronic equipment and storage medium | |
CN115617888A (en) | Data import method, device, equipment, storage medium and product | |
CN113127357B (en) | Unit test method, apparatus, device, storage medium, and program product | |
CN116302218B (en) | Function information adding method, device, equipment and storage medium | |
CN113220710A (en) | Data query method and device, electronic equipment and storage medium | |
CN116185389A (en) | Code generation method and device, electronic equipment and medium | |
CN116382640A (en) | Method, device, equipment and storage medium for managing micro-service | |
CN116414855A (en) | Information processing method and device, electronic equipment and computer readable storage medium | |
CN113901094B (en) | Data processing method, device, equipment and storage medium | |
CN116841982A (en) | Database migration method, device, equipment, storage medium and program product | |
CN114860753A (en) | SQL statement generation method, device, equipment, medium and product | |
CN118133794B (en) | Table configuration method, apparatus, device and storage medium | |
CN113760765B (en) | Code testing method and device, electronic equipment and storage medium | |
CN117634429A (en) | Statement conversion method, device, equipment and storage medium | |
CN118012897A (en) | Heterogeneous database grammar conversion method, device, equipment and storage medium | |
CN115238212A (en) | Page designated element detection and replacement method, device, equipment and storage medium | |
CN114443035A (en) | Code generation method for application program, code generator, electronic device, and medium | |
CN118277406A (en) | SQL sentence generation method and device based on large language model | |
CN114860312A (en) | Mobile terminal adaptation method, device, equipment and medium based on credit business | |
CN117609186A (en) | Database migration data comparison method, device, electronic equipment and storage medium | |
CN115981657A (en) | Code generation method and device, electronic equipment and readable medium | |
CN118535336A (en) | Task execution method, device, electronic 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 |