CN115658726A - Database integration method, device, equipment and storage medium - Google Patents

Database integration method, device, equipment and storage medium Download PDF

Info

Publication number
CN115658726A
CN115658726A CN202211414896.9A CN202211414896A CN115658726A CN 115658726 A CN115658726 A CN 115658726A CN 202211414896 A CN202211414896 A CN 202211414896A CN 115658726 A CN115658726 A CN 115658726A
Authority
CN
China
Prior art keywords
database
query
execution
local database
operation instruction
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
CN202211414896.9A
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.)
Shenzhen Hanyun Technology Co ltd
Original Assignee
Shenzhen Hanyun 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 Shenzhen Hanyun Technology Co ltd filed Critical Shenzhen Hanyun Technology Co ltd
Priority to CN202211414896.9A priority Critical patent/CN115658726A/en
Publication of CN115658726A publication Critical patent/CN115658726A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention relates to the field of data processing, and discloses a database integration method, a database integration device, a database integration equipment and a database integration storage medium. The method comprises the following steps: s101, acquiring a data operation instruction by a local database; s102, the local database judges whether the data operation instruction is an SQL operation instruction of the external database, if the data operation instruction is the SQL operation instruction of the external database, the step S103 is carried out, and if not, the step S105 is carried out; s103, the local database queries a connection character string in a preset database registration table according to the name of the external database, and the step S104 is entered; s104, the local database establishes communication connection with an external database corresponding to the connection character string, and performs data operation processing on the external database according to the SQL execution statement to generate an operation result; s105, the local database judges whether the data operation instruction has a With execution statement, and if the With execution statement exists, the step S106 is carried out; and S106, the local database executes the statement based on the Wit h in the data operation instruction, and the external database is queried.

Description

Database integration method, device, equipment and storage medium
Technical Field
The present invention relates to the field of data processing, and in particular, to a database integration method, apparatus, device, and storage medium.
Background
In a production environment, the construction period of an IT system of an enterprise/unit is long, and the sources of IT system manufacturers are many, so that various heterogeneous databases such as MYSQL, ORACLE, SQLSERVER and the like exist in one enterprise/unit. Along with the large data circulation, an enterprise/unit can build a large data analysis platform, wherein a database is selected as a main database, and a large data application system is connected with the main database. Most data in the existing database can be extracted and converged to the main database through the ETL, but some data with extremely high sensitivity or real-time requirements can still be only stored in the original database. The big data application platform is only connected with the main database, and needs to meet the requirements of simultaneously inquiring, counting and analyzing data in the main database and data in the original heterogeneous database, so that the main database needs to have the function of multi-database integration: i.e. objects in a plurality of heterogeneous databases (e.g. MYSQL, ORACLE, SQLSERVER, etc.) can be operated on in the main database. In the database industry, different database vendors provide different solutions for "multi-database integration," such as Oracle's DBLink mechanism. However, these schemes are either complex to implement and require high development cost, or complicated to apply and increase the difficulty of users. Therefore, a solution is needed to solve the technical problems of complex implementation process, high cost and complex application of the integration of the partitioned database.
Disclosure of Invention
The invention mainly aims to solve the technical problems of complex integrated implementation process, higher cost and complex application of the sectional database.
The first aspect of the present invention provides a database integration method, configured to implement data operations between a local database and an external database, where the database integration method includes:
s101, the local database acquires a data operation instruction, wherein the data operation instruction comprises: connecting the database name and the SQL execution statement;
s102, the local database judges whether the data operation instruction is an SQL operation instruction of the external database, if the data operation instruction is the SQL operation instruction of the external database, the step S103 is carried out, and if not, the step S105 is carried out;
s103, the local database inquires a connection character string in a preset database registration table according to the name of the external database, and the step S104 is entered;
s104, the local database establishes communication connection with an external database corresponding to the connection character string, and performs data operation processing on the external database according to the SQL execution statement to generate an operation result;
s105, the local database judges whether a With execution statement exists in the data operation instruction, and if the With execution statement exists, the step S106 is executed;
and S106, the local database performs query processing on the external database based on the With execution statement in the data operation instruction.
Optionally, in a first implementation manner of the first aspect of the present invention, the executing statement with a resource includes: n with execution clauses, where N is a positive integer, the step S106 includes:
s1061, judging whether the N with-execution clauses are executed or not by the local database, if so, entering a step S1065, otherwise, entering a step S1062;
s1062, the local database reads an unexecuted with execution clause in the N with execution clauses, judges whether the unexecuted with execution clause has a query characteristic character string, if not, the step S1063 is carried out, otherwise, the step S1064 is carried out;
s1063, the local database utilizes the unexecuted with execution clause to perform creation execution processing on the local database according to a preset creation execution algorithm to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1064, the local database queries an external database corresponding to the query characteristic character string by using the query characteristic character string to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1065, the local database executes a SELECT statement of a preset temporary table, generates a query processing result, and deletes the temporary table.
Optionally, in a second implementation manner of the first aspect of the present invention, the step S1063 includes:
s10631, the local database creates a temporary table in the local database based on the corresponding relation between the unexecuted with execution clause and the external database;
s10632, executing the SQL instruction in the unexecuted with execution clause by the local database in the external database corresponding to the unexecuted with execution clause to generate with execution data;
s10633, the local database writes the execution data with the length into the temporary table to generate the query subdata.
Optionally, in a third implementation manner of the first aspect of the present invention, the step S1064 includes:
s10641, establishing a communication connection between the local database and an external database corresponding to the query characteristic character string, and establishing a temporary table of the external database corresponding to the query characteristic character string;
s10642, the local database executes the SQL instruction in the unexecuted with execution clause to the external database corresponding to the query characteristic character string, and generates with execution data;
s10643, the local database writes the execution data with the length into the temporary table to generate the query subdata.
Optionally, in a fourth implementation manner of the first aspect of the present invention, after the step S101 and before the step S102, the method further includes:
s1011, the local database judges whether the data operation instruction is a database registration instruction, if so, the step S1012 is executed, otherwise, the step S1013 is executed;
s1012, the local database adds an external database corresponding to the data operation instruction to a preset database registration table;
s1013, the local database judges whether the data operation instruction is a database deletion instruction, if so, the step S1014 is executed, otherwise, the step S102 is executed;
and S1014, deleting the external database corresponding to the data operation instruction from a preset database registration table by the local database.
Optionally, in a fifth implementation manner of the first aspect of the present invention, after the step S104, the method further includes:
s1041, the local database performs compatibility conversion processing on the operation result by using a preset compatibility algorithm to obtain result compatible data;
s1042, the local database sends the result compatible data to a port corresponding to the data operation instruction.
A second aspect of the present invention provides an apparatus for integrating a database, configured to implement data operations between a local database and an external database, where the apparatus for integrating a database includes:
an obtaining module, configured to obtain a data operation instruction by the local database, where the data operation instruction includes: connecting the database name and the SQL execution statement;
a first judging module, configured to judge, by the local database, whether the data operation instruction is an SQL operation instruction of the external database
The query module is used for the local database to query a connection character string in a preset database registration table according to the name of the external database;
the data operation module is used for establishing communication connection between the local database and an external database corresponding to the connection character string, performing data operation processing on the external database according to the SQL execution statement and generating an operation result;
the second judging module is used for judging whether the data operation instruction has a With execution statement or not by the local database;
and the data query module is used for performing query processing on the external database by the local database based on the With execution statement in the data operation instruction.
A third aspect of the present invention provides an integration apparatus for a database, including: a memory having instructions stored therein and at least one processor, the memory and the at least one processor interconnected by a line; the at least one processor calls the instructions in the memory to cause the database integration device to perform the above-mentioned database integration method.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which, when executed on a computer, cause the computer to execute the above-described database integration method.
In the embodiment of the invention, aiming at the requirement of 'multi-database integration' of the database, the SQL definition is expanded on the basis of the SQL standard, and a plurality of databases are integrated by the expanded SQL database, so that the technical problems of complex implementation process, high cost and complex application of the current subsection database integration are solved.
Drawings
FIG. 1 is a diagram of an embodiment of a database integration method according to an embodiment of the present invention;
FIG. 2 is a diagram of an embodiment of an apparatus for integrating a database according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of another embodiment of an apparatus for integrating a database according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an embodiment of an integration apparatus of a database in the embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a database integration method, a database integration device, database integration equipment and a storage medium.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be implemented in other sequences than those illustrated or described herein. Moreover, the terms "comprises," "comprising," or "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.
For convenience of understanding, a specific flow of an embodiment of the present invention is described below, with reference to fig. 1, an embodiment of a database integration method in an embodiment of the present invention is used for implementing data operations between a local database and an external database, where the database integration method includes:
s101, a local database acquires a data operation instruction, wherein the data operation instruction comprises: connecting the database name and the SQL execution statement;
in this embodiment, in order to implement the "multiple database integration" function, firstly, the SQL definition needs to be extended on the basis of the SQL standard, and the extended SQL syntax customization includes the following parts:
1. the first part, creating an external database connection SQL syntax:
CREATE DATABASE LINK link_name USING connect_string
connect_string:link_type/ip:port/'user_name'/'user_passwd'/'db_name'
link _ name is a connection name, connect _ string is a connection string
Such as:
CREATE DATABASE LINK ORACLE
USING ORACLE/10.10.0.102, 'usertest'/'123456'/'household register Bank'
CREATE DATABASE LINK MYSQL
USING MYSQL/10.10.0.103'
CREATE DATABASE LINK SQLSERVER
USING SQLSERVER/10.10.0.104 1356/'usertest'/'123456'/'social Security Bank'
2. Second part, deleting external database connection SQL syntax
DROP DATABASE LINK link_name
Link _ name is the connection name of an external database that has been created previously
Such as:
DROP DATABASE LINK ORACLE
DROP DATABASE LINK MYSQL
DROP DATABASE LINK SQLSERVER
3. third, operating on external database SQL syntax
@@@link_name SQLStatement
The link _ name is the connection name of an external database that has been created previously, and the SQLState is any SQL that can be executed on the database pointed to by the link _ name, including SELECT/UPDATE/DELETE/INSERT/CREATE/DROP, etc. The key @ @ link _ name is equivalent to prompt information, namely prompting that the subsequent SQL statement is executed not in the local library but in the external library specified by the link _ name.
Such as:
@@@MYSQL
SELECT SFZH AS identity card number, HPHM AS number plate number
FROM VEHICLE AS Motor VEHICLE registration Profile
The above statements show that the identification number and the number plate number data are inquired in a motor vehicle registration file table of a MYSQL service database, namely a vehicle driving management file library.
4. The fourth part, the multi-database correlation SQL syntax:
WITH with_references
select_statement
with_references:
with_reference[,with_reference]...
with_reference:
query_name AS([@@@link_name]with_reference_sql_statement)
wherein, with _ reference _ sql _ status, is any sql statement generating query result set legally for the target library, such as select, show, etc.; SELECT _ State A Multi-Table SELECT statement that is self-supporting for the library
The WITH grammar is a grammar in standard SQL, and the definition of the WITH grammar is expanded on the basis of the standard SQL, namely: the @ @ link name prompt statement is added to prompt that the SQL statement in the prompt statement is not executed locally but is executed in a specified external database.
Such as:
WITH
query_rst1 AS(@@@MYSQL select sfzh,hphm from vehicle),
query_rst2 AS(@@@ORACLE select sfzh,hz from passport),
query_rst3 AS(@@@_SQLSERVER select sfzh,sbkh from social_security)
select phone.sfzh,phone.sjh,query_rst1.hphm,query_rst2.hz,query_rst3.sbkh
from phone,query_rst1,query_rst2,query_rst3
where phone.sfzh=query_rst1.sfzh and phone.sfzh=query_rst2.sfzh and phone.sfzh=query_rst3.sfzh
the identification number (sfzh) and the number plate number (hphm) data are inquired from a vehicle registration archive (vehicle) of an external database MYSQL, and the inquiry result is named as query _ rst1.
The identity card number (sfzh) and passport (hz) data are searched from the passport registration archive table (passport) of the external database "ORACLE", and the search result is named as query _ rst2.
Inquiring data of an identity card number (sfzh) and a social security card number (sbkh) from a social security card registration file table (passport) of an external database 'SQLSERVER', and taking an alias of an inquiry result as query _ rst3.
And finally, inquiring the identity card number (sfzh) and the mobile phone number (sjh) data from a mobile phone number registration archive table (phone) of the local library, and associating the inquired data with query _ rst1, query _ rst2 and query _ rst3 based on sfzh to obtain complete personal information of a person including the identity card number (sfzh), the mobile phone number (sjh), the social security card number (sbkh), the passport (hz) and the number plate number (hphm).
After the SQL is based on the extended SQL grammar, a data operation instruction is received, wherein the data operation instruction comprises a connection name and the content of an SQL execution statement.
Further, after S101, before S102, the following steps may be further performed:
s1011, the local database judges whether the data operation instruction is a database registration instruction, if so, the step S1012 is executed, otherwise, the step S1013 is executed;
s1012, adding an external database corresponding to the data operation instruction to a preset database registration table by the local database;
s1013, the local database judges whether the data operation instruction is a database deletion instruction, if so, the step S1014 is executed, otherwise, the step S102 is executed;
and S1014, deleting the external database corresponding to the data operation instruction from the preset database registration table by the local database.
In steps S1011 to S1014, it is determined whether the data operation instruction is a database registration instruction, and if it is determined to be the database registration instruction, step S1012 is executed. If the SQL submitted to the master DATABASE is "CREATE DATABASE LINK ORACLE USE ORACLE/10.10.0.102, it fills the (ORACLE, ORACLE/10.10.0.102,/'usertest'/'123456'/'tenant library') information into the external DATABASE registry for the SQL statement that CREATEs the external DATABASE connections.
If it is judged that it is not the database registration instruction, the flow proceeds to step S1013, where it is further judged whether it is a database deletion instruction. If the command is a DATABASE deletion command, step 1014 is entered, if the SQL submitted to the main DATABASE is "DROP DATABASE LINK ORACLE", which is an SQL statement for deleting the connection of the external DATABASE, and the record corresponding to "ORACLE" is deleted from the DATABASE. If not, the process proceeds to step S102 for analysis.
S102, the local database judges whether the data operation instruction is an SQL operation instruction of the external database, if the data operation instruction is the SQL operation instruction of the external database, the step S103 is carried out, and if not, the step S105 is carried out;
s103, the local database queries a connection character string in a preset database registration table according to the name of the external database, and the step S104 is entered;
in steps S102-S103, it is further determined whether the operation command is an SQL operation command, and if the operation command is the SQL operation command, the process proceeds to step S103, where a connection string is first queried from the registry. If the SQL submitted to the main database is the "@ @ MYSQL SELECT SFZH AS identity number, HPHM AS number plate number FROM VEHICLE AS motor VEHICLE registration archive", it is the SQL statement for operating the external database. And extracting a connection name "MYSQL" from the SQL statement, and finding a corresponding connection character string "MYSQL/10.10.0.103".
S104, the local database establishes communication connection with the external database corresponding to the connection character string, and performs data operation processing on the external database according to the SQL execution statement to generate an operation result;
in the present embodiment, a connection is established with the external target database based on the connection string information. And extracting a SQL sentence 'SELECT SFZH AS identity number and HPHM AS number plate number FROM VEHICLE AS motor VEHICLE registration file' to be executed by the target database FROM the SQL, and sending the sentence to the target database for execution through the connection established in the previous step to obtain an operation result.
Further, after step S104, the following steps may be further performed:
s1041, performing compatible conversion processing on an operation result by using a preset compatible algorithm in a local database to obtain result compatible data;
and S1042, the local database sends the result compatible data to a port corresponding to the data operation instruction.
In steps S1041 to S1042, a result set executed by the target library is obtained, and the result set is returned to the port corresponding to the data operation instruction after performing compatibility adaptation conversion. For example, compatibility adaptation conversion of data types, such as tinyint data type of external target database, and the primary database does not have the type, so that the type needs to be converted into int type supported by the primary database.
S105, the local database judges whether a Path execution statement exists in the data operation instruction, and if the Path execution statement exists, the step S106 is executed;
in this embodiment, in the case that the data operation instruction is not the SQL operation instruction of the database as entered in step S102, it is determined whether the data operation instruction has a With execution statement.
SQL is the following With execution statement if submitted to the master database:
WITH
query_rst1 AS(@@@MYSQL select sfzh,hphm from vehicle),
query_rst2 AS(@@@ORACLE select sfzh,hz from passport),
query_rst3 AS(@@@SQLSERVER select sfzh,sbkh from social_security)
select phone.sfzh,phone.sjh,query_rst1.hphm,query_rst2.hz,query_rst3.sbkh
from phone,query_rst1,query_rst2,query_rst3
where phone.sfzh=query_rst1.sfzh and phone.sfzh=query_rst2.sfzh and phone.sfzh=query_rst3.sfzh
the above data processing procedure is to further process the path execution statement.
And S106, the local database performs query processing on the external database based on the With execution statement in the data operation instruction.
In this embodiment, the following description of the path execution statement is used to process the SQL statement: "
WITH
query_rst1 AS(@@@MYSQL select sfzh,hphm from vehicle),
query_rst2 AS(@@@ORACLE select sfzh,hz from passport),
query_rst3 AS(@@@SQLSERVER select sfzh,sbkh from social_security)
select phone.sfzh,phone.sjh,query_rst1.hphm,query_rst2.hz,query_rst3.sbkh
from phone,query_rst1,query_rst2,query_rst3
where phone.sfzh=query_rst1.sfzh and phone.sfzh=query_rst2.sfzh and phone.sfzh=query_rst3.sfzh
Based on the statements, the query processing is carried out on the MYSQL database, the ORACLE database and the SQLSERVER database.
Further, executing the statement with the use includes: n with execution clauses, where N is a positive integer, step S106 may perform the following steps:
s1061, judging whether the N with execution clauses are executed or not by the local database, if so, entering a step S1065, otherwise, entering a step S1062;
s1062, the local database reads unexecuted with execution clauses in the N with execution clauses, judges whether the unexecuted with execution clauses have query characteristic character strings, if not, the step S1063 is carried out, otherwise, the step S1064 is carried out;
s1063, the local database utilizes unexecuted with execution clauses to perform creation execution processing on the local database according to a preset creation execution algorithm to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1064, the local database queries the external database corresponding to the query characteristic character string by using the query characteristic character string to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1065, the local database executes a SELECT statement of the preset temporary table, generates a query processing result, and deletes the temporary table.
In steps S1061-S1065, the With execution clause is 3 execution clauses, and if the With execution clauses are completely executed, all necessary data in the With statement in the external database are temporarily transferred to the local database, so that multi-table association of the local data table phone, the temporary table query _ rst1 (data from my), the temporary table query _ rst2 (data from ORACLE), and the temporary table query _ rst3 (data from QLSERVER) can be directly completed in the local database, thereby achieving the target of multi-database association, and then the temporary table query _ rst1, the temporary table query _ rst2, and the temporary table query _ rst3 are deleted.
And if the executing clauses of the with are not executed all together, reading the unexecuted executing clauses of the N executing clauses of the with, and judging whether the unexecuted executing clauses of the with have the query characteristic character string or not. If the query characteristic character string exists, for example, the first with executes a clause "query _ rst1 AS (@ @ @ MYSQL select sfzh, hpmm from driver)", the clause includes a clause "@ @ @ MYSQL" in the form of @ @ link _ name, finds the connection character string information "MYSQL/10.10.0.103" 2134/'usertest'/'123456'/'vehicle driving management archive base' "from the registry according to the connection name" MYSQL ", further establishes a connection with the database according to the connection character string information, obtains query sub-data, and writes the query sub-data into the query _ rst1 temporary table.
If the query feature character string does not exist, the with _ reference _ sql _ status statement "select sfzh, hpmm from vehicle" in the with execution clause is sent to the local target database for execution. And inquiring the subdata, and writing the inquired subdata into a query _ rst1 temporary table.
Returning to step S1061 in steps S1063 and S1064, the following steps are performed: and judging whether the N with execution clauses are all executed.
In step S1061, the same method is used to process the second with-execution clause "query _ rst2 AS (@ @ @ public ORACLE select sfzh, hz from passsport)" to generate local temporary table query _ rst2, and the third with-execution clause "query _ rst3 AS (@ @ SQLSERVER select sfzh, sbkh from social _ security)" to generate local temporary table query _ rst3, until all three with-statements are executed.
Further, step S1063 may perform the following steps:
s10631, the local database executes the corresponding relation between the clause and the external database based on the unexecuted with, and creates a temporary table in the local database;
s10632, the local database executes SQL instructions in the unexecuted with execution clauses in the external database corresponding to the unexecuted with execution clauses to generate with execution data;
s10633, the local database writes the execution data with the length into the temporary table to generate the query subdata.
In steps S10631-S10633, a new temporary table query _ rst1 is created in the local database (i.e., the master database). And sending a with _ reference _ sql _ statement "select sfzh, hpmm from _ statement" in the with execution clause to an external target database for execution, and writing a result set executed by the external target database into a temporary table of the query _ rst1 of the local database after compatibility adaptation conversion. For example, our sql example is modified to:
WITH
query_rst1 AS(select sfzh,hphm from vehicle),
query_rst2 AS(@@@ORACLE select sfzh,hz from passport),
query_rst3 AS(@@@SQLSERVER select sfzh,sbkh from social_security)
select phone.sfzh,phone.sjh,query_rst1.hphm,query_rst2.hz,query_rst3.sbkh
from phone,query_rst1,query_rst2,query_rst3
where phone.sfzh=query_rst1.sfzh and phone.sfzh=query_rst2.sfzh and phone.sfzh=query_rst3.sfzh
as above, query _ rst1 has no query feature string @ @ XXX, so its SQL statement selectsfzh, hphm from vehicle is executed in the local target library, and the data resulting from the execution is written into the temporary table query _ rst1.
Further, step S1064 may perform the following steps:
s10641, establishing a communication connection with an external database corresponding to the query characteristic character string by the local database, and establishing a temporary table of the external database corresponding to the query characteristic character string;
s10642, the local database executes the SQL instruction in the unexecuted with execution clause to the external database corresponding to the query characteristic character string, and generates with execution data;
s10643, the local database writes the execution data with the length into the temporary table to generate the query subdata.
In steps S10641-S10642, the unexecuted with execution clauses in the N with execution clauses are read, and it is determined whether the unexecuted with execution clauses have the query feature character string. If the query characteristic character string exists, for example, the first with executes the clause "query _ rst1 AS (@ @ @ MYSQL select sfzh, hphm from driver)", the with executes the clause containing the clause "@ @ @ MYSQL" in the form of @ @ link _ name, finds out the connection character string information "MYSQL/10.10.0.103" 2134/'usertest'/'123456'/'vehicle driving management archive base' "from the registry according to the connection name" MYSQL ", further establishes a connection with the database according to the connection character string information, obtains a with execution data, and writes the with execution data into a query _ rst1 temporary table to obtain query sub data.
In the embodiment of the invention, aiming at the requirement of 'multi-database integration' of the database, the SQL definition is expanded on the basis of the SQL standard, and a plurality of databases are integrated by the expanded SQL database, so that the technical problems of complex implementation process, high cost and complex application of the current subsection database integration are solved.
With reference to fig. 2, in the above description of the method for integrating a database according to the embodiment of the present invention, an embodiment of the apparatus for integrating a database according to the embodiment of the present invention includes:
an obtaining module 201, configured to obtain a data operation instruction by the local database, where the data operation instruction includes: connecting the database name and the SQL execution statement;
a first determining module 202, configured to determine, by the local database, whether the data operation instruction is an SQL operation instruction of the external database
The query module 203 is configured to query, by the local database, a connection character string in a preset database registration table according to the name of the external database;
the data operation module 204 is configured to establish, by the local database, a communication connection with an external database corresponding to the connection character string, and perform data operation processing on the external database according to the SQL execution statement to generate an operation result;
a second determining module 205, configured to determine, by the local database, whether a path execution statement exists in the data operation instruction;
and the data query module 206 is configured to query the external database by using the local database based on the path execution statement in the data operation instruction.
In the embodiment of the invention, aiming at the requirement of 'multi-database integration' of the database, the SQL definition is expanded on the basis of the SQL standard, and a plurality of databases are integrated by the expanded SQL database, so that the technical problems of complex implementation process, high cost and complex application of the current subsection database integration are solved.
Referring to fig. 3, in another embodiment of the database integration apparatus according to the embodiment of the present invention, the database integration apparatus includes:
an obtaining module 201, configured to obtain a data operation instruction by the local database, where the data operation instruction includes: connecting the database name and the SQL execution statement;
a first determining module 202, configured to determine, by the local database, whether the data operation instruction is an SQL operation instruction of the external database
The query module 203 is configured to query the local database for a connection character string in a preset database registration table according to the name of the external database;
the data operation module 204 is configured to establish a communication connection with an external database corresponding to the connection character string by the local database, perform data operation processing on the external database according to the SQL execution statement, and generate an operation result;
a second determining module 205, configured to determine, by the local database, whether a path execution statement exists in the data operation instruction;
and the data query module 206 is configured to query the external database by using the local database based on the path execution statement in the data operation instruction.
Wherein, the data query module 206 includes:
an execution judgment unit 2061, configured to judge, by the local database, whether the N with execution clauses have all been executed;
a characteristic determining unit 2062, configured to read, by the local database, an unexecuted with execution clause from the N with execution clauses, and determine whether the unexecuted with execution clause has a query characteristic character string;
a creating and querying unit 2063, configured to perform creating and executing processing on the local database by using the unexecuted with execution clause according to a preset creating and executing algorithm to obtain query subdata, and write the query subdata into a preset temporary table;
a feature query unit 2064, configured to query, by using the query feature string, an external database corresponding to the query feature string by the local database to obtain query subdata, and write the query subdata into a preset temporary table;
a result generating unit 2065, configured to execute a SELECT statement of a preset temporary table by the local database, generate a query processing result, and delete the temporary table.
The creating and querying unit 2063 is specifically configured to:
the local database creates a temporary table in the local database based on the corresponding relation between the unexecuted with execution clause and the external database;
the local database executes SQL instructions in the unexecuted with execution clauses in an external database corresponding to the unexecuted with execution clauses to generate with execution data;
and the local database writes the with execution data into the temporary table to generate query subdata.
The feature querying unit 2064 is specifically configured to:
the local database establishes communication connection with an external database corresponding to the query characteristic character string, and establishes a temporary table of the external database corresponding to the query characteristic character string;
the local database executes the SQL instruction in the unexecuted with execution clause to an external database corresponding to the query characteristic character string so as to generate with execution data;
and the local database writes the with execution data into the temporary table to generate query subdata.
The database integration apparatus further includes a registration deletion module 207, where the registration deletion module 207 is specifically configured to:
the local database judges whether the data operation instruction is a database registration instruction or not;
the local database adds an external database corresponding to the data operation instruction to a preset database registration table;
the local database judges whether the data operation instruction is a database deletion instruction or not;
and deleting the external database corresponding to the data operation instruction from a preset database registration table by the local database.
The integrated device of the database further includes a result feedback module 208, where the result feedback module 208 is specifically configured to:
the local database performs compatibility conversion processing on the operation result by using a preset compatibility algorithm to obtain result compatibility data;
and the local database sends the result compatible data to a port corresponding to the data operation instruction.
In the embodiment of the invention, aiming at the requirement of 'multi-database integration' of the database, on the basis of the SQL standard, the SQL definition is expanded, and a plurality of databases are integrated by the expanded SQL database, so that the technical problems of complex implementation process, higher cost and complex application of the current fractional database integration are solved.
Fig. 2 and fig. 3 describe the database integration apparatus in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the database integration apparatus in the embodiment of the present invention is described in detail from the perspective of the hardware processing.
Fig. 4 is a schematic structural diagram of an integrated device of a database, which may have a relatively large difference due to different configurations or performances, and the integrated device 400 of the database may include one or more processors (CPUs) 410 (e.g., one or more processors) and a memory 420, and one or more storage media 430 (e.g., one or more mass storage devices) for storing applications 433 or data 432. Memory 420 and storage medium 430 may be, among other things, transient storage or persistent storage. The program stored in the storage medium 430 may include one or more modules (not shown), each of which may include a series of instruction operations in the integrated device 400 for a database. Further, the processor 410 may be configured to communicate with the storage medium 430, and execute a series of instruction operations in the storage medium 430 on the database integration apparatus 400.
The database-based integrated device 400 may also include one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input-output interfaces 460, and/or one or more operating systems 431, such as Windows Server, mac OS X, unix, linux, freeBSD, and the like. Those skilled in the art will appreciate that the integrated device architecture of the database illustrated in fig. 4 does not constitute a limitation of integrated devices based on databases, and may include more or fewer components than those illustrated, or some components in combination, or a different arrangement of components.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when run on a computer, cause the computer to perform the steps of the database integration method.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses, and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
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, which is substantially or partly contributed by the prior art, or all or part of the technical solution may be embodied in 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 perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (9)

1. An integration method of a database, which is used for realizing data operation between a local database and an external database, and is characterized in that the integration method of the database comprises the following steps:
s101, the local database acquires a data operation instruction, wherein the data operation instruction comprises: connecting the database name and the SQL execution statement;
s102, the local database judges whether the data operation instruction is an SQL operation instruction of the external database, if the data operation instruction is the SQL operation instruction of the external database, the step S103 is executed, otherwise, the step S105 is executed;
s103, the local database queries a connection character string in a preset database registration table according to the name of the external database, and the step S104 is entered;
s104, the local database establishes communication connection with an external database corresponding to the connection character string, and performs data operation processing on the external database according to the SQL execution statement to generate an operation result;
s105, the local database judges whether the data operation instruction has a With execution statement, and if the With execution statement exists, the step S106 is carried out;
and S106, the local database performs query processing on the external database based on the With execution statement in the data operation instruction.
2. The method of integrating a database according to claim 1, wherein the executing a statement with the use includes: n with execution clauses, where N is a positive integer, and step S106 includes:
s1061, judging whether the N with execution clauses are executed or not by the local database, if so, entering a step S1065, otherwise, entering a step S1062;
s1062, the local database reads an unexecuted with execution clause in the N with execution clauses, judges whether the unexecuted with execution clause has a query characteristic character string, if not, the step S1063 is executed, otherwise, the step S1064 is executed;
s1063, the local database utilizes the unexecuted wit h execution clause to perform creation execution processing on the local database according to a preset creation execution algorithm to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1064, the local database queries an external database corresponding to the query characteristic character string by using the query characteristic character string to obtain query subdata, writes the query subdata into a preset temporary table, and returns to the step S1061;
s1065, the local database executes a SELECT statement of a preset temporary table, generates a query processing result, and deletes the temporary table.
3. The database integration method according to claim 2, wherein the step S1063 comprises:
s10631, the local database creates a temporary table in the local database based on the corresponding relation between the unexecuted with execution clause and the external database;
s10632, executing the SQL instruction in the unexecuted with execution clause by the local database in the external database corresponding to the unexecuted with execution clause to generate with execution data;
and S10633, writing the execution data with the use into the temporary table by the local database, and generating query subdata.
4. The method for integrating databases according to claim 2, wherein the step S1064 comprises:
s10641, the local database establishes a communication connection with the external database corresponding to the query feature character string, and establishes a temporary table of the external database corresponding to the query feature character string;
s10642, the local database executes the SQL instruction in the unexecuted with execution clause to the external database corresponding to the query characteristic character string, and generates with execution data;
s10643, the local database writes the execution data with the length into the temporary table to generate query subdata.
5. The method for integrating databases according to claim 1, wherein after step S101 and before step S102, the method further comprises:
s1011, the local database judges whether the data operation instruction is a database registration instruction, if so, the step S1012 is executed, otherwise, the step S1013 is executed;
s1012, the local database adds an external database corresponding to the data operation instruction to a preset database registration table;
s1013, the local database judges whether the data operation instruction is a database deletion instruction, if so, the step S1014 is executed, otherwise, the step S102 is executed;
and S1014, deleting the external database corresponding to the data operation instruction from a preset database registration table by the local database.
6. The method for integrating databases according to claim 1, further comprising, after the step S104:
s1041, the local database performs compatibility conversion processing on the operation result by using a preset compatibility algorithm to obtain result compatible data;
and S1042, the local database sends the result compatible data to a port corresponding to the data operation instruction.
7. An apparatus for integrating a database, which is used for implementing data operations between a local database and an external database, the apparatus comprising:
an obtaining module, configured to obtain a data operation instruction by the local database, where the data operation instruction includes: connecting the database name and the SQL execution statement;
a first judging module, configured to judge, by the local database, whether the data operation instruction is an SQL operation instruction of the external database
The query module is used for the local database to query a connection character string in a preset database registration table according to the name of the external database;
the data operation module is used for establishing communication connection between the local database and an external database corresponding to the connection character string, and performing data operation processing on the external database according to the SQL execution statement to generate an operation result;
the second judgment module is used for judging whether the data operation instruction has a With execution statement by the local database;
and the data query module is used for performing query processing on the external database by the local database based on the With execution statement in the data operation instruction.
8. An integration apparatus of a database, comprising: a memory having instructions stored therein and at least one processor, the memory and the at least one processor interconnected by a line;
the at least one processor invokes the instructions in the memory to cause an integration apparatus of the database to perform an integration method of the database according to any one of claims 1-6.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of integrating a database according to any one of claims 1 to 6.
CN202211414896.9A 2022-11-11 2022-11-11 Database integration method, device, equipment and storage medium Pending CN115658726A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211414896.9A CN115658726A (en) 2022-11-11 2022-11-11 Database integration method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211414896.9A CN115658726A (en) 2022-11-11 2022-11-11 Database integration method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115658726A true CN115658726A (en) 2023-01-31

Family

ID=85022100

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211414896.9A Pending CN115658726A (en) 2022-11-11 2022-11-11 Database integration method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115658726A (en)

Similar Documents

Publication Publication Date Title
US11216422B2 (en) Universal data management interface
US6466931B1 (en) Method and system for transparently caching and reusing query execution plans efficiently
US6163776A (en) System and method for exchanging data and commands between an object oriented system and relational system
US6587856B1 (en) Method and system for representing and accessing object-oriented data in a relational database system
CN1713179B (en) Impact analysis in an object model
US7822710B1 (en) System and method for data collection
US20010016843A1 (en) Method and apparatus for accessing data
CA2361523A1 (en) A system and method for accessing data stores as objects
CN112235311B (en) OVSDB client code automatic generation method, system, device and medium
US7509248B2 (en) Generic persistence engine
JP2001350656A (en) Integrated access method for different data sources
US7707211B2 (en) Information management system and method
US20060242167A1 (en) Object based test library for WinFS data model
US7945532B2 (en) System, and program product for rebasing an application
CN115658726A (en) Database integration method, device, equipment and storage medium
JP2022018435A (en) Data management apparatus and data management method
KR100505111B1 (en) The apparatus and method of creating program source for operating database and the computer program product using the same
CN116737113B (en) Metadata catalog management system and method for mass scientific data
CN116450609B (en) Method and equipment for modeling on heterogeneous data source based on unified grammar
CN111625581A (en) System data processing method adopting button to start service
JP2004259066A (en) Data source integrating program, system and method
CN116204598A (en) Java-based full-automatic object relation mapping method, system, equipment and storage medium
Copelli et al. Comandos Integration System (CIS)
KR20010059680A (en) Host db remote access apparatus
JP2001142759A (en) Method for performing access to file 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