CN107656940B - Database processing method and device - Google Patents

Database processing method and device Download PDF

Info

Publication number
CN107656940B
CN107656940B CN201610597808.1A CN201610597808A CN107656940B CN 107656940 B CN107656940 B CN 107656940B CN 201610597808 A CN201610597808 A CN 201610597808A CN 107656940 B CN107656940 B CN 107656940B
Authority
CN
China
Prior art keywords
database
character set
information
databases
list
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610597808.1A
Other languages
Chinese (zh)
Other versions
CN107656940A (en
Inventor
赵春猛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201610597808.1A priority Critical patent/CN107656940B/en
Publication of CN107656940A publication Critical patent/CN107656940A/en
Application granted granted Critical
Publication of CN107656940B publication Critical patent/CN107656940B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • 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

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)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database processing method and device. Wherein, the method comprises the following steps: obtaining a first database listing, wherein the first database listing comprises: at least one first database, wherein the first database is a database in which a character set has errors and stored data is correct; creating at least one second database, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database is in one-to-one correspondence with the at least one first database; and synchronizing the data stored in each first database into the corresponding second database. The invention solves the technical problems of complicated process and easy error caused by adopting a method for modifying the character set of the database one by one in the prior art.

Description

Database processing method and device
Technical Field
The invention relates to the technical field of databases, in particular to a database processing method and device.
Background
In the operation and maintenance process of the SQL Server (SQL Server is a relational database management system introduced by Microsoft corporation), a template library is usually used to generate a special database for Profile (user configuration file), if the special database for Profile is generated by the template library using an error character set and is not found in time, when a large amount of production data is accumulated in the database, a method of modifying the character set of the database (including a table) one by one is very labor-consuming and easy to make an error.
In the prior art, the database can be modified one by one through an SSMS (SQL Server Management Studio, SQL Server Management platform), which includes a method of each table in which a character set is referenced, but when there are many databases on a Server and the table structure of the database is complicated, the operation requires a large number of mouse click actions, which is quite cumbersome and prone to errors.
Aiming at the technical problems that the process is complicated and mistakes are easy to make by adopting a method for modifying the character set of the database one by one in the prior art, an effective solution is not provided at present.
Disclosure of Invention
The embodiment of the invention provides a database processing method and device, and aims to at least solve the technical problems that in the prior art, the process is complicated and errors are easy to occur due to the adoption of a method for modifying character sets of a database one by one.
According to an aspect of an embodiment of the present invention, there is provided a database processing method, including: obtaining a first database listing, wherein the first database listing comprises: at least one first database, wherein the first database is a database in which a character set has errors and stored data is correct; creating at least one second database, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database is in one-to-one correspondence with the at least one first database; and synchronizing the data stored in each first database into the corresponding second database.
Further, obtaining the first database listing includes: executing the storage process of the database to obtain a database information list of a plurality of databases, wherein the database information list at least comprises: character set information; importing database information lists of a plurality of databases into a database table; and filtering the database table by using the character set field to obtain a first database list.
Further, after the database information list of the plurality of databases is obtained by performing the storage process of the database, the method further includes: splitting the database information lists of the multiple databases to obtain the split database information lists of the multiple databases; extracting and processing database information lists of the plurality of split databases to obtain character set information of each database; and importing the character set information of each database into the database table.
Further, filtering the database table using the character set field to obtain a first database list comprises: matching the character set information of each database with preset character set information; and if the character set information of any one database does not match with the preset character set information, determining any one database as a first database.
Further, creating at least one second database comprises: and generating at least one blank database by using the template library with the correct character set to obtain at least one second database.
Further, synchronizing the data stored in each first database into a corresponding second database includes: and simultaneously synchronizing the data stored in at least one first database into a corresponding second database by using a data synchronization tool or a database statement.
According to another aspect of the embodiments of the present invention, there is also provided a database processing apparatus, including: an obtaining module, configured to obtain a first database list, where the first database list includes: at least one first database, wherein the first database is a database in which a character set has errors and stored data is correct; the creating module is used for creating at least one second database, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database is in one-to-one correspondence with the at least one first database; and the synchronization module is used for synchronizing the data stored in each first database into the corresponding second database.
Further, the acquisition module includes: the acquisition module comprises: the first processing submodule is used for executing a storage process of a database to obtain a database information list of a plurality of databases, wherein the database information at least comprises: character set information; the import submodule is used for importing the database information lists of the plurality of databases into the database table; and the second processing submodule is used for filtering the database table by using the character set field to obtain a first database list.
Further, the creating module includes: and the generating submodule is used for generating at least one blank database by using the template library with the correct character set to obtain at least one second database.
Further, the synchronization module includes: and the second synchronization sub-module is used for synchronizing the data stored in at least one first database into the corresponding second database at the same time by using the data synchronization tool or the database statements.
In the embodiment of the present invention, acquiring a first database list is adopted, where the first database list includes: at least one first database, wherein the first database is a database in which a character set has errors and stored data is correct; creating at least one second database, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database is in one-to-one correspondence with the at least one first database; the data stored in each first database is synchronized to the corresponding second database, and the purpose of modifying the character set of the SQL Server database in batches is achieved, so that the technical problems that the process is complicated and errors are easy to occur due to the adoption of a method for modifying the character set of the database one by one in the prior art are solved, and the effect of quickly and accurately modifying the character set of the database is achieved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart of a method of processing a database according to an embodiment of the invention;
FIG. 2 is a flow diagram of a method of obtaining a first database listing according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a database information list of a plurality of databases obtained in a database storage process according to an embodiment of the present invention;
FIG. 4 is a flow diagram of another method of obtaining a first database listing in accordance with an embodiment of the present invention;
FIG. 5 is a flow diagram of a method of obtaining a first database listing according to an embodiment of the present invention;
FIG. 6 is a flow diagram of a method of creating at least one second database in accordance with an embodiment of the present invention;
FIG. 7 is a schematic diagram of an alternative method for synchronizing data stored in each first database to a corresponding second database using a data synchronization tool according to an embodiment of the invention;
FIG. 8 is a flow diagram of a method of synchronizing data stored by each first database into a second database in accordance with an embodiment of the present invention;
FIG. 9 is a flow chart of an alternative database processing method according to an embodiment of the present invention;
FIG. 10 is a schematic structural diagram of a database processing apparatus according to an embodiment of the present invention;
FIG. 11 is a schematic diagram of an alternative database processing apparatus according to an embodiment of the present invention;
FIG. 12 is a schematic diagram of an alternative database processing apparatus according to an embodiment of the present invention; and
fig. 13 is a schematic structural diagram of an alternative database processing device according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with an embodiment of the present invention, there is provided a method of processing a database, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 1 is a flowchart of a processing method of a database according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S102, a first database list is obtained, wherein the first database list comprises: and at least one first database, wherein the first database is a database with an error character set and correct stored data.
Step S104, creating at least one second database, where the second database is a database with a correct character set and empty storage content, and the at least one second database corresponds to the at least one first database one to one.
And step S106, synchronizing the data stored in each first database to the corresponding second database.
In step S102 of the present application, the first database is a database in which a character set has an error but stored data is correct, for example, a template database is usually used to generate a Profile (user Profile) dedicated database in an SQL Server (SQL Server is a relational database management system introduced by Microsoft corporation) database operation and maintenance process.
In step S104, at least one second database may be created on the current server, or at least one second database may be created on another server, where the second database is a database with a correct character set and empty storage content, and the at least one second database corresponds to the at least one first database one to one. It should be noted here that the manner of creating at least one second database on another server can reduce data redundancy and improve the processing efficiency of the database. In this embodiment, taking the example of creating at least one second database on another server as an example, the processing method of the database provided in this embodiment is to obtain three first databases, which are db1 (database), db3, and db5 respectively, where the three first databases are databases whose character sets have errors but stored data are correct, and then create three corresponding second databases db2, db4, and db6 respectively according to the three first databases, where the second database is a database corresponding to the first database whose character sets are correct and whose storage contents are empty.
In the above step S106 of the present application, still taking the example of creating second databases on other servers as an example, the correct data stored in each first database is synchronized into the corresponding second database, specifically, the correct data stored in db1 is synchronized into db2, the correct data stored in db3 is synchronized into db4, and the correct data stored in db5 is synchronized into db 6.
In the method for processing a database provided in this embodiment, a first database list is obtained, where the first database list includes: the method comprises the steps of establishing at least one first database, wherein the first database is a database with correct character sets but correct stored data, establishing at least one second database, wherein the second database is a database with correct character sets and empty stored contents, the at least one second database corresponds to the at least one first database one by one, synchronizing the data stored in each first database into the corresponding second database, quickly inquiring the first database to be modified, establishing the second database with correct character sets and empty stored contents on other servers, and then synchronizing the data stored in each first database into the second database, so that the work of modifying the character sets of the LSSQerver database in batches can be quickly and accurately realized.
It should be noted here that, in the prior art, the problem of how to modify the character set of the SQL Server database is mainly implemented by a method of the SSMS modifying the database one by one, specifically, a method including a table in which the character set is referred to, but when there are a lot of databases on the Server and the table structure of the database is complicated, the operation requires a lot of mouse click actions, is quite cumbersome, and is prone to errors.
From the above analysis, it can be known that, by the database processing method provided in this embodiment, a database list to be modified is quickly queried, databases with correct character sets are generated in other database instances, and then the data of the databases are sequentially synchronized, so that the purpose of modifying the character sets of the SQL Server database in batches is achieved, thereby solving the technical problems of complex process and easy error caused by adopting a method for modifying the character sets of the databases one by one in the prior art, and achieving the effect of quickly and accurately modifying the character sets of the databases.
Optionally, fig. 2 is a flowchart of a method for acquiring a first database list according to an embodiment of the present invention, and as shown in fig. 2, the method for acquiring a first database list includes:
step S202, executing a storage process of a database to obtain database information of a plurality of databases, wherein the database information list at least includes: character set information.
Step S204, importing the database information lists of the plurality of databases into the database table.
And step S206, filtering the database table by using the character set field to obtain a first database list.
In step S202, the database information of the multiple databases is obtained by executing the storage process of the database, and the information lists of all databases can be obtained by executing the storage process of the database instance. In the above-mentioned storing process of the execution database, the execution statement for obtaining the database information lists of the multiple databases may be: exesp _ hellpdb, fig. 3 is a schematic diagram of obtaining database information lists of a plurality of databases by a storage process of a database according to an embodiment of the present invention, and as shown in fig. 3, the information lists of all databases are obtained by the storage process carried by a database instance, where dbid represents a database identification number, created represents a creation date of the database, and status represents information of the databases, for example: status indicates that the database is ONLINE, update indicates that the modification authority of the data is readable and writable, and relationship indicates a character set.
In step S206, the database table may be filtered by using the relationship field to obtain the first database list.
It should be noted that, in this embodiment, since the information lists of all databases are acquired from the storage process carried by the database instance, the accuracy is high. By importing the database information of the databases into the database table, the data of the default storage process of the system is acquired from the beginning of data processing in the implementation, so that the acquired data is accurate and convenient to import into the database table, and further, the databases with character sets which do not accord with the specification can be filtered out by using SQL sentences to obtain a first database list.
Alternatively, fig. 4 is a flowchart of another method for acquiring a first database list according to an embodiment of the present invention, as shown in fig. 4, the method includes:
step S402, splitting the database information lists of the databases to obtain the split database information lists of the databases.
Step S404, extracting the database information lists of the plurality of split databases to obtain the character set information of each database.
Step S406, importing the character set information of each database into a database table.
It should be noted here that after the database information lists of the multiple databases are obtained in the storage process of the database, on one hand, the database information lists of the multiple databases may be imported into the database table, on the other hand, the database information lists of the multiple databases may be split to obtain the split database information lists of the multiple databases, then, the database information lists of the split multiple databases are extracted to obtain the character set information of each database, and then, the character set information of each database is imported into the database table.
For example, as shown in fig. 3, the information Status of the databases in the information list passes through and is divided, for example, Status, update availability and relationship in the information of the databases pass through and are divided, so that the information of each database in the information list can be split according to and, that is, the Status information of each database can be split according to and can be extracted, and the relationship information of each database can be extracted, that is, the character set information can be extracted, and the character set information can be imported into the database table. The database table includes only the following: the database identification dbid, the database creation date created and the character set information relationship.
From the above analysis, the method of splitting the database information list and extracting the character set information reduces the range of filtering the database table by using the character set field, that is, the database table is filtered by using the character set field, and therefore, the response speed of database query is improved.
Optionally, fig. 5 is a flowchart of a method for obtaining a first database list according to an embodiment of the present invention, and as shown in fig. 5, the method for obtaining a first database list by filtering a database table using a character set field includes:
step S502, matching the character set information of each database with the preset character set information.
Step S504, if the character set information of any one database is not matched with the preset character set information, determining that any one database is the first database.
In the above step S502 of the present application, the example of using the relationship field to filter the database table to obtain the first database list is still described. The execution statement for matching the character set information of each database with the preset character set information may be: WHERE GGG NOT LIKE 'ligation ═ core%', i.e. the fields in the database table that do NOT meet the condition of ` ligation ` core% `arefiltered out by the ligation field.
In step S504, if the character set information of any one of the databases is not matched with the preset character set information, it is determined that any one of the databases is the first database, and specifically, after filtering the database table using the relationship field, the first database list is obtained as shown in table 1 below:
table 1 shows two first databases obtained by filtering using the Collision field
GGG
1 Collation=Latin1_General_Cl_AS_KS_WS
2 Collation=Latin1_General_Cl_AS_KS_WS
As can be seen from table 1, in the process of filtering the database table by using the character set field to obtain the first database list, the database table may be filtered by using a comparison field, for example, a field in the database table that does not meet the condition of "comparison%" is filtered out, so as to obtain two first databases as shown in table 1.
Optionally, fig. 6 is a flowchart of a method for creating at least one second database according to an embodiment of the present invention, and as shown in fig. 6, the method for creating at least one second database includes:
step S602, generating at least one blank database by using the template library with the correct character set, and obtaining at least one second database.
In the above step S602 of the present application, taking the example of creating at least one second database on another server as an example, because the first database is only that the character set has an error, but the data stored in the first database is correct, for this reason, in this embodiment, based on information of another database of each first database except the information of the character set, a blank database is generated on another server by using a template library with a correct character set, so as to obtain at least one second database.
Optionally, the method of synchronizing the data stored in each first database into the second database includes: and sequentially synchronizing the data stored in at least one first database to the corresponding second database by using a data synchronization tool or a database statement.
In the foregoing solution of the present application, the database statements may be SQL statements, further, correct data stored in at least one first database is sequentially synchronized into a corresponding second database with correct character sets and empty storage contents through the data synchronization tool or the database statements, so as to achieve the purpose of modifying the character sets of the SQL Server database, fig. 7 is a schematic diagram of optionally using the data synchronization tool to synchronize data stored in each first database into the corresponding second database according to an embodiment of the present invention, and as shown in fig. 7, specifically, the database statements located in the current Server: 172.17.1.155, the data stored in the first database webdistectordw _80045 is synchronized to other servers, such as server: X230I-PC.
Optionally, fig. 8 is a flowchart of a method for synchronizing data stored in each first database into a second database according to an embodiment of the present invention, and as shown in fig. 8, the method for synchronizing data stored in at least one first database into a corresponding second database includes:
step S802, using a data synchronization tool or a database statement, to synchronize data stored in at least one first database to a corresponding second database at the same time.
In the step S802, the database statement may be an SQL statement, and further, the data synchronization tool or the database statement synchronizes correct data stored in at least one first database to a corresponding second database with correct character sets and empty storage contents, so as to achieve the purpose of modifying the character sets of the SQL Server database in batch.
It should be noted that, in this embodiment, data of the default storage process of the system is obtained from the beginning of data processing, which is accurate and convenient to import into the database table, and is convenient to use SQL statement filtering conditions for screening, and the data synchronization tool is only used for data level synchronization, thereby avoiding a large amount of operations for modifying the character sets of the database and the table one by one.
Fig. 9 is a flowchart of an optional database processing method according to an embodiment of the present invention, and as shown in fig. 9, in this embodiment, filtering a database table by using a Status field is exemplified, so as to implement the database processing method provided in this embodiment, and specific steps are as follows:
step S90, start processing;
step S92, acquiring information lists of all databases through the self-contained storage process of the system for inquiring database instances;
step S94, storing the database information list into a database table, and filtering out the database list with character set errors by using Status fields;
step S96, creating at least one blank database (corresponding to the second database in the present embodiment) with correct character set settings on the other server using the template library;
step S98, synchronizing correct data in an incorrect database (corresponding to the first database in the present embodiment) into a blank database (corresponding to the second database in the present embodiment) with a correct character set, wherein the at least one second database corresponds to the at least one first database one-to-one;
step S100 ends the process.
Therefore, aiming at the technical problems that the process is complicated and the error is easy to occur when a method for modifying the character sets of the databases one by one is adopted in the prior art, the invention provides a processing method of the databases.
In this embodiment, the database list under the instance is acquired from the system table of the database instance, so that the accuracy is high. By importing the result into a temporary table of the database, the database with the character set not meeting the specification can be filtered out by using the SQL statement, and then the data is imported into a correct empty database after an empty database with the character set meeting the specification is generated in other database instances. In addition, the data of the default storage process of the system is obtained from the beginning of data processing, the data are accurately and conveniently imported into the database table, the SQL statement filtering conditions are conveniently used for screening, and the data synchronization tool is only used for synchronizing the data layer, so that a great amount of operations of modifying the character sets of the database and the table one by one are avoided.
According to the present embodiment, there is also provided a database processing apparatus, where the database processing apparatus is mainly used to execute the database processing method provided in the foregoing embodiments of the present invention, and the following describes the database processing apparatus provided in the present embodiment in detail.
Fig. 10 is a schematic structural diagram of a database processing apparatus according to an embodiment of the present invention, and as shown in fig. 10, the apparatus includes:
an obtaining module 1001, configured to obtain at least one first database list, where the first database list includes: and at least one first database, wherein the first database is a database with an error in the character set but correct stored data.
A creating module 1003, configured to create at least one second database, where the second database is a database with a correct character set and empty storage content, and the at least one second database corresponds to the at least one first database one to one.
A synchronization module 1005, configured to synchronize data stored in each first database to a corresponding second database.
In this embodiment, the first database list is a database list in which a character set has an error, but stored data is correct, for example, a database dedicated to Profile (user Profile) is usually generated by using a template library in an SQL Server (SQL Server is a relational database management system proposed by Microsoft corporation) database operation and maintenance process.
In this embodiment, at least one second database may be created on the current server, or at least one second database may be created on another server, where the second database has a correct character set and stores empty data, and the at least one second database corresponds to the at least one first database one to one. It should be noted here that the manner of creating at least one second database on another server can reduce data redundancy and improve the processing efficiency of the database. In this embodiment, taking the example of creating at least one second database on another server as an example, the processing method of the database provided in this embodiment is to obtain three first databases, which are db1 (database), db3, and db5 respectively, where the three first databases are databases whose character sets have errors but stored data are correct, and then create three corresponding second databases db2, db4, and db6 respectively according to the three first databases, where the second database is a database corresponding to the first database whose character sets are correct and whose storage contents are empty.
In this embodiment, still taking the example of creating at least one second database on another server as an example, the correct data stored in each first database is synchronized into the created second database, specifically, the correct data stored in db1 is synchronized into db2, the correct data stored in db3 is synchronized into db4, and the correct data stored in db5 is synchronized into db 6.
As can be seen from the above, in the second embodiment of the present application, the database processing apparatus obtains, by the obtaining module, a first database list, where the first database list includes: the SQL Server comprises at least one first database, a creating module and at least one second database, wherein the first database is a database with correct character sets but correct stored data, the creating module is used for creating at least one second database, the second database is a database with correct character sets and empty stored contents, the at least one second database corresponds to the at least one first database one by one, the synchronizing module is used for synchronizing the data stored in each first database into the corresponding second database, the first database needing to be modified is quickly inquired out, the second database with correct character sets and empty stored contents is created on other servers, and then the data stored in each first database is synchronized into the second database, so that the SQL Server can be quickly and accurately modified in batches.
It should be noted here that, in the prior art, the problem of how to modify the character set of the SQL Server database is mainly implemented by a method of the SSMS modifying the database one by one, specifically, a method including a table in which the character set is referred to, but when there are a lot of databases on the Server and the table structure of the database is complicated, the operation requires a lot of mouse click actions, is quite cumbersome, and is prone to errors.
From the above analysis, it can be known that, by the processing device of the database provided in this embodiment, a database list to be modified is quickly queried, databases with correct character sets are generated in other database instances, and then the data of the databases are sequentially synchronized, so that the purpose of modifying the character sets of the SQL Server database in batches is achieved, thereby solving the technical problems of complex process and easy error caused by adopting a method for modifying the character sets of the databases one by one in the prior art, and achieving the effect of quickly and accurately modifying the character sets of the databases.
Optionally, as shown in fig. 11, the obtaining module 1001 includes:
the first processing sub-module 1101 is configured to perform a storage process of a database, and obtain a database information list of a plurality of databases, where the database information at least includes: character set information; the plurality of databases includes: at least one first database.
An import sub-module 1103, configured to import the database information lists of the multiple databases into the database table.
The second sub-processing module 1105 is configured to filter the database tables using the character set fields to obtain at least one first database list.
In this embodiment, the database information lists of the multiple databases are obtained by executing the storage process of the database, and the information lists of all databases can be obtained by executing the storage process of the database instance itself. In the above-mentioned storage process of the execution database, the execution statement for obtaining the database information of the multiple databases may be: exe sp _ hellpdb, as shown in fig. 2, executes the storage process carried by the database instance to obtain the information list of all databases, where dbid represents the database identification number, created represents the creation date of the database, and status represents the information of the database, such as: status indicates that the database is ONLINE, update indicates that the data modification authority is readable and writable, and relationship indicates a character set.
In this embodiment, the database table may be filtered using the relationship field to obtain at least one first database list.
It should be noted that, in this embodiment, since the information lists of all databases are acquired from the storage process carried by the database instance, the accuracy is high. By importing the database information of the databases into the database table, the data of the default storage process of the system is acquired from the beginning of data processing in the implementation, so that the acquired data is accurate and convenient to import into the database table, and further, the databases with character sets which do not accord with the specification can be filtered out by using SQL sentences to obtain at least one first database list.
Optionally, in this embodiment, the processing device of the database further includes:
and the splitting module is used for splitting the database information lists of the plurality of databases to obtain the split database information lists of the plurality of databases.
And the extraction module is used for extracting the database information lists of the plurality of split databases to obtain the character set information of each database.
And the importing module is used for importing the character set information of each database into the database table.
It should be noted here that after the database information lists of the multiple databases are obtained in the storage process of the database, on one hand, the database information lists of the multiple databases may be imported into the database table, on the other hand, the database information lists of the multiple databases may be split to obtain the split database information lists of the multiple databases, then, the database information lists of the split multiple databases are extracted to obtain the character set information of each database, and then, the character set information of each database is imported into the database table. From the above analysis, it can be seen that, by means of clustering, the range of filtering the database table by using the character set field is narrowed, that is, the database table is filtered by using the character set field, and therefore, the response speed of querying the database is improved.
Optionally, in this embodiment, the second processing sub-module includes:
and the matching weight submodule is used for matching the character set information of each database with the preset character set information.
And the weight determining sub-module is used for determining any database as the first database if the character set information of any database is not matched with the preset character set information.
In this embodiment, the example of using the relationship field to filter the database table to obtain at least one first database list is still described. The execution statement for matching the character set information of each database with the preset character set information may be: WHERE GGG NOT LIKE 'ligation ═ core%', i.e. the fields in the database table that do NOT meet the condition of ` ligation ` core% `arefiltered out by the ligation field.
In this embodiment, if the character set information of any one database is not matched with the preset character set information, it is determined that any one database is the first database, and specifically, after filtering the database table by using a relation field, the first database list is obtained as shown in table 1. As can be seen from table 1, in the process of filtering the database table by using the character set field to obtain the first database list, the database table may be filtered by using a comparison field, for example, a field in the database table that does not meet the condition of "comparison%" is filtered out, so as to obtain two first databases as shown in table 1.
Optionally, as shown in fig. 12, the creating module 1003 includes:
the generating sub-module 1201 generates at least one blank database using the template library with the correct character set to obtain at least one second database.
In this embodiment, a description is given by taking an example of creating at least one second database on another server, and since the first database is only that the character set has an error, but the data stored in the first database is correct, for this reason, in this embodiment, based on information of another database of each first database except for information of the character set, a blank database is generated on another server by using a template library with a correct character set, so as to obtain at least one second database.
Optionally, in this embodiment, the synchronization module includes:
and the first synchronization submodule is used for sequentially synchronizing the data stored in at least one first database into the corresponding second database by using a data synchronization tool or a database statement.
In this embodiment, the database statements may be SQL statements, and further, correct data stored in at least one first database is sequentially synchronized to a corresponding second database with correct character sets and empty storage contents through the data synchronization tool or the database statements, so as to achieve the purpose of modifying the character sets of the SQL Server database.
Optionally, as shown in fig. 13, the synchronization module 1005 includes:
the second synchronization sub-module 1301 is configured to synchronize data stored in at least one first database to a corresponding second database at the same time using a data synchronization tool or a database statement.
In this embodiment, the database statements may be SQL statements, and further, the data synchronization tool or the database statements synchronize correct data stored in at least one first database to a corresponding second database with correct character sets and empty storage contents at the same time, so as to achieve the purpose of modifying the SQL Server database character sets in batch.
It should be noted that, in this embodiment, data of the default storage process of the system is obtained from the beginning of data processing, which is accurate and convenient to import into the database table, and is convenient to use SQL statement filtering conditions for screening, and the data synchronization tool is only used for data level synchronization, thereby avoiding a large amount of operations for modifying the character sets of the database and the table one by one.
Therefore, aiming at the technical problems that the process is complicated and errors are easy to occur when a method for modifying the character set of the database one by one is adopted in the prior art, the invention provides a processing method of the database, which is implemented by acquiring at least one first database list, wherein the first database list comprises: the method comprises the steps of establishing at least one first database, wherein the first database is a database with correct character sets but correct stored data, establishing at least one second database, the second database is a database with correct character sets and empty stored contents, the at least one second database corresponds to the at least one first database one by one, and the data stored in each first database is synchronized into the corresponding second database, so that the purpose of modifying the character sets of the SQL Server database in batches is achieved, the technical problems that the process is complicated and errors are easy to occur in the prior art due to the fact that a method for modifying the character sets of the databases one by one is adopted are solved, and the effect of quickly and accurately modifying the character sets of the databases is achieved.
In this embodiment, the database list under the instance is acquired from the system table of the database instance, so that the accuracy is high. By importing the result into a temporary table of the database, the database with the character set not meeting the specification can be filtered out by using the SQL statement, and then the data is imported into a correct empty database after an empty database with the character set meeting the specification is generated in other database instances. In addition, the data of the default storage process of the system is obtained from the beginning of data processing, the data are accurately and conveniently imported into the database table, the SQL statement filtering conditions are conveniently used for screening, and the data synchronization tool is only used for synchronizing the data layer, so that a great amount of operations of modifying the character sets of the database and the table one by one are avoided.
The processing device of the database comprises a processor and a memory, the acquisition module, the creation module, the synchronization module and the like are stored in the memory as program units, and the processor executes the program units stored in the memory. The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to one or more than one, and the text content is analyzed by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The present application further provides an embodiment of a computer program product, which, when being executed on a data processing device, is adapted to carry out program code for initializing the following method steps: obtaining a first database listing, wherein the first database listing comprises: at least one first database, wherein the first database is a database in which a character set has errors and stored data is correct; creating at least one second database, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database is in one-to-one correspondence with the at least one first database; and synchronizing the data stored in each first database into the corresponding second database.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method for processing a database, comprising:
obtaining a first database listing, wherein the first database listing comprises: the system comprises at least one first database, a database module and a database module, wherein the first database is a database with an error character set but correct stored data, and is a special database for the Profile generated by adopting a template library;
creating at least one second database on a server different from the server where the first database is located, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database corresponds to the at least one first database one to one;
and synchronizing the data stored in each first database into the corresponding second database.
2. The method of claim 1, wherein obtaining a first database listing comprises:
executing a storage process of a database to obtain a database information list of a plurality of databases, wherein the database information list at least comprises: character set information;
importing database information lists of the plurality of databases into a database table;
and filtering the database table by using the character set field to obtain the first database list.
3. The method according to claim 2, wherein after performing a storing process of the database to obtain the database information lists of the plurality of databases, the method further comprises:
splitting the database information lists of the plurality of databases to obtain the split database information lists of the plurality of databases;
extracting the database information lists of the plurality of split databases to obtain the character set information of each database;
and importing the character set information of each database into the database table.
4. The method of claim 2 or 3, wherein filtering the database table using a character set field to obtain the first database list comprises:
matching the character set information of each database with preset character set information;
and if the character set information of any one database is not matched with the preset character set information, determining that the any one database is the first database.
5. The method of claim 1, wherein creating at least one second database comprises:
and generating at least one blank database by using the template library with the correct character set to obtain at least one second database.
6. The method of claim 1, wherein synchronizing the data stored by each first database into a corresponding second database comprises:
and simultaneously synchronizing the data stored in the at least one first database into the corresponding second database by using a data synchronization tool or a database statement.
7. A database processing apparatus, comprising:
an obtaining module, configured to obtain a first database list, where the first database list includes: the system comprises at least one first database, a database module and a database module, wherein the first database is a database with an error character set but correct stored data, and is a special database for the Profile generated by adopting a template library;
the creating module is used for creating at least one second database on a server different from the server where the first database is located, wherein the second database is a database with a correct character set and empty storage content, and the at least one second database corresponds to the at least one first database one to one;
and the synchronization module is used for synchronizing the data stored in each first database into the corresponding second database.
8. The apparatus of claim 7, wherein the obtaining module comprises:
the first processing sub-module is configured to perform a storage process of a database to obtain a database information list of multiple databases, where the database information at least includes: character set information;
the importing submodule is used for importing the database information lists of the plurality of databases into a database table;
and the second processing submodule is used for filtering the database table by using the character set field to obtain the first database list.
9. The apparatus of claim 7, wherein the creation module comprises:
and the generating submodule is used for generating at least one blank database by using the template library with the correct character set to obtain at least one second database.
10. The apparatus of claim 7, wherein the synchronization module comprises:
and the second synchronization sub-module is used for synchronizing the data stored in the at least one first database into the corresponding second database at the same time by using a data synchronization tool or a database statement.
CN201610597808.1A 2016-07-26 2016-07-26 Database processing method and device Active CN107656940B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610597808.1A CN107656940B (en) 2016-07-26 2016-07-26 Database processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610597808.1A CN107656940B (en) 2016-07-26 2016-07-26 Database processing method and device

Publications (2)

Publication Number Publication Date
CN107656940A CN107656940A (en) 2018-02-02
CN107656940B true CN107656940B (en) 2020-06-16

Family

ID=61126558

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610597808.1A Active CN107656940B (en) 2016-07-26 2016-07-26 Database processing method and device

Country Status (1)

Country Link
CN (1) CN107656940B (en)

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6970877B2 (en) * 2002-06-28 2005-11-29 Microsoft Corporation Reducing and controlling sizes of prototype-based recognizers
CN104252481B (en) * 2013-06-27 2018-10-19 阿里巴巴集团控股有限公司 The dynamic check method and apparatus of master-slave database consistency
CN105243168B (en) * 2015-11-11 2019-08-30 中国建设银行股份有限公司 A kind of data migration method and system

Also Published As

Publication number Publication date
CN107656940A (en) 2018-02-02

Similar Documents

Publication Publication Date Title
CN107918666B (en) Data synchronization method and system on block chain
CN108536752B (en) Data synchronization method, device and equipment
CN107609217B (en) Processing method and device for collision check data
CN104899295B (en) A kind of heterogeneous data source data relation analysis method
US20180246955A1 (en) Method and device for searching legal provision
CN106446019B (en) A kind of software function treating method and apparatus
CN107016019B (en) Database index creation method and device
EP2862101B1 (en) Method and a consistency checker for finding data inconsistencies in a data repository
CN104915414A (en) Data extraction method and device
CN106844320B (en) Financial statement integration method and equipment
CN103186560A (en) Data sorting method and related device
CN105159952A (en) Data processing method based on frequent item set mining
CN105095436A (en) Automatic modeling method for data of data sources
CN107368569B (en) Data difference comparison method and device, storage medium and processor
CN112948473A (en) Data processing method, device and system of data warehouse and storage medium
CN107656940B (en) Database processing method and device
CN104506636B (en) A kind of method of data synchronization and device
CN113672692A (en) Data processing method, data processing device, computer equipment and storage medium
CN107085603B (en) Data processing method and device
CN110908978B (en) Database data structure verification method and device
CN105760382A (en) Method and device for importing excel data into database
CN110008231B (en) MySQL data backtracking method and storage medium
CN110147396B (en) Mapping relation generation method and device
EP2620827A2 (en) Work content creation apparatus and method, and workflow creation apparatus and method
JP7131119B2 (en) Systems and methods for merging source data from a source application with target data in a target application

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100083 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: Beijing Guoshuang Technology Co.,Ltd.

Address before: 100086 Cuigong Hotel, 76 Zhichun Road, Shuangyushu District, Haidian District, Beijing

Applicant before: Beijing Guoshuang Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant