Database table information detection method, device, computer equipment and storage medium

By integrating various types of database information into public detection components, connectivity testing of target databases and data table information detection are achieved, solving the problem of low detection efficiency caused by diversification of database systems in the prior art, and improving business performance.

CN113722325BActive Publication Date: 2024-12-31RUN TECH CO LTD BEIJING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111014952.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-31
Publication Date
2024-12-31
Estimated Expiration
2041-08-31

AI Technical Summary

Technical Problem

The prior art is difficult to effectively realize the detection of data table information in a diversified database system, affecting the efficient execution of business performance.

Method used

By integrating the corresponding information of each type of database into the public detection component, the connection test is carried out and the data table information is detected by obtaining the attribute parameter information of the target database.

Benefits of technology

On the premise of ensuring the accuracy of detection information, it saves database information detection time, improves data table information detection efficiency, and ensures efficient execution of business performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113722325B_ABST
    Figure CN113722325B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method, device, computer equipment and storage medium for detecting table information in a database. The method comprises: inputting the acquired target attribute parameter information of the target database into a pre-constructed information detection component, wherein the information detection component performs a connectivity test on the target database in combination with the attribute parameter information, and when the connectivity test result is determined to be connected, the table information of the data table in the target database is detected. Compared with the method of setting detection components for different databases to perform information detection in the prior art, this embodiment effectively saves the information detection time of the database while ensuring the accuracy of the detection information, thereby improving the detection efficiency of the data table information in the database, and further ensuring the efficient execution of the entire business performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular to a method, device, computer equipment and storage medium for detecting table information in a database. Background Art

[0002] A database is a warehouse that organizes, stores, and manages data according to data structures. With the development of information technology and the market, databases have evolved into more and more types. At the same time, various database management systems or platforms for data storage and management have also emerged, such as the currently more common Oracle database, MySQL database, postgresql database, DmDB database, and Gbase database.

[0003] In practical applications, there is often a need to obtain data information from a database, or to store calculated or determined data in a database. Generally, in order to ensure that the data to be stored is better compatible with the database, it is often necessary to understand the relevant characteristics of the data table in the database, such as the table structure of the data table and the data quality of the data table. The above information can be obtained by detecting the table information of the database, so that before the data is stored in the data table of the database, data processing can be performed based on the detection results, so that the data to be stored after processing is more consistent with the characteristics of the data table in the database.

[0004] The existing method of detecting data tables in a database often requires setting matching detection methods for different database systems. As a result, in the diverse scenarios presented by database systems, it is impossible to effectively detect data table information, thereby affecting the efficient execution of the entire business performance. Summary of the invention

[0005] The embodiments of the present invention provide a method, an apparatus, a computer device and a storage medium for detecting table information in a database, so as to enable a user to quickly detect table information of a data table in a target database.

[0006] In a first aspect, an embodiment of the present invention provides a method for detecting table information in a database, comprising:

[0007] Obtain target attribute parameter information of the target database;

[0008] Based on the pre-constructed information detection component combined with the attribute parameter information, a connectivity test is performed on the target database;

[0009] When it is determined that the connectivity test result is connected, the table information of the data table in the target database is detected.

[0010] In a second aspect, an embodiment of the present invention provides a device for detecting table information in a database, comprising:

[0011] A parameter information acquisition module is used to acquire target attribute parameter information of a target database;

[0012] A testing module, used to perform a connectivity test on the target database based on a pre-constructed information detection component combined with the attribute parameter information;

[0013] The table information detection module is used to detect the table information of the data table in the target database when it is determined that the connectivity test result is connected.

[0014] In a third aspect, an embodiment of the present invention provides a computer device, including:

[0015] one or more processors,

[0016] a storage device for storing one or more programs,

[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting table information in a database as described in the embodiment of the present invention.

[0018] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for detecting table information in a database as described in an embodiment of the present invention.

[0019] The technical solution of the embodiment of the present invention is to input the acquired target attribute parameter information of the target database into a pre-constructed information detection component, and the information detection component performs a connectivity test on the target database in combination with the attribute parameter information, and when it is determined that the connectivity test result is connected, the table information of the data table in the target database is detected. The above technical solution adopts a method of integrating the corresponding information of various types of databases into a common detection component (i.e., an information detection component). Compared with the method of setting detection components for different databases to perform information detection in the prior art, this embodiment effectively saves the information detection time of the database while ensuring the accuracy of the detection information, thereby improving the detection efficiency of the data table information in the database, and further ensuring the efficient execution of the entire business performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flow chart of a method for detecting table information in a database provided by Embodiment 1 of the present invention;

[0021] Figure 2 is a flow chart of a method for detecting table information in a database provided by Embodiment 2 of the present invention;

[0022] Figure 3 This is a flowchart for implementing table information detection in the method for detecting table information in a database provided in Embodiment 2 of the present invention;

[0023] Figure 4 It is a structural block diagram of a device for detecting table information in a database provided by Embodiment 3 of the present invention;

[0024] Figure 5 It is a structural diagram of a computer device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0025] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0026] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0027] Embodiment 1

[0028] Figure 1 It is a flowchart of the method for detecting table information in a database provided in the first embodiment of the present invention. This embodiment is applicable to the situation where table information in a database is detected before the data is stored in the database. The method can be executed by the device for detecting table information in a database provided in the embodiment of the present invention. The device can be implemented by software and / or hardware, and the device can be configured in a computer device.

[0029] like Figure 1 As shown, the database table information detection method specifically includes the following steps:

[0030] S110, obtaining target attribute parameter information of the target database.

[0031] In this embodiment, the target database is a warehouse that organizes, stores and manages data according to the data structure. It is a collection of a large amount of data that is stored in a computer for a long time, organized, shareable and uniformly managed. It should be noted that according to different types of databases, they can be divided into relational databases, non-relational databases and distributed databases. The embodiment of the present invention is applicable to relational databases. For example, the target database can be an oracle database (OracleDatabase, oracle), a mysql database (MySQL Database, mysql), a postgresql database (PostgreSQL Database, postgresql), a Dameng Database (Dm) and a Gbase database (Gbase Database, Gbase) and other databases.

[0032] In this embodiment, the target attribute parameter information may include database type, database Internet Protocol (IP) address, database port, database user name, database password, database name, and data table name.

[0033] Exemplarily, in the target attribute parameter information of the target database obtained in this step, the database type can be a relational database type such as oracle, mysql, postgresql, Dm, and Gbase. The database IP address can be the local host (localhost) or 127.0.0.1, the oracle port can be 1521, the mysql port can be 3306, the postgresql port can be 5432, the DmDB port can be 5236, and the Gbase port can be 5258. The user name can be root, the password can be 123456, and the database name can be "test". The embodiment of the present invention does not limit the database type, database IP address, database port, database user name, database password, and database name.

[0034] It should be noted that before using the database table information detection method provided by the embodiment of the present invention, the user may provide the target attribute parameter information of the target database to the execution subject by means of information editing.

[0035] S120: Perform a connectivity test on the target database based on a pre-constructed information detection component combined with the target attribute parameter information.

[0036] In an embodiment of the present invention, the information detection component may include a string concatenation function and a database connection function. The string concatenation function and the database connection function of the corresponding database may be integrated by judging the database type. The string concatenation function may concatenate the target attribute parameters according to the format of the connection string of the corresponding target database to form a connection string of the target database; the database connection function may perform a connectivity test on the corresponding target database based on the connection string concatenated by the string concatenation function.

[0037] In the embodiment of the present invention, the connectivity test may refer to a test of connectivity between the information detection component and the target database.

[0038] Exemplarily, first, the information detection component determines the database type in the target attribute parameter information, and then calls the string concatenation function of the corresponding database type. The string concatenation function concatenates the target attribute parameters according to the format of the connection string of the target database to obtain a concatenated connection string. Finally, the corresponding database connection function is called. The information detection component uses the concatenated connection string as input of the database connection function. Finally, the database connection function tests connectivity with the target database.

[0039] S130: When it is determined that the connectivity test result is connectivity, the table information of the data table in the target database is detected.

[0040] In this embodiment, when the connectivity test result is determined to be connected, it can be understood that the information detection component has established a connection with the target database, and the information detection component can perform a detection operation on the target database. It should be noted that the information detection component can also include a database detection function, and the database detection function can also integrate the database detection function of the corresponding database by judging the database type. The database detection function has the function of detecting the table structure and data in the data table of the target database.

[0041] In this embodiment, the table information may be information such as table structure and / or data status in the table, etc. The detection may be understood as querying, checking or probing the information of the data table in the target database.

[0042] Exemplarily, first, by judging the database type in the target attribute parameter information, the corresponding database connection function in the information detection component is called to test the connectivity with the target database. If the database connection function returns a connection object, the connectivity test result is determined to be connected. Then, the database detection function in the information detection component is called, and the returned connection object is used as the input of the corresponding database detection function. Finally, the database detection function queries the table structure of the data table in the database and the data in the table.

[0043] The technical solution of the embodiment of the present invention is to input the acquired target attribute parameter information of the target database into a pre-constructed information detection component, and the information detection component performs a connectivity test on the target database in combination with the attribute parameter information, and when it is determined that the connectivity test result is connected, the table information of the data table in the target database is detected. The above technical solution adopts a method of integrating the corresponding information of various types of databases into a common detection component (i.e., an information detection component). Compared with the method of setting detection components for different databases to perform information detection in the prior art, this embodiment effectively saves the information detection time of the database while ensuring the accuracy of the detection information, thereby improving the detection efficiency of the data table information in the database, and further ensuring the efficient execution of the entire business performance.

[0044] Specifically, an optional embodiment of the present invention can specifically express the target attribute parameter information of the target database as: database type, database name, database IP address, database port, database user name, database password and data table name; the information detection component can be specifically expressed as: information items to be filled in corresponding to the attribute parameter information of the database.

[0045] It is understandable that each type of database has a different filling format, and the filling format of each type of database contains information items to be filled. The attribute parameter information of each type of database can be used to fill the information items to be filled in the filling format of each type of database accordingly, so as to form the positioning string of each database. The positioning string can be a connection string of a computer programming language (java) database connection (java DataBase Connectivity, JDBC), and the positioning string is used to identify the location of the target database, and the JDBC is told which database to connect to through the positioning string. Among them, JDBC is a set of computer programming language (java) application programming interface (Application Programming Interface, API) for executing structured query language (Structured Query Language, SQL) statements, and the computer programming language (java) API allows users to access table information in any form, especially information stored in relational databases. JDBC realizes communication with various types of databases, can provide a unified access interface for multiple relational databases, and adapts to SQL statements to complete operations such as querying, updating and deleting data in the database. JDBC provides a benchmark, based on which more advanced tools and interfaces can be built, enabling database developers to write database applications. Specifically, users can use JDBC to establish a database connection, create SQL statements to execute, process execution results, and release resources.

[0046] It should be noted that the information detection component may have the following functions: the filling format of the corresponding type of database may be found according to the database type in the attribute parameter information of each type of database as a judgment condition, so as to form a positioning string of the corresponding type of database. Exemplarily, if the database type is an oracle database, the filling format of the oracle database may be "jdbc:oracle:thin:@item to be filled 1:item to be filled 2:item to be filled 3", the database IP address "127.0.0.1" in the attribute parameters of the database entered by the user may be filled into item 1 to be filled, the database port "1521" in the attribute parameters of the database may be filled into item 2 to be filled, and the database name "oracle database 1" in the attribute parameters of the database may be filled into item 3 to be filled, then the positioning string of the oracle database may be "jdbc:oracle:thin:@127.0.0.1:1521:oracle database 1". If the database type is MySQL database, then the filling format of the MySQL database can be "jdbc:mysql / / item to be filled in 1:item to be filled in 2: / item to be filled in 3". The database IP address "localhost" in the database's attribute parameters entered by the user can be filled in item 1 to be filled in, the database port "3306" in the database's attribute parameters can be filled in item 2 to be filled in, and the database name "mydb" in the database's attribute parameters can be filled in item 3 to be filled in. Then the positioning string of the MySQL database can be "jdbc:mysql: / / localhost:3306 / mydb".

[0047] In an optional embodiment of the first embodiment, the information detection component can obtain a corresponding filling format according to the attribute parameter information of each type of database input by the user, and can fill the attribute parameter information in the information item to be filled in the corresponding filling format to form a positioning string of the corresponding database. Thus, it has the effect of dynamically forming a positioning string of the target database according to the attribute parameter information of the target database input by the user.

[0048] Embodiment 2

[0049] Figure 2It is a flow chart of the method for detecting table information in a database provided by the second embodiment of the present invention. This embodiment is optimized based on the above embodiment. In the embodiment of the present invention, the target database can be tested for connectivity based on the pre-constructed information detection component combined with the target attribute parameter information. The specific optimization is as follows: constructing a target location string based on the target attribute parameter information; calling a given connectivity test function, combining the target location string, and performing a connectivity test on the target database and the information detection component; when the function return value is a set mark, determining that the connectivity test result of the connectivity test is connected.

[0050] At the same time, this second embodiment can also detect the table information of the data table in the target database, and the specific optimization is: obtain the target detection function corresponding to the target database when the connectivity test result is connected, and the target detection function is assembled in the information detection component; call the target detection function from the information detection component through a matching function interface, and use the target detection function to detect the table information of the data table in the target database.

[0051] like Figure 2 As shown, the method for detecting table information in a database provided by Embodiment 2 of the present invention specifically includes the following steps:

[0052] S210, obtaining target attribute parameter information of the target database.

[0053] S220: construct a target positioning character string based on the target attribute parameter information.

[0054] In the above operation, the information detection component can obtain the corresponding filling format according to the database type in the target attribute parameter information of the target database obtained by executing S210, and can fill the target attribute parameter information such as database IP address, database port and database name in the information items to be filled in the corresponding filling format to form a target positioning string corresponding to the target database.

[0055] S230, calling a given connectivity test function, combining the target positioning string, and performing a connectivity test on the target database and the information detection component.

[0056] In the above operation, the connectivity test function may be a getConnection() method in the DriverManager class in the JDBC computer programming language (java) API. DriverManager is a JDBC computer programming language (java) API, and DriverManager is used to load the JDBC driver and create a connection with the database. The getConnection() method in DriverManager is used to establish a connection with the database and return a connection object representing the connection.

[0057] Exemplarily, the connectivity test function may be Connection connection = DriverManager.getConnection (target location string, database user name, database password). It should be noted that S230 can obtain the database user name and database password in the target attribute parameter information of the target database according to executing S210 and executing S220 to obtain the target location string, and use them as parameters of the connectivity test function, and then call the connectivity test function to test the connectivity of the database located by the target location string.

[0058] S240: When the function return value is a set mark, determine that the connectivity test result of the connectivity test is connected.

[0059] In the above operation, the function return value may return an information prompt or a connection object. The connection object is returned by the getConnection() method in DriverManager.

[0060] In the above operation, the setting mark may be a connection object.

[0061] Exemplarily, when the function return value returns information such as "the database user name or database password does not exist" or "the network is not accessible, the connection has timed out", the connectivity test result of the connectivity test is determined to be failed; when the function return value returns a connection object representing the connection, the connectivity test result of the connectivity test is determined to be connected. Among them, the connection interface corresponding to the connection object has a series of methods, such as the getMetadata() method, which is used to return a databaseMetaData object of DatabaseMetaData representing the metadata of the database. Among them, DatabaseMetaData is a computer programming language (java) API of JDBC.

[0062] S250, when it is determined that the connectivity test result is connected, obtaining a target detection function of the target database when the connectivity test result is connected, wherein the target detection function is assembled in the information detection component.

[0063] It can be understood that by calling the connectivity test function to test the connectivity with the target database, when the connectivity test function returns a connection object, it is determined to be connected. At this time, the connection object returned by the connectivity test function is received by obtaining the target detection function in the information detection component corresponding to the target database.

[0064] S260, calling the target detection function from the information detection component through a matching function interface, and using the target detection function to detect table information of the data table in the target database.

[0065] It should be noted that the corresponding filling format can be found through the database type of the attribute parameter information of the target database, and the matching function interface can also be found. Specifically, first determine according to the database type in the attribute parameter information, find the corresponding filling format, fill in the items to be filled in the corresponding filling format, and form a target positioning string. At the same time, when the connectivity test function is called in combination with the database user name and database password of the attribute parameter information and the connectivity test result is connected, the target detection function of the target database can be obtained through the matching function interface. The matching function interface receives the connection object whose connectivity test result is connected returned by the connectivity test function, and transmits the received connection object to the obtained target detection function. At this time, the target detection function can detect the table structure or data in the table of the data table in the corresponding connected database.

[0066] In the embodiment of the present invention, a target positioning string is obtained according to the target attribute parameter information, and a given connectivity test function is called, and a connectivity test is performed on the target database in combination with the target positioning string. When the function return value is a set mark, the connectivity test result of the connectivity test is determined to be connected. The user's program is connected with the target database by inputting the target attribute parameter information of the target database, so as to provide a more effective method for connecting to the database; when connected with the target database, the corresponding target detection function of the target database is obtained from the information detection component through a matching function interface, and the table information of the data table in the target database is detected, so that the detection component can detect the table information of the data table in the target database.

[0067] It should be noted that executing S210, S220, S230 and S240 in Example 2 can realize the detection of the connectivity of the target database by the information detection component; executing S210, S220, S230, S240, S250 and S260 in Example 2 can realize the connectivity test of the target database and the detection of the target database by the information detection component.

[0068] Further, such as Figure 3 As shown, Figure 3 This is a flowchart for implementing table information detection in the method for detecting table information in a database provided in Embodiment 2 of the present invention. An optional embodiment of the present invention uses the target detection function to detect table information of a data table in the target database, which can be further optimized as follows:

[0069] S2601, obtaining data table name information of each data table included in the target database through the metadata object of the target database.

[0070] In the above operation, the metadata of the target database may be information defined by the database and data tables. It should be noted that the metadata object in this embodiment may be obtained by the getMetadata() method in the connection interface corresponding to the connection object returned when the connectivity test result of the connectivity test is connected. The method obtains the databaseMetaData object of the DatabaseMetaData of the metadata of the target database, and obtains the data table name information of each data table included in the target database through the getTables() method corresponding to the databaseMetaData object, and returns it as the tableNameResultSet object of ResultSet. ResultSet is the computer programming language (java) API of JDBC.

[0071] S2602: Determine the table structure information of the data table to be detected in the target database according to the data table name information.

[0072] It is understandable that, by using the acquired data table name information, the data table name of the data table to be detected is searched in the data table name information. If it can be found in the data table name information, the table structure information of the data table to be detected can be queried through the name of the data table to be detected. Among them, the table structure information may include information such as field name, field type and field length. It should be noted that the data table name of the data table to be detected can be obtained by executing S210.

[0073] S2603: Determine data attribute information of the data table to be detected by sampling data of the data table to be detected.

[0074] It is understandable that the data in the data table to be detected can be extracted. This embodiment does not limit the amount of data to be extracted, and the extracted data can be analyzed to obtain data attribute information of the data table to be detected.

[0075] For example, 1000 data items in the data table to be tested are extracted, and the specific values ​​of the data are filled in accordance with the requirements of the corresponding fields in the table structure, and analyzed according to the field names, so as to determine the data attribute information of the table to be tested, for example, the data with the most occurrences in each field.

[0076] In an optional embodiment of the present invention, the target detection function obtains the metadata object of the target database to obtain the data table name information of each data table included in the target database, and determines the table structure information of the data table to be detected in the target database based on the table name information, and determines the data attribute information of the data table to be detected by sampling the data of the data table to be detected. This solves the problem that users often query the table structure information of various types of databases and the data attribute information of data tables of various types of databases at a slow speed, and achieves the effect that users can perform more effective database detection based on the information detection component.

[0077] Specifically, an optional embodiment of the present invention determines the table structure information of the data table to be detected in the target database according to the data table name information, which can be optimized as follows:

[0078] a1. Determine a table name list of data tables included in the target database through the data table name information.

[0079] In this embodiment, the target detection function obtains the metadata databaseMetaData object of the target database, and obtains the data table name information of each data table included in the target database through the getTables() method corresponding to the databaseMetaData object, and returns it as a tableNameResultSet object of ResultSet. The tableNameResultSet can be traversed through a loop statement to obtain a table name list of the data tables of the target database.

[0080] b1, if the table name of the data table to be detected exists in the table name list, query the table structure information of the data table to be detected through the set first query statement, and the table structure information includes: field English name, field type, and field length.

[0081] In the above operation, the table name of the data table to be detected is obtained by user input, specifically, the name of the data table in the target attribute parameter information of the target database. If the table name of the data table to be detected is not in the table name list, a "table does not exist" message is prompted. Otherwise, if the table name of the data table to be detected exists in the table name list, the table structure information of the data table to be detected is queried through the set first query statement. The first query statement can be obtained through the getColumns() method corresponding to the databaseMetaData object to obtain the table structure information of the data table to be detected, and returned as a fieldResultSet object of Result, and the fieldResultSet can be traversed through a loop statement to obtain the table structure information. Among them, Result is the computer programming language (java) API of JDBC.

[0082] The table structure information includes: field English name, field type and field length. The field English name can be name 1 (field1), the field type can be integer (int), single-precision floating point type (float), data type that can accommodate a single character (char) and timestamp type (timestamp), etc. The field length can be 10, 16 and 7. In the embodiment of the present invention, there is no restriction on the field English name, field type and field length. As shown in Table 1.

[0083] Table 1: Table structure information of the data table in the database

[0084] Field English name Field Type Field length field1 int 10 field2 char 16 field3 timestamp 7 ......

[0085] In an optional embodiment of the present invention, the table name list of the data tables included in the target database is determined through the data table name information, and it is judged whether the table name of the data table to be detected exists in the table name list. If the table name of the data table to be detected exists in the table name list, the table structure information of the data table to be detected is queried through a set first query statement. This enables the information detection component to query the table structure information of the data table to be detected, so as to provide users with a more effective method for querying table structure information.

[0086] Specifically, an optional embodiment of the present invention determines the data attribute information of the data table to be detected by sampling the data of the data table to be detected, which can be optimized as follows:

[0087] a2, performing a traversal operation on the to-be-detected data table through a set second query statement to obtain sample data in the to-be-detected data table.

[0088] In the above operation, specifically, the second query statement may be a SQL query statement, which performs a traversal operation on the data table to be detected to obtain sampled data in the data table to be detected. The number of sampled data in the data table to be detected may be obtained by a preset value, for example, 2000, and the embodiment of the present invention does not limit the number of preset sampled data.

[0089] It can be understood that the content of each data item in the sampled data in the data table to be detected can be the value corresponding to the field type corresponding to the English name of the field. For example, the name 1 (field1), the corresponding field type is integer (int), then the corresponding data value can be 139, 23, 14 and 3, etc., and the embodiment of the present invention does not limit the data value of the integer (int) corresponding to the name 1 (field1); the name 2 (field2), the corresponding field type is a data type (char) that can accommodate a single character, then the corresponding data value can be Zhang San, Li Si, Wang Dongdong and Zhang San, etc., and the embodiment of the present invention limits the data value of the name 2 (field2), the corresponding data type that can accommodate a single character The data value of (char) is not restricted; the name 3 (field3), the corresponding field type is integer (int), then the corresponding data value can be 9, empty, 37 and 37, etc., and the embodiment of the present invention does not restrict the data value of the integer (int) corresponding to the name 3 (field3); the name 4 (field4), the corresponding field type is timestamp type (timestamp), then the corresponding data value can be 2021-08-02, 2021-07-12, 2021-07-12 and 2021-06-14, etc., and the embodiment of the present invention does not restrict the data value of the timestamp type (timestamp) corresponding to the name 4 (field4). As shown in Table 2.

[0090] Table 2 Data of the data table in the database

[0091] field1 field2 field3 field4 ...... 139 Zhang San 9 2021-08-02 23 Li Si 2021-07-12 14 Wang Dongdong 37 2021-07-12 3 Zhang San 37 2021-06-14 ......

[0092] b2. Determine data attribute information of the data table to be detected through a given information statistics strategy. The data attribute information includes: the highest frequency element information, minimum length value, maximum length value and cell filling rate of each field in the data table to be detected.

[0093] In the above operation, specifically, the sampled data in the data table to be detected are traversed through a loop statement, and the data attribute information of the data table to be detected is determined through a given information statistics strategy, wherein the data attribute information includes: the highest frequency element information, the minimum length value, the maximum length value and the cell fill rate of each field in the data table to be detected. Among them, the highest frequency element information can be the data value with the most occurrences in the field. The minimum length value can be the minimum length of all data values ​​in the field. The maximum length value can be the maximum length of all data values ​​in the field. The cell fill rate can be the percentage of the number of data values ​​contained in the cells in the field to the number of preset cells. Among them, the data attribute information can also include the maximum value and the minimum value in the data table to be detected, the maximum value can be the maximum value of all data values ​​in the field, and the minimum value can be the minimum value of all data values ​​in the field.

[0094] Exemplarily, name 1 (field1), the corresponding field type is integer (int), then the corresponding data values ​​can be 139, 23, 14 and 3, etc., then the data attribute information in the field name 1 (field1) in the data table to be detected can be: the element with the highest frequency of occurrence can be 3, 14, 23, the minimum length value can be 1, the maximum length value can be 3, the cell fill rate can be 100%, the maximum value can be 139, and the minimum value can be 3; name 2 (field2), the corresponding field type is a data type that can accommodate a single character (char), then the corresponding data values ​​can be Zhang San, Li Si, Wang Dongdong and Zhang San, etc., then the data attribute information in the field name 2 (field2) in the data table to be detected can be: the element with the highest frequency of occurrence can be Zhang San, the minimum length value can be 2, the maximum length value can be 3, the cell fill rate can be 100%, the maximum value is empty, and the minimum value is empty; name 3 (field3), the corresponding field type is integer (int), the corresponding data values ​​can be 9, empty, 37 and 37, etc., then the data attribute information in the field name 3 (field3) in the data table to be detected can be: the highest frequency element can be 37, the minimum length value can be 1, the maximum length value can be 2, the cell filling rate can be 75%, the maximum value can be 37, and the minimum value can be 9; name 4 (field4), the corresponding field type is the timestamp type (timestamp), then the corresponding data values ​​can be 2021-08-02, 2021-07-12, 2021-07-12 and 2021-06-14, etc., then the data attribute information in the field name 4 (field4) in the data table to be detected can be: the highest frequency element can be 2021-07-12, the minimum length value can be 7, the maximum length value can be 7, the cell filling rate can be 100%, the maximum value can be 2021-08-02, and the minimum value can be 2021-06-14. As shown in Table 3.

[0095] Table 3 Data attribute information of the data table in the database

[0096]

[0097] In an embodiment of the present invention, a traversal operation is performed on the data table to be detected through a set second query statement to obtain sample data in the data table to be detected, and data attributes of the data table to be detected are determined through a given information statistical strategy, so that the information detection component can query the data attributes of the data table to be detected, so as to provide users with data attribute information of data tables in a more effective query database.

[0098] It should be noted that a1 and b1 in Example 2 are executed to detect the table structure information of the data table in the target database through the information detection component. a1, b1, a2 and b2 in Example 2 can also be executed to detect the table structure information of the data table in the target database and determine the data attributes of the data table in the target database. Of course, the premise is that the information detection component has performed a connectivity test with the target database, and the connectivity test result of the information detection component and the target database is connected.

[0099] Embodiment 3

[0100] Figure 4 1 is a structural block diagram of a database table information detection device provided in Embodiment 3 of the present invention. The device can execute the database table information detection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. The device is configured in a computer device to implement the database table information detection method in the embodiment of the present invention. Figure 4 As shown, the device includes: a parameter information acquisition module 410, a test module 420 and a table information detection module 430.

[0101] The parameter information acquisition module 410 is used to acquire target attribute parameter information of the target database;

[0102] A testing module 420, configured to perform a connectivity test on the target database based on a pre-constructed information detection component combined with the attribute parameter information;

[0103] The table information detection module 430 is used to detect the table information of the data table in the target database when it is determined that the connectivity test result is connected.

[0104] The technical solution of the embodiment of the present invention is to input the acquired target attribute parameter information of the target database into a pre-constructed information detection component, and the information detection component performs a connectivity test on the target database in combination with the attribute parameter information, and when it is determined that the connectivity test result is connected, the table information of the data table in the target database is detected. The above technical solution adopts a method of integrating the corresponding information of various types of databases into a common detection component (i.e., an information detection component). Compared with the method of setting detection components for different databases to perform information detection in the prior art, this embodiment effectively saves the information detection time of the database while ensuring the accuracy of the detection information, thereby improving the detection efficiency of the data table information in the database, and further ensuring the efficient execution of the entire business performance.

[0105] In the above device, optionally, the target attribute parameter information of the target database includes: database type, database name, database IP address, database port, database user name, database password and data table name;

[0106] The information detection component includes: information items to be filled corresponding to the attribute parameter information of the database.

[0107] In the above device, optionally, the testing module 420 is specifically used for:

[0108] Constructing a target positioning character string based on the target attribute parameter information;

[0109] Calling a given connectivity test function, combining the target positioning string, and performing a connectivity test on the target database and the information detection component;

[0110] When the function return value is the set mark, it is determined that the connectivity test result of the connectivity test is connected.

[0111] In the above device, optionally, the table information detection module 430 includes a function acquisition unit and a detection unit:

[0112] The function acquisition unit is used to acquire a target detection function of the target database when the connectivity test result is connectivity, and the target detection function is assembled in the information detection component;

[0113] The detection unit is used to call the target detection function from the information detection component through a matching function interface, and use the target detection function to detect the table information of the data table in the target database.

[0114] In the above device, optionally, the detection unit includes: a table name acquisition subunit, a table structure determination subunit and a data attribute determination subunit:

[0115] The table name acquisition subunit is used to acquire data table name information of each data table included in the target database through the metadata object of the target database;

[0116] The table structure determination subunit is used to determine the table structure information of the data table to be detected in the target database according to the data table name information;

[0117] The data attribute determination subunit is used to determine the data attribute information of the data table to be detected by sampling the data of the data table to be detected.

[0118] In the above device, optionally, the table structure determination subunit is specifically used for:

[0119] The step of determining the table structure information of the to-be-detected data table in the target database according to the data table name information includes:

[0120] Determine a table name list of data tables included in the target database through the data table name information;

[0121] If the table name of the data table to be detected exists in the table name list, the table structure information of the data table to be detected is queried through the set first query statement, and the table structure information includes: field English name, field type, and field length.

[0122] In the above device, optionally, the data attribute determination subunit is specifically used for:

[0123] Performing a traversal operation on the to-be-detected data table through a set second query statement to obtain sample data in the to-be-detected data table;

[0124] The data attribute information of the data table to be detected is determined by a given information statistics strategy, and the data attribute information includes: the highest occurrence frequency element information, the minimum length value, the maximum length value and the cell filling rate of each field in the data table to be detected.

[0125] The above-mentioned product can execute the method for detecting table information in a database provided by the embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.

[0126] Implementation Four

[0127] A fourth embodiment of the present invention provides a computer device. Figure 5 Schematic diagram of the structure of a computer device provided by Embodiment 4 of the present invention. Figure 5 As shown, this embodiment provides a computer device, which may include: a processor and a storage device. The storage device stores at least one instruction, and the instruction is executed by the processor, so that the computer device executes the database table information detection method described in the above method embodiment.

[0128] Reference Figure 5 The computer device may specifically include: a processor 510, a storage device 520, an input device 530, and an output device 540; the number of the processor 510 in the computer device may be one or more. Figure 5 In the example, a processor 510 is used; the number of storage devices 520 in the computer device may be one or more. Figure 5 A storage device 520 is taken as an example. The processor 510, storage device 520, input device 530 and output device 540 in the computer device can be connected via a bus or other means. Figure 5The example of connecting through bus is taken in the following.

[0129] Specifically, in the embodiment, when the processor 510 executes one or more programs stored in the storage device 520, the following operations can be implemented: obtaining target attribute parameter information of the target database; performing a connectivity test on the target database based on a pre-constructed information detection component combined with the target attribute parameter information; and when it is determined that the connectivity test result is connected, detecting the table information of the data table in the target database.

[0130] The database table information detection device, computer device and storage medium provided in the above embodiments can execute the database table information detection method provided in any embodiment of the present invention, and have the corresponding functional modules and beneficial effects of executing the method. For technical details not described in detail in the above embodiments, please refer to the database table information detection method provided in any embodiment of the present invention.

[0131] Embodiment 5

[0132] Embodiment 5 of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, a method for detecting table information in a database as provided in all embodiments of the present invention is implemented. The method includes: obtaining target attribute parameter information of a target database; performing a connectivity test on the target database based on a pre-constructed information detection component in combination with the target attribute parameter information; and when it is determined that the connectivity test result is connected, detecting the table information of the data table in the target database.

[0133] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0134] Computer-readable signal media may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable program code. Such propagated data signals may take a variety of forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0135] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0136] Computer program code for performing the operations of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0137] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for detecting table information in a database, characterized in that: include: Obtain target attribute parameter information of the target database; Based on the pre-constructed information detection component combined with the target attribute parameter information, the target database is tested for connectivity; wherein the information detection component includes a string concatenation function and a database connection function; the string concatenation function concatenates the target attribute parameters according to the format of the connection string of the corresponding target database to form a connection string of the target database, and the database connection function performs a connectivity test on the corresponding target database based on the connection string concatenated by the string concatenation function; When it is determined that the result of the connectivity test is connected, the table information of the data table in the target database is detected; when it is determined that the result of the connectivity test is connected, the table information of the data table in the target database is detected, including: the information detection component also includes a database detection function, the database detection function integrates the database detection function of the corresponding database by judging the database type, and detects the table structure and data in the data table in the target database.

2. The method according to claim 1, characterized in that The target attribute parameter information of the target database includes: database type, database name, database IP address, database port, database user name, database password and data table name; The information detection component includes: information items to be filled corresponding to the attribute parameter information of the database.

3. The method according to any one of claims 1 or 2, characterized in that: Based on the pre-constructed information detection component combined with the target attribute parameter information, the target database is tested for connectivity, including: Constructing a target positioning character string based on the target attribute parameter information; Calling a given connectivity test function, combining the target positioning string, and performing a connectivity test on the target database and the information detection component; When the function return value is the set mark, it is determined that the connectivity test result of the connectivity test is connected.

4. The method according to claim 1, characterized in that: The detecting of the table information of the data table in the target database includes: Acquire a target detection function of the target database when the connectivity test result is connectivity, wherein the target detection function is assembled in the information detection component; The target detection function is called from the information detection component through a matching function interface, and the target detection function is used to detect the table information of the data table in the target database.

5. The method according to claim 4, characterized in that The using the target detection function to detect the table information of the data table in the target database includes: Obtaining data table name information of each data table included in the target database through the metadata object of the target database; Determine the table structure information of the data table to be detected in the target database according to the data table name information; The data attribute information of the data table to be detected is determined by sampling the data of the data table to be detected.

6. The method according to claim 5, characterized in that The step of determining the table structure information of the to-be-detected data table in the target database according to the data table name information includes: Determine a table name list of data tables included in the target database through the data table name information; If the table name of the data table to be detected exists in the table name list, the table structure information of the data table to be detected is queried through the set first query statement, and the table structure information includes: field English name, field type, and field length.

7. The method according to claim 5, characterized in that The step of determining data attribute information of the data table to be detected by sampling data of the data table to be detected includes: Performing a traversal operation on the to-be-detected data table through a set second query statement to obtain sample data in the to-be-detected data table; The data attribute information of the data table to be detected is determined by a given information statistics strategy, and the data attribute information includes: the highest occurrence frequency element information, the minimum length value, the maximum length value and the cell filling rate of each field in the data table to be detected.

8. A device for detecting table information in a database, characterized in that: include: A parameter information acquisition module is used to acquire target attribute parameter information of a target database; A test module, for performing a connectivity test on the target database based on a pre-constructed information detection component in combination with the attribute parameter information; wherein the information detection component comprises a string concatenation function and a database connection function; the string concatenation function concatenates the target attribute parameters according to the format of the connection string of the corresponding target database to form a connection string of the target database, and the database connection function performs a connectivity test on the corresponding target database based on the connection string concatenated by the string concatenation function; A table information detection module is used to detect the table information of the data table in the target database when the connectivity test result is determined to be connected; when the connectivity test result is determined to be connected, the table information of the data table in the target database is detected, including: the information detection component also includes a database detection function, the database detection function integrates the database detection function of the corresponding database by judging the database type, and detects the table structure and data in the data table in the target database.

9. A computer device, characterized in that: include: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for detecting table information in a database as described in any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for detecting table information in a database as described in any one of claims 1 to 7 is implemented.