CN116860771A - Database updating method and system - Google Patents

Database updating method and system Download PDF

Info

Publication number
CN116860771A
CN116860771A CN202310972820.6A CN202310972820A CN116860771A CN 116860771 A CN116860771 A CN 116860771A CN 202310972820 A CN202310972820 A CN 202310972820A CN 116860771 A CN116860771 A CN 116860771A
Authority
CN
China
Prior art keywords
data
updated
database
text
original
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310972820.6A
Other languages
Chinese (zh)
Inventor
王晓虎
张劲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Geely Holding Group Co Ltd
Guangyu Mingdao Digital Technology Co Ltd
Original Assignee
Zhejiang Geely Holding Group Co Ltd
Guangyu Mingdao Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Geely Holding Group Co Ltd, Guangyu Mingdao Digital Technology Co Ltd filed Critical Zhejiang Geely Holding Group Co Ltd
Priority to CN202310972820.6A priority Critical patent/CN116860771A/en
Publication of CN116860771A publication Critical patent/CN116860771A/en
Pending legal-status Critical Current

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/23Updating
    • 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/245Query processing
    • G06F16/2455Query execution
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution

Landscapes

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

Abstract

The application relates to the technical field of data updating, and discloses a database updating method and a system, wherein the method is characterized in that the mapping relation between an original data text and a target data text is acquired, the original database is subjected to data query according to the original data text to obtain data to be updated with the original data text, the original data text of the data to be updated is replaced with the target data text through executing a database updating statement, so that the data to be updated is completed, the data to be updated is searched from the database through the text, and the text of the data to be updated is replaced, so that the updating of the data to be updated is completed, and compared with the arrangement of a database table and a table field needing to be updated, the arrangement time length of updating positions of the database table, the table field and the like before system updating is shortened, the data updating efficiency is improved, and the system updating efficiency of a service platform is improved.

Description

Database updating method and system
Technical Field
The present application relates to the field of data updating technologies, and in particular, to a database updating method and system.
Background
When the service platform is subjected to system upgrading, if an upgrading object is a functional interface, a data algorithm and the like of the service platform, the situation that the platform call data are incompatible can be caused by the upgrading content, and the data of the platform database is required to be updated or synchronized according to the upgrading content before upgrading. In general, before data update, a database table, a table field and the like to be updated need to be arranged, the arranged database table, table field and the like are used as data update targets to form an update script, and then the platform database is updated and synchronized through the update script.
However, under the conditions that the data volume of the service platform is large and the service platform is cross, a large amount of labor cost such as manpower and time is required for arranging specific data updating targets such as database tables and table fields, so that the preparation time for data updating is long, the data updating efficiency is low, the system updating efficiency of the service platform is low, and the timeliness requirement of system updating cannot be met.
Disclosure of Invention
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed embodiments. This summary is not an extensive overview, and is intended to neither identify key/critical elements nor delineate the scope of such embodiments, but is intended as a prelude to the more detailed description that follows.
In view of the above drawbacks of the prior art, the present application discloses a database updating method and system, so as to improve the data updating efficiency before system upgrade.
The application provides a database updating method, which comprises the following steps: obtaining an update mapping table corresponding to an original database, wherein the update mapping table comprises a mapping relation between an original data text and a target data text; taking the original data text as a query variable to perform data query on the original database to obtain data to be updated with the original data text; and generating a database update statement by taking the target data text and the data to be updated as update variables, and replacing the original data text of the data to be updated with the target data text by executing the database update statement so as to update the data to be updated.
Optionally, performing data query on the original database by using the original data text as a query variable to obtain data to be updated with the original data text, including: presetting a temporary data table; taking the original data text as a query variable, and traversing and querying the original database by utilizing a cursor mode to obtain a query record; and determining data to be updated with the original data text from the original database according to the query record, and adding the data to be updated into the temporary data table.
Optionally, after adding the data to be updated in the temporary data table, before generating a database update statement with the target data text and the data to be updated as update variables, the method further includes: generating a database query statement according to the data to be updated in the temporary data table; the database query statement is sent to a preset user terminal, so that a user queries the temporary data table through the database query statement of the user terminal; and if a user selection instruction corresponding to the data to be updated is received from the user terminal, updating the data to be updated according to the user selection instruction.
Optionally, replacing the original data text of the data to be updated with the target data text by the following method: presetting a target data type and a default data text of the original data text; acquiring the current data type of the original data text; if the current data type belongs to the target data type, replacing the original data text of the data to be updated with the target data text; and if the current data type does not belong to the target data type, replacing the original data text of the data to be updated with a default data text.
Optionally, the method further comprises: acquiring a database table in which the data to be updated are located; if the table data volume of the database table is greater than or equal to the preset data volume, generating a main thread and an asynchronous thread, wherein the main thread is used for managing the database table, and the asynchronous thread is used for updating the data to be updated in the database table according to the target data text; and if the execution of the asynchronous thread is completed, determining an updating result corresponding to the data to be updated as the completion of data updating.
Optionally, the method further comprises: if the number of the original data texts is multiple, distributing the value weight corresponding to each original data text; respectively establishing updating threads corresponding to the original data texts so as to simultaneously update the data to be updated corresponding to the original data texts into target data texts corresponding to the original data texts through the updating threads; if any data to be updated comprises a plurality of original data texts, sequentially executing the updating threads corresponding to the data to be updated according to the value weights, so as to sequentially replace each original data text in the data to be updated with the target data text.
Optionally, obtaining an update mapping table corresponding to the original database includes: acquiring an associated data set of an original database, wherein the associated data set comprises an original data text and associated data corresponding to the original data text; according to the associated data, carrying out data synchronization on a preset target database, so that the target database feeds back a target data text corresponding to the original data text after synchronizing the associated data; and establishing a mapping relation between the original data text and the target data text to obtain an updated mapping table.
Optionally, performing data synchronization on a preset target database according to the association data includes: the associated data comprise identification data and data to be synchronized; performing data query on the target database according to the identification data to obtain a query result; if the query result is that the query result exists, updating the queried database data into the data to be synchronized, so that the target database generates a target data text according to the updated data to be synchronized; and if the query result is not present, synchronizing the data to be synchronized to the target database, so that the target database generates a target data text according to the synchronized data to be synchronized.
Optionally, the method further comprises: and replacing the original data text of the data to be updated with the target data text by executing the database update statement, and then carrying out data synchronization again on a preset target database according to the updated data to be updated.
The application provides a database updating system, which comprises: the acquisition module is used for acquiring an update mapping table corresponding to the original database, wherein the update mapping table comprises a mapping relation between an original data text and a target data text; the query module is used for carrying out data query on the original database by taking the original data text as a query variable to obtain data to be updated with the original data text; and the updating module is used for generating a database updating statement by taking the target data text and the data to be updated as updating variables, and replacing the original data text of the data to be updated with the target data text by executing the database updating statement so as to update the data to be updated.
The application has the beneficial effects that:
and obtaining data to be updated with the original data text by acquiring a mapping relation between the original data text and the target data text, carrying out data query on the original database according to the original data text, and replacing the original data text of the data to be updated with the target data text by executing a database update statement, thereby completing the data to be updated. In this way, the data to be updated is searched from the database through the text, and the text of the data to be updated is replaced to finish the update of the data to be updated, so that compared with the arrangement of the database table and the table field which need to be updated, the arrangement time of updating positions such as the database table and the table field before the system is updated is shortened, the data updating efficiency is improved, and the system updating efficiency of the service platform is improved.
Drawings
FIG. 1 is a schematic diagram of an application environment for implementing a database update method according to an embodiment of the present application;
FIG. 2 is a flowchart of a database update method according to an embodiment of the present application;
FIG. 3 is a flowchart of a method for obtaining an update map according to an embodiment of the present application;
FIG. 4 is a flowchart of another database updating method according to an embodiment of the present application;
FIG. 5 is a flowchart of another database updating method according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a database update system according to an embodiment of the present application.
Detailed Description
Other advantages and effects of the present application will become apparent to those skilled in the art from the following disclosure, which describes the embodiments of the present application with reference to specific examples. The application may be practiced or carried out in other embodiments that depart from the specific details, and the details of the present description may be modified or varied from the spirit and scope of the present application. It should be noted that, without conflict, the following embodiments and sub-samples in the embodiments may be combined with each other.
It should be noted that the illustrations provided in the following embodiments merely illustrate the basic concept of the present application by way of illustration, and only the components related to the present application are shown in the drawings and are not drawn according to the number, shape and size of the components in actual implementation, and the form, number and proportion of the components in actual implementation may be arbitrarily changed, and the layout of the components may be more complicated.
In the following description, numerous details are set forth in order to provide a more thorough explanation of embodiments of the present application, it will be apparent, however, to one skilled in the art that embodiments of the present application may be practiced without these specific details, in other embodiments, well-known structures and devices are shown in block diagram form, rather than in detail, in order to avoid obscuring the embodiments of the present application.
The terms first, second and the like in the description and in the claims of the embodiments of the disclosure and in the above-described figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe embodiments of the present disclosure. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion.
The term "plurality" means two or more, unless otherwise indicated.
In the embodiment of the present disclosure, the character "/" indicates that the front and rear objects are an or relationship. For example, A/B represents: a or B.
The term "and/or" is an associative relationship that describes an object, meaning that there may be three relationships. For example, a and/or B, represent: a or B, or, A and B.
Before describing embodiments of the present application in further detail, the terms and terminology involved in the embodiments of the present application will be described, and the terms and terminology involved in the embodiments of the present application will be used in the following explanation.
The data updating is that the data table is an important object of the database and is a basic unit for storing data, new data is inserted into the table after the table structure is established, and the existing data is modified and deleted, so that the data updating can be realized by using two modes of an object resource manager and a T-SQL statement. That is, the data update is performed by deleting, modifying and reinserting the new data item or record, and replacing the old data item or record corresponding to the new data item or record in the data file or database.
SQL (Structured Query Language ), a special purpose programming language, is a database query and programming language used to access data and query, update and manage relational database systems. The structured query language is a high-level, non-procedural programming language that allows users to work on high-level data structures. The method does not require the user to specify a data storage method or the user to know a specific data storage mode, so that different database systems with completely different substructures can use the same structured query language as an interface for data input and management. The structured query language statement can be nested, which gives it great flexibility and powerful functionality.
A cursor is a pointer to a particular row in the database query result. The pointer can be moved from one line to the next and, depending on the type of cursor, also to the previous line. In colloquial terms, the SQL result resembles a bag, holding multiple database rows, but not any row alone; and the cursor, like a pair of tweezers, grabs a particular row of the database in the package and then moves on to the next row.
Referring to fig. 1, an embodiment of the disclosure provides an application environment for implementing a database updating method, which includes a client and a server, wherein the client communicates with the server through a network. The server may receive a user instruction via the client, the user instruction including at least a portion of: acquiring an update mapping table corresponding to an original database, wherein the update mapping table comprises a mapping relation between an original data text and a target data text; taking the original data text as a query variable to perform data query on the original database to obtain data to be updated with the original data text; and generating a database update statement by taking the target data text and the data to be updated as update variables, and replacing the original data text of the data to be updated with the target data text by executing the database update statement so as to update the data to be updated.
Referring to fig. 2, an embodiment of the present disclosure provides a database updating method, including:
step S201, an update mapping table corresponding to an original database is obtained;
wherein the updated mapping table includes a mapping relationship between the original data text and the target data text.
In some embodiments, the service platform a is connected to the service platform B, and needs to perform system upgrade on the service platform a, so that the service platform a uses services provided by the service platform B, where the service platform a generates a large amount of service data such as user information, account information, tenant information, department information, employee information and the like in an own platform system, and stores the service data in a database of the service platform a according to a first ID (Identity document, an identification number, an account number, a unique code, a proprietary number, an industrial design, a national abbreviation, legal vocabulary, a general account, a decoder, abbreviations of various proprietary vocabularies of software companies and the like); the service platform A synchronizes the service data to the service platform B, so that the service platform B generates a second ID corresponding to each service data when synchronizing the service data of the service platform A; when the service platform A acquires the second ID fed back by the service platform B, the service platform A needs to update the first ID of the service platform A by taking the second ID of the service platform B as a standard; if the upgrade script is established, the data update targets such as the database, the database table, the database field, the field type and the like where the first ID is located need to be arranged, the arrangement difficulty is high, a large amount of labor cost such as manpower and time is required, and meanwhile, the data full coverage cannot be ensured.
In some embodiments, the updated mapping table includes not only mapping relationships in the form of text, but also mapping relationships in the form of field values, data values, and the like.
Referring to fig. 3, obtaining an update mapping table corresponding to an original database includes:
step S301, obtaining an associated data set of an original database;
the associated data set comprises an original data text and associated data corresponding to the original data text;
the associated data comprise identification data and data to be synchronized;
step S302, carrying out data synchronization on a preset target database according to the associated data, so that the target database feeds back a target data text corresponding to the original data text after synchronizing the associated data;
step S303, a mapping relation between the original data text and the target data text is established, and an updated mapping table is obtained.
Optionally, before performing data synchronization on a preset target database according to the associated data, performing data verification on the associated data, and performing data repair according to a data verification result, where the data verification includes whether the data is empty, whether the data is repeated, whether the data is missing, and the like.
Referring to fig. 3, performing data synchronization on a preset target database according to the associated data includes:
step S3021, carrying out data query on a target database according to the identification data to obtain a query result;
step S3022, if the query result is present, updating the queried database data to be synchronized data, so that the target database generates a target data text according to the updated to-be-synchronized data;
in step S3023, if the query result is not present, the data to be synchronized is synchronized to the target database, so that the target database generates a target data text according to the synchronized data to be synchronized.
In some embodiments, the first ID of the service platform a is used as an original data text, the second ID of the service platform B is used as a target data text, and a mapping relationship between the first ID and the second ID is established to obtain an updated mapping table.
In some embodiments, querying employee information of the service platform a and a first ID corresponding to the employee information, wherein the employee information is used as associated data, and the first ID corresponding to the employee information is used as an original data text; carrying out data assembly according to the associated data to obtain data to be synchronized compatible with the service platform B, wherein the data to be synchronized comprises employee account numbers, departments where employees are located, employee part-time departments, employee sexes, employee work numbers, employee login passwords and the like; taking the employee account with uniqueness as identification data, and inquiring a database of the service platform B according to the identification data to obtain an inquiry result; if the employee account number exists in the database of the service platform B, updating the employee information in the service platform B according to the employee information corresponding to the employee account number in the service platform A, and receiving a second ID fed back by the service platform B after the updating is successful; if the employee account number does not exist in the database of the service platform B, the employee information corresponding to the employee account number in the service platform A is added into the database of the service platform B, and a second ID fed back by the service platform B is received after the addition is successful; and taking the second ID of the service platform B as a target data text, and establishing a mapping relation between the first ID and the second ID to obtain an updated mapping table.
In some embodiments, according to the method for generating the update mapping table of the ID corresponding to employee information, an update mapping table of the ID corresponding to service data such as user information, account information, tenant information, department information, etc. is obtained.
In some embodiments, since the service platform a uses the mobile phone number as the employee account number, and the service platform B does not support using the mobile phone number as the employee account number, after receiving the query failure information of the service platform B, the identification data is modified into other arbitrary data, and then the data query and the data synchronization are performed again.
Optionally, the method further comprises: and replacing the original data text of the data to be updated with the target data text by executing the database update statement, and then carrying out data synchronization on the preset target database again according to the updated data to be updated.
In some embodiments, in the database of the service platform B, the list of the upper limit information of the staff a is staff B, and meanwhile, after the staff information of the staff a is updated, the staff information of the staff B is updated again, and after the staff information of the staff B is updated, the staff information of the staff a is updated again according to the staff information of the staff B.
Step S202, carrying out data query on an original database by taking the original data text as a query variable to obtain data to be updated with the original data text.
Optionally, performing data query on the original database by using the original data text as a query variable to obtain data to be updated with the original data text, including: presetting a temporary data table; taking the original data text as a query variable, traversing and querying the original database by utilizing a cursor mode to obtain a query record; and determining data to be updated with the original data text from the original database according to the query record, and adding the data to be updated into the temporary data table.
Optionally, after adding the data to be updated in the temporary data table, before generating the database update statement with the target data text and the data to be updated as the update variables, the method further includes: generating a database query statement according to the data to be updated in the temporary data table; the method comprises the steps of sending a database query statement to a preset user terminal, so that a user queries data of a temporary data table through the database query statement of the user terminal; if a user selection instruction corresponding to the data to be updated is received from the user terminal, the data to be updated is updated according to the user selection instruction.
In some embodiments, an SQL query statement is generated according to the data to be updated in the temporary data table and sent to the user terminal, so that the user can conveniently query and select the data to be updated through the generated SQL query statement, and the final data to be updated is confirmed according to a user selection instruction.
In step S203, a database update statement is generated using the target data text and the data to be updated as update variables, and the original data text of the data to be updated is replaced with the target data text by executing the database update statement to update the data to be updated.
In some embodiments, a mapping relationship between a first ID of service platform a (e.g., "100314782"), a second ID of service platform B (e.g., "23562") is obtained; then the update of the first ID in service platform a is completed by executing the SQL statement (call 'auto_replace', 'database', '100314782', '23562') and replacing "100314782" in the service platform a database with "23562".
Optionally, the original data text of the data to be updated is replaced with the target data text by the following method: presetting a target data type and a default data text of an original data text; acquiring the current data type of an original data text; if the current data type belongs to the target data type, replacing the original data text of the data to be updated with the target data text; and if the current data type does not belong to the target data type, replacing the original data text of the data to be updated with the default data text.
Optionally, the method further comprises: presetting an exception handling rule; after updating the data to be updated, generating a data updating result; if the data updating result is abnormal updating, the data updating result is fed back to the user, and a preset abnormal processing rule is executed.
Optionally, the method further comprises: acquiring a database table in which data to be updated are located; if the table data volume of the database table is greater than or equal to the preset data volume, generating a main thread and an asynchronous thread, wherein the main thread is used for managing the database table, and the asynchronous thread is used for updating the data to be updated in the database table according to the target data text; if the execution of the asynchronous thread is completed, determining an updating result corresponding to the data to be updated as the data updating completion.
In some embodiments, if the data volume of a database table, such as an information history table, is large, the database table is updated asynchronously by using a thread, and after the execution of the main line is completed, an asynchronous thread is executed; and after the asynchronous thread execution is completed, determining that the data update is complete.
Therefore, the data synchronization of the database is ensured by using a thread asynchronous mode, the thread execution congestion is avoided, and the data updating efficiency is improved.
Optionally, the method further comprises: if the number of the original data texts is multiple, distributing the value weight corresponding to each original data text; respectively establishing updating threads corresponding to the original data texts so as to simultaneously update the data to be updated corresponding to the original data texts into target data texts corresponding to the original data texts through the updating threads; if any data to be updated comprises a plurality of original data texts, sequentially executing the update threads corresponding to the data to be updated according to the value weights, so as to sequentially replace each original data text in the data to be updated with the target data text.
In some embodiments, if the upper driver of the employee C is the employee D, the employee information of the employee C includes two data to be updated, namely an employee number of the employee C and an employee number of the employee D, and update threads corresponding to the two employee numbers are respectively established; and if the update weight of the person is preset to be larger than the update weight of the last department, the update thread corresponding to the employee D updates the data of the employee D after the update thread corresponding to the employee C is completed.
Thus, by establishing a plurality of text updating threads to respectively finish updating different data, when a plurality of texts exist in one data to be updated, the data updating is sequentially executed according to the value weight, and the data updating error is avoided while the data updating efficiency is ensured.
By adopting the database updating method provided by the embodiment of the disclosure, the original database is subjected to data query according to the original data text by acquiring the mapping relation between the original data text and the target data text, the data to be updated with the original data text is obtained, and the original data text of the data to be updated is replaced by the target data text by executing the database updating statement, so that the data to be updated is completed, and the method has the following advantages:
firstly, searching data to be updated from a database through texts, and replacing the texts of the data to be updated to finish updating the data to be updated, so that compared with the arrangement of database tables and table fields needing to be updated, the arrangement time of updating positions of the database tables, the table fields and the like before system updating is shortened, the data updating efficiency is improved, and the system updating efficiency of a service platform is improved;
secondly, the data synchronization of the database is ensured by using a thread asynchronous mode, the thread execution congestion is avoided, and the data updating efficiency is improved;
thirdly, updating different data is respectively completed by establishing a plurality of text updating threads, and when a plurality of texts exist in one data to be updated and need to be updated, the data updating is sequentially executed according to the value weight, so that the data updating efficiency is ensured, and meanwhile, the data updating error is avoided.
Referring to fig. 4, an embodiment of the present disclosure provides a database updating method, including:
step S401, an update mapping table corresponding to an original database is obtained;
the updating mapping table comprises a mapping relation between an original data text and a target data text;
step S402, declaring variables according to the original database and the updated mapping table;
taking the original data text as a query variable;
taking the target data text as an update variable;
step S403, declaring a cursor, and inquiring the original database by utilizing a cursor mode to obtain an inquiry record;
step S404, determining data to be updated with original data text from an original database according to the query record, and adding the data to be updated into a temporary data table;
step S405, generating SQL update sentences according to the data to be updated in the temporary data table;
step S406, executing SQL update statement, and replacing the original data text of the data to be updated with the target data text to update the data to be updated.
By adopting the database updating method provided by the embodiment of the disclosure, the original database is subjected to data query according to the original data text by acquiring the mapping relation between the original data text and the target data text, the data to be updated with the original data text is obtained, and the original data text of the data to be updated is replaced by the target data text by executing the database updating statement, so that the data to be updated is completed. In this way, the data to be updated is searched from the database through the text, and the text of the data to be updated is replaced to finish the update of the data to be updated, so that compared with the arrangement of the database table and the table field which need to be updated, the arrangement time of updating positions such as the database table and the table field before the system is updated is shortened, the data updating efficiency is improved, and the system updating efficiency of the service platform is improved.
Referring to fig. 5, an embodiment of the present disclosure provides a database updating method, including:
step S501, a temporary data table is obtained;
wherein the temporary data table stores data to be updated;
step S502, judging whether unprocessed data to be updated exists in the temporary data table, if yes, jumping to step S503, and if not, jumping to step S507;
step S503, extracting unprocessed data to be updated from the temporary data table;
step S504, generating SQL update sentences according to the extracted data to be updated;
step S505, executing SQL update statement, replacing the original data text of the data to be updated with the target data text to update the data to be updated, and skipping steps S502 and S506 respectively;
step S506, the updated data to be updated is synchronized.
In step S507, the data update is completed.
By adopting the database updating method provided by the embodiment of the disclosure, the original database is subjected to data query according to the original data text by acquiring the mapping relation between the original data text and the target data text, the data to be updated with the original data text is obtained, and the original data text of the data to be updated is replaced by the target data text by executing the database updating statement, so that the data to be updated is completed. In this way, the data to be updated is searched from the database through the text, and the text of the data to be updated is replaced to finish the update of the data to be updated, so that compared with the arrangement of the database table and the table field which need to be updated, the arrangement time of updating positions such as the database table and the table field before the system is updated is shortened, the data updating efficiency is improved, and the system updating efficiency of the service platform is improved.
As shown in fig. 6, an embodiment of the present disclosure provides a database update system, which includes an acquisition module 601, a query module 602, and an update module 603.
The obtaining module 601 is configured to obtain an update mapping table corresponding to the original database, where the update mapping table includes a mapping relationship between an original data text and a target data text.
The query module 602 is configured to perform a data query on the original database using the original data text as a query variable, so as to obtain data to be updated with the original data text.
The updating module 603 is configured to generate a database updating sentence with the target data text and the data to be updated as updating variables, and replace the original data text of the data to be updated with the target data text by executing the database updating sentence, so as to update the data to be updated.
By adopting the database updating system provided by the embodiment of the disclosure, the original database is subjected to data query according to the original data text by acquiring the mapping relation between the original data text and the target data text, the data to be updated with the original data text is obtained, and the original data text of the data to be updated is replaced by the target data text by executing the database updating statement, so that the data to be updated is completed. In this way, the data to be updated is searched from the database through the text, and the text of the data to be updated is replaced to finish the update of the data to be updated, so that compared with the arrangement of the database table and the table field which need to be updated, the arrangement time of updating positions such as the database table and the table field before the system is updated is shortened, the data updating efficiency is improved, and the system updating efficiency of the service platform is improved.
The above description and the drawings illustrate embodiments of the disclosure sufficiently to enable those skilled in the art to practice them. Other embodiments may involve structural, logical, electrical, process, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the sequence of operations may vary. Portions and sub-samples of some embodiments may be included in or substituted for portions and sub-samples of other embodiments. Moreover, the terminology used in the present application is for the purpose of describing embodiments only and is not intended to limit the claims. As used in the description of the embodiments and the claims, the singular forms "a," "an," and "the" (the) are intended to include the plural forms as well, unless the context clearly indicates otherwise. Similarly, the term "and/or" as used in this disclosure is meant to encompass any and all possible combinations of one or more of the associated listed. In addition, when used in this disclosure, the terms "comprises," "comprising," and/or variations thereof mean the presence of the stated sub-sample, integer, step, operation, element, and/or component, but do not exclude the presence or addition of one or more other sub-samples, integers, steps, operations, elements, components, and/or groups of these. Without further limitation, an element defined by the phrase "comprising one …" does not exclude the presence of other like elements in a process, method or apparatus comprising such elements. In this context, each embodiment may be described with emphasis on the differences from the other embodiments, and the same similar parts between the various embodiments may be referred to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method sections disclosed in the embodiments, the description of the method sections may be referred to for relevance.
Those of skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. The skilled person may use different methods for each particular application to achieve the described functionality, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again.
In the embodiments disclosed herein, the disclosed methods, articles of manufacture (including but not limited to devices, apparatuses, etc.) may be practiced in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of elements may be merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some sub-samples may be omitted, or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form. The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to implement the present embodiment. In addition, each functional unit in the embodiments of the present disclosure may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to embodiments of the present disclosure. 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). 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. In the description corresponding to the flowcharts and block diagrams in the figures, operations or steps corresponding to different blocks may also occur in different orders than that disclosed in the description, and sometimes no specific order exists between different operations or steps. For example, two consecutive operations or steps may actually be performed substantially in parallel, they may sometimes be performed in reverse order, which may be dependent on the functions involved. Each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/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.

Claims (10)

1. A method of updating a database, comprising:
obtaining an update mapping table corresponding to an original database, wherein the update mapping table comprises a mapping relation between an original data text and a target data text;
taking the original data text as a query variable to perform data query on the original database to obtain data to be updated with the original data text;
and generating a database update statement by taking the target data text and the data to be updated as update variables, and replacing the original data text of the data to be updated with the target data text by executing the database update statement so as to update the data to be updated.
2. The method according to claim 1, wherein performing data query on the original database using the original data text as a query variable to obtain data to be updated having the original data text, comprises:
presetting a temporary data table;
taking the original data text as a query variable, and traversing and querying the original database by utilizing a cursor mode to obtain a query record;
and determining data to be updated with the original data text from the original database according to the query record, and adding the data to be updated into the temporary data table.
3. The method of claim 2, wherein after adding the data to be updated in the temporary data table, before generating a database update statement with the target data text and the data to be updated as update variables, the method further comprises:
generating a database query statement according to the data to be updated in the temporary data table;
the database query statement is sent to a preset user terminal, so that a user queries the temporary data table through the database query statement of the user terminal;
and if a user selection instruction corresponding to the data to be updated is received from the user terminal, updating the data to be updated according to the user selection instruction.
4. The method according to claim 1, characterized in that the original data text of the data to be updated is replaced by the target data text by:
presetting a target data type and a default data text of the original data text;
acquiring the current data type of the original data text;
if the current data type belongs to the target data type, replacing the original data text of the data to be updated with the target data text;
and if the current data type does not belong to the target data type, replacing the original data text of the data to be updated with a default data text.
5. The method according to claim 1, wherein the method further comprises:
acquiring a database table in which the data to be updated are located;
if the table data volume of the database table is greater than or equal to the preset data volume, generating a main thread and an asynchronous thread, wherein the main thread is used for managing the database table, and the asynchronous thread is used for updating the data to be updated in the database table according to the target data text;
and if the execution of the asynchronous thread is completed, determining an updating result corresponding to the data to be updated as the completion of data updating.
6. The method according to claim 1, wherein the method further comprises:
if the number of the original data texts is multiple, distributing the value weight corresponding to each original data text;
respectively establishing updating threads corresponding to the original data texts so as to simultaneously update the data to be updated corresponding to the original data texts into target data texts corresponding to the original data texts through the updating threads;
if any data to be updated comprises a plurality of original data texts, sequentially executing the updating threads corresponding to the data to be updated according to the value weights, so as to sequentially replace each original data text in the data to be updated with the target data text.
7. The method according to any one of claims 1 to 6, wherein obtaining an update mapping table corresponding to the original database includes:
acquiring an associated data set of an original database, wherein the associated data set comprises an original data text and associated data corresponding to the original data text;
according to the associated data, carrying out data synchronization on a preset target database, so that the target database feeds back a target data text corresponding to the original data text after synchronizing the associated data;
and establishing a mapping relation between the original data text and the target data text to obtain an updated mapping table.
8. The method of claim 7, wherein synchronizing data of a preset target database based on the association data comprises:
the associated data comprise identification data and data to be synchronized;
performing data query on the target database according to the identification data to obtain a query result;
if the query result is that the query result exists, updating the queried database data into the data to be synchronized, so that the target database generates a target data text according to the updated data to be synchronized;
and if the query result is not present, synchronizing the data to be synchronized to the target database, so that the target database generates a target data text according to the synchronized data to be synchronized.
9. The method of claim 7, wherein the method further comprises:
and replacing the original data text of the data to be updated with the target data text by executing the database update statement, and then carrying out data synchronization again on a preset target database according to the updated data to be updated.
10. A database updating system, comprising:
the acquisition module is used for acquiring an update mapping table corresponding to the original database, wherein the update mapping table comprises a mapping relation between an original data text and a target data text;
the query module is used for carrying out data query on the original database by taking the original data text as a query variable to obtain data to be updated with the original data text;
and the updating module is used for generating a database updating statement by taking the target data text and the data to be updated as updating variables, and replacing the original data text of the data to be updated with the target data text by executing the database updating statement so as to update the data to be updated.
CN202310972820.6A 2023-08-03 2023-08-03 Database updating method and system Pending CN116860771A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310972820.6A CN116860771A (en) 2023-08-03 2023-08-03 Database updating method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310972820.6A CN116860771A (en) 2023-08-03 2023-08-03 Database updating method and system

Publications (1)

Publication Number Publication Date
CN116860771A true CN116860771A (en) 2023-10-10

Family

ID=88221725

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310972820.6A Pending CN116860771A (en) 2023-08-03 2023-08-03 Database updating method and system

Country Status (1)

Country Link
CN (1) CN116860771A (en)

Similar Documents

Publication Publication Date Title
US8140495B2 (en) Asynchronous database index maintenance
US7539669B2 (en) Methods and systems for providing guided navigation
CN106407360B (en) Data processing method and device
US8620946B2 (en) Storage and searching of temporal entity information
CN106886371B (en) Caching data processing method and device
CN102236672A (en) Method and device for importing data
CN108415998B (en) Application dependency relationship updating method, terminal, device and storage medium
US20140115066A1 (en) Systems and Methods for Creating and Displaying an Electronic Communication Digest
CN109408507B (en) Multi-attribute data processing method, device, equipment and readable storage medium
CN112699151B (en) Data processing method, device, equipment and medium
US20080281792A1 (en) Conversion of data from a first file type to a second file type for use by a telecommunications equipment inventory system
CN110781183A (en) Method and device for processing incremental data in Hive database and computer equipment
CN113760948A (en) Data query method and device
US20100070460A1 (en) System and method for rule-based data object matching
CN111782235A (en) Data upgrading and querying method and device
KR20200094074A (en) Method, apparatus, device and storage medium for managing index
CN110109981B (en) Information display method and device for work queue, computer equipment and storage medium
CN115470191A (en) Database updating system, method and corresponding computer equipment and storage medium
US20040078361A1 (en) System and method for analyzing patent families
CN113377876B (en) Data database processing method, device and platform based on Domino platform
EP2506540B1 (en) Enhanced contact information
US11914612B2 (en) Selective synchronization of linked records
US9619458B2 (en) System and method for phrase matching with arbitrary text
EP2135161B1 (en) Management of data for installation on a remote device
CN116860771A (en) Database updating method 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