CN114840551A - Database table processing method and device, electronic equipment and storage medium - Google Patents

Database table processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114840551A
CN114840551A CN202210580495.4A CN202210580495A CN114840551A CN 114840551 A CN114840551 A CN 114840551A CN 202210580495 A CN202210580495 A CN 202210580495A CN 114840551 A CN114840551 A CN 114840551A
Authority
CN
China
Prior art keywords
query
database table
field
name
target database
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
CN202210580495.4A
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202210580495.4A priority Critical patent/CN114840551A/en
Publication of CN114840551A publication Critical patent/CN114840551A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/248Presentation of query results
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The invention relates to the field of databases, and provides a method and a device for processing a database table, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a database name, a database table name and a field name to be inquired; searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name; and if receiving a query instruction for querying the field content in the target database table according to at least one query condition, responding to the query instruction to obtain a query result and outputting the query result. The scheme provided by the invention solves the technical problems that the existing database table query scheme needs a large amount of query codes for support and has no universality.

Description

Database table processing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the field of databases, in particular to a method and a device for processing a database table, electronic equipment and a storage medium.
Background
In each system using a relational database, the development of single-table data queries is almost ubiquitous. The method comprises the steps that single-table data in a conventional JAVA data layer mybatis framework are queried, and each single table basically corresponds to an xml file and a database entity in a dynamic SQL (structured query language) mode configured by xml; when the object is not oriented, corresponding SQL statements need to be written in each XML file to query fields in a database table, and if newly added fields, deleted fields and the like cannot be dynamically deleted, the fields, conditions and the like in the XML need to be manually deleted; in object-oriented Query, common object-oriented Query methods such as criterion of Hibernate and Query warp in mybatis plus do not need to write a large amount of SQL when querying a single table, but a large amount of object-oriented Query codes need to be written, and a large amount of Query codes are still needed to support the object-oriented Query.
Therefore, the existing database table query scheme needs a large amount of query codes to support and has no technical problem of universality.
Disclosure of Invention
In view of the above problems, the present invention provides a method and an apparatus for processing a database table, an electronic device, and a storage medium, so as to at least solve the technical problem that the existing database table query scheme requires a large number of query codes for support and has no universality.
According to a first aspect of the invention, a method for processing a database table is provided, which comprises the following steps: acquiring a database name, a database table name and a field name to be inquired; searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name; and if receiving a query instruction for querying the field content in the target database table according to at least one query condition, responding to the query instruction to obtain a query result and outputting the query result.
Optionally, the searching, from a plurality of databases, a target database table containing the database table name and one or more field contents corresponding to the field name according to the database name includes: and searching a target database from the databases according to the database names, searching a basic database table from the target database according to the database table names, and screening the target database table containing one or more field contents corresponding to the field names from the basic database table according to the field names to be queried by calling query sentences.
Optionally, after searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name, the method further includes: and if the query instruction for querying the field content in the target database table according to the at least one query condition is not received, taking the target database table as the query result and outputting the target database table.
Optionally, before obtaining the query result in response to the query instruction, the method further includes: splicing one or more query conditions by adopting a condition constructor to obtain spliced query conditions; encapsulating a function for querying field contents in the target database table according to the spliced query conditions into corresponding operation classes; wherein the query condition comprises at least one of: the system comprises a field screening condition used for screening one or more field contents in the target database table, a sorting condition used for sorting the one or more field contents in the target database table, and a paging condition used for paging the target database table.
Optionally, the obtaining a query result in response to the query instruction includes: inquiring a corresponding operation class according to at least one inquiry condition in the inquiry instruction; calling an operation class corresponding to the at least one query condition; and querying the field content in the target database table by executing the function in the corresponding operation class.
Optionally, the responding to the query instruction includes at least one of: if the at least one query condition does not contain a field screening condition, querying all field contents in the target database by default; if the at least one query condition does not contain a sorting condition, sorting the field contents in the target database according to a default sorting condition; and if the at least one query condition does not contain a paging condition, paging the target database table according to a default paging condition.
Optionally, before outputting the query result, the method further comprises: rendering the query result according to a data format corresponding to the data set containing the key value so as to output the target database table with a universal data format.
According to a second aspect of the present invention, there is provided a processing apparatus of a database table, comprising: the acquisition module is used for acquiring a database name, a database table name and a field name to be inquired; the searching module is used for searching a target database table which comprises the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name; and the response module is used for responding to the query instruction to obtain a query result and outputting the query result when receiving the query instruction for querying the field content in the target database table according to at least one query condition.
Optionally, the search module includes: and the first execution unit is used for sequentially executing searching of a target database from the plurality of databases according to the database names by calling query statements, searching of a basic database table from the target database according to the database table names, and screening of the target database table containing one or more field contents corresponding to the field names from the basic database table according to the field names to be queried.
Optionally, the apparatus further comprises: and the output module is used for taking the target database table as the query result and outputting the target database table when a query instruction for querying the field content in the target database table according to the at least one query condition is not received after the search module searches the target database table comprising the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name.
Optionally, the apparatus further comprises: the splicing unit is used for splicing one or more query conditions by adopting a condition constructor before the response module responds to the query instruction to obtain a query result, so as to obtain the spliced query conditions; the packaging unit is used for packaging a function for querying the field content in the target database table according to the spliced query conditions into a corresponding operation class; wherein the query condition comprises at least one of: the method comprises the following steps of screening one or more field contents in a target database table, sorting one or more field contents in the target database table, and paging one or more field contents in the target database table.
Optionally, the response module includes: the first query unit is used for querying the corresponding operation class according to at least one query condition in the query instruction; the calling unit is used for calling the operation class corresponding to the at least one query condition; and the second execution unit is used for inquiring the field content in the target database table by executing the function in the corresponding operation class.
Optionally, the response module comprises at least one of the following operations: a second query unit, configured to query all field contents in the target database by default if the at least one query condition does not include the field screening condition; a third query unit, configured to rank, if the at least one query condition does not include a ranking condition, field contents in the target database according to a default ranking condition; and the fourth query unit is used for paging the target database table according to a default paging condition if the at least one query condition does not contain the paging condition.
Optionally, the apparatus further comprises: and the rendering module is used for rendering the query result according to a data format corresponding to the data set containing the key value before outputting the query result so as to output the target database table with a universal data format.
According to a third aspect of the present invention, there is also provided an electronic device comprising a memory having a computer program stored therein and a processor arranged to run the computer program to perform the steps in any of the above method embodiments.
According to a fourth aspect of the present invention, there is also provided a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps in any of the apparatus embodiments described above when executed.
Firstly, acquiring a database name, a database table name and a field name to be inquired; then, searching a target database table containing database table names and one or more field contents corresponding to the field names from the plurality of databases according to the database names, so that the selection of the database table and the table fields is realized; if an inquiry instruction for inquiring the field content in the target database table according to at least one inquiry condition is received, the inquiry instruction is responded to obtain an inquiry result, the inquiry result is output, the fields in the database table can be inquired according to the inquiry condition of any combination, and codes such as repeated SQL or a large number of field conditions which are written down by the same SQL under different scenes can be avoided; and because the table and the field are obtained in real time and are the latest table information, the problem that SQL or codes need to be repeatedly modified after the field is added or deleted is avoided, and the universality is realized, so that the technical problem that the existing database table query scheme needs a large amount of query codes for support and does not have the universality is solved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart of a processing method of a database table according to an embodiment of the invention;
FIG. 2 is a block diagram of a processing apparatus for a database table according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that such uses are interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the term "include" and its variants are to be read as open-ended terms meaning "including, but not limited to".
In order to solve the technical problems in the related art, the present embodiment provides a method for processing a database table. The following describes the technical solution of the present invention and how to solve the above technical problems with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a processing method of a database table according to an embodiment of the present invention, and as shown in fig. 1, the flowchart includes the following steps:
step S102, obtaining a database name, a database table name and a field name to be inquired;
in this embodiment, the database name is an identification name named when the database is created, and operations on the database in an SQL (structured query language) statement all depend on the database name to identify a specific database; the database table names are names of single tables in the database, and the names of the single tables in different databases can be the same or different; when a database table is queried, a specified target database table can be queried from a plurality of databases by making clear database names, database table names and field names to be queried.
Alternatively, the query may be obtained by configuring the database name, the database table name, and the field name to be queried in the front end. Because the table and the field are obtained in real time and are the latest table information, the problems that SQL or codes need to be repeatedly modified after the field is added or deleted can be solved.
Step S104, searching a target database table containing database table names and one or more field contents corresponding to the field names from a plurality of databases according to the database names;
in a possible implementation manner of the present disclosure, the step S104 specifically includes: and calling the query statement, sequentially searching a target database from the plurality of databases according to the database name, searching a basic database table from the target database according to the database table name, and screening the target database table containing one or more field contents corresponding to the field name from the basic database table according to the field name to be queried.
In this embodiment, by setting an SQL statement and then executing the SQL statement, a required database can be screened from a plurality of databases according to the database name; then, screening a required basic database table from the screened database; and then, screening the fields in the basic database table according to the field names to be queried, thereby screening out a target database table only comprising one or more field contents corresponding to the field names to be queried.
In an alternative embodiment, if the field name to be queried is not configured, a query is made for all fields in the base database table by default.
According to the embodiment, object query under different service scenes or different function conditions does not need to be considered, writing of a large number of SQL statements is avoided, and the database tables meeting user requirements can be flexibly screened from various databases.
And step S106, if receiving a query instruction for querying the field content in the target database table according to at least one query condition, responding to the query instruction to obtain a query result and outputting the query result.
The processing method of the database table provided by the embodiment of the invention comprises the following steps of firstly, obtaining a database name, a database table name and a field name to be inquired; then, searching a target database table containing database table names and one or more field contents corresponding to the field names from the plurality of databases according to the database names, so that the selection of the database table and the table fields is realized; if an inquiry instruction for inquiring the field content in the target database table according to at least one inquiry condition is received, the inquiry instruction is responded to obtain an inquiry result, the inquiry result is output, the fields in the database table can be inquired according to the inquiry condition of any combination, and codes such as repeated SQL or a large number of field conditions which are written down by the same SQL under different scenes can be avoided; and because the table and the field are obtained in real time and are the latest table information, the problem that SQL or codes need to be repeatedly modified after the field is added or deleted is avoided, and the universality is realized, so that the technical problem that the existing database table query scheme needs a large amount of query codes for support and does not have the universality is solved.
A possible implementation manner is provided in the embodiment of the present invention, and after step S104, the method further includes: and if the query instruction for querying the field content in the target database table according to at least one query condition is not received, taking the target database table as a query result and outputting the target database table. In this embodiment, if an instruction for querying the field contents in the target database table is not received, that is, all the field contents in the target database table need to be queried by default, and then the target database table is output.
The embodiment of the present invention provides a possible implementation manner, before obtaining a query result in response to a query instruction, the implementation manner further includes: splicing one or more query conditions by adopting a condition constructor to obtain spliced query conditions; encapsulating a function for querying field contents in a target database table according to the spliced query conditions into corresponding operation classes; wherein the query condition comprises at least one of: the method comprises the following steps of screening one or more field contents in a target database table by using a field screening condition, sequencing one or more field contents in the target database table by using a sequencing condition and paging condition for paging the target database table.
In the embodiment of the invention, on the basis of a DAO layer framework depending on mybatiplus at the bottom layer, the function of a query list table is developed based on the function of object-oriented query of QueryWarper (namely the condition constructor) in mybatiplus; the QueryWarper is a function encapsulation operation class for realizing query in mybatisplus, namely an encapsulated SQL object, and comprises a where condition (playing a function of specifying a query filtering condition in a single table query statement), an order by sorting (sorting the result according to a specified column or sorting the records according to an ascending order by default), which fields are selected by a select, which fields are added newly, which fields are deleted and the like, and the selection of a database table, the selection of table fields, the self-defined screening condition (namely the field screening condition), the self-defined sorting condition, the self-defined query mode, the self-defined paging condition, the rendering of a general return format, the addition of fields, the deletion of fields and the like can be realized through the QueryWarper; by the embodiment, once the fields, conditions and the like in the XML are not required to be deleted manually in the situations of adding the fields, deleting the fields and the like, the operations such as dynamic deletion can be realized, and the flexibility of list processing is improved.
Wherein the field screening conditions include at least, but not limited to, equal to, not equal to, less than equal to, greater than equal to, containing, not containing, beginning with, not beginning with, ending with, null (unknown), null, non-null, between, in, notin, ASC, DESC, etc.; screening one or more fields in the target database table by using the preset screening conditions;
sorting conditions, namely sorting one or more fields in the target database table according to sorting modes such as positive order, reverse order and the like by using the sorting conditions;
the query mode at least comprises deduplication query, count query and common data query; inquiring the target database table according to a preset inquiry mode;
paging condition, which indicates how many pieces of data in each page the page number is queried. For example, a 10-row list in page 5 is queried, that is, for each viewed page, the field contents corresponding to 10 lists in the current page are displayed on a display interface at the front end;
and (4) rendering in a universal return format, namely performing format rendering on the query result so as to express the query result into a universal data format.
Optionally, obtaining a query result in response to the query instruction includes: inquiring the corresponding operation class according to at least one inquiry condition in the inquiry instruction; calling an operation class corresponding to at least one query condition; and querying the field content in the target database table by executing the function in the corresponding operation class.
In an example of this embodiment, according to a query condition list defined by a user, circularly querying an operation class encapsulated in advance at a back end, then executing a queryWrapper function corresponding to a query condition configured in advance in the operation class, and performing field query in a target database table according to the defined query condition list; in this embodiment, the queryWrapper objects of mybatisplus are chain-packed together.
For example, according to a user-defined sorting condition list, circularly inquiring an operation class configured in advance at the rear end, adjusting the operation class and executing a queryWrapper field screening function and a sorting rule function in the operation class to sort the fields.
For another example, according to the user-defined query paging condition information, the corresponding operation class is called, and the queryWrapper paging function in the operation class is executed, so as to page the fields in the target database table.
In the existing single table query scheme, the following SQL statements are written in each xml file: SELECT [ table field ] FROM [ table name ] WHERE [ CONDITION ] [ LIMIT ], and in different service scenarios or functions, SQL statements corresponding to queried fields, screening CONDITIONs, sorting and paging may be different, and a large amount of SQL is needed to support single table query work in different service scenarios or functions; if the newly added fields, the deleted fields and the like can not be dynamically deleted, the fields, the conditions, the sequencing and other conditions in the xml are manually deleted; in addition, if the front end uses the field, the field also needs to be synchronously changed, single-table query is not flexible, a large amount of SQL statement support is needed, and operation is complex. According to the embodiment, various query conditions are packaged through QueryWarper in mybatisplus, and a corresponding database table can be screened from a corresponding database according to the table name and the field to be queried; after receiving the query instruction through the front end, the screened database table is queried according to various query conditions set by the front end by calling various corresponding functions, and a query result is output, so that the flexibility of database table query is improved.
In one possible implementation of the present disclosure, the response to the query instruction includes at least one of: if the at least one query condition does not contain the field screening condition, defaulting all field contents in the query target database; if the at least one query condition does not contain a sorting condition, sorting the field contents in the target database according to a default sorting condition; if the at least one query condition does not include a paging condition, paging the target database table according to a default paging condition.
In this embodiment, if the at least one query condition does not include the screening condition of the table field, the target database table is subjected to full-table query by default, and the queryWrapper function of mybatiplus without any screening condition is to query all fields in the database table; if at least one query condition does not contain a sorting condition, default unconditional sorting, namely default queryWrapper objects without any sorting condition mybatisplus; if at least one query condition does not contain a paging condition, defaulting to a non-paging condition, or defaulting to a queryWrapper function of 10 mybatiplus per page for query, and the like, so that the flexibility of query of the database table is improved.
In a possible implementation manner of the present disclosure, before outputting the query result, the method further includes: and rendering the query result according to the data format corresponding to the data set containing the key value so as to output a target database table with a universal data format.
In this embodiment, the query result is rendered into a common return format, and the result is returned. Therefore, various database tables in various databases are rendered into a universal data format. For example, a two-dimensional set, for example, a key-value, is represented as follows:
[{key,value},{key,value},{key,value},{key,value}……]
[{key,value},{key,value},{key,value},{key,value}……]
[{key,value},{key,value},{key,value},{key,value}……]
[{key,value},{key,value},{key,value},{key,value}……]
……;
each key (field name), value (field content) is the following object, and all tables can be constructed and shown by the same structure, except that the number of the keys and the values are different, and the values corresponding to the keys and the values are different. In this embodiment, the front end can complete page rendering only by writing a set of unified double-layer circulation logic, different rendering logics do not need to be written according to different return structures corresponding to different tables, and the front end and the back end can complete rendering of the front-end page dynamic data table without modifying even after the structure of the back-end table is changed.
Through the implementation steps, all fields in the database table can be queried, sorted and paged according to the defined query conditions, different query condition sets are defined by users, and logic assembled by using the same conditions can be suitable for querying all single tables in the system; the flexibility of single table query is greatly improved, the logic of the single table query of each different table is completely unnecessary to be written repeatedly in the process of querying different single tables, and conditions, query fields, sorting rules, query modes, paging conditions and the like can be selected by self to query in the process of querying the same table; therefore, codes such as repeated SQL or a large number of dead written fields of the same SQL and the like under a large number of different scenes are avoided, because the tables and the fields are obtained in real time and are the latest table information, the SQL or the codes are prevented from being repeatedly modified after the fields are added or deleted, and compared with the traditional scheme, the method is high in universality and can be dynamically changed; and finally, the queries of different tables return the same data structure uniformly, the object with the finest granularity contains two attributes of key and value, the key represents the field name, the value represents the field content, a plurality of fine-grained objects form a line of data, and a plurality of lines form the full-scale data of the table.
Based on the processing method of the database table provided in the foregoing embodiments, and based on the same inventive concept, the present embodiment further provides a processing apparatus of a database table, where the apparatus is used to implement the foregoing embodiments and preferred embodiments, and the description of the apparatus has been already made, and is not repeated. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 2 is a block diagram of a structure of a processing apparatus for a database table according to an embodiment of the present invention, as shown in fig. 2, the apparatus includes: the acquiring module 20 is used for acquiring a database name, a database table name and a field name to be inquired; a searching module 22, connected to the obtaining module 20, for searching a target database table containing database table names and one or more field contents corresponding to the field names from the plurality of databases according to the database names; and the response module 24 is connected to the search module 22, and is configured to, when receiving a query instruction for querying field contents in the target database table according to at least one query condition, obtain a query result in response to the query instruction, and output the query result.
Optionally, the search module 22 includes: and the first execution unit is used for sequentially executing searching of a target database from the plurality of databases according to the database names, searching of a basic database table from the target database according to the database table names and screening of the target database table containing one or more field contents corresponding to the field names from the basic database table according to the field names to be queried by calling the query statement.
Optionally, the apparatus further comprises: and the output module is used for taking the target database table as a query result and outputting the target database table when a query instruction for querying the field content in the target database table according to at least one query condition is not received after the search module searches the target database table containing the database table name and one or more field contents corresponding to the field name from the plurality of databases according to the database name.
Optionally, the apparatus further comprises: the splicing unit is used for splicing one or more query conditions by adopting the condition constructor before the response module responds to the query instruction to obtain a query result, so as to obtain the spliced query conditions; the packaging unit is used for packaging a function for querying the field content in the target database table according to the spliced query conditions into a corresponding operation class; wherein the query condition comprises at least one of: the method comprises the following steps of screening one or more field contents in a target database table by using a field screening condition, sequencing one or more field contents in the target database table by using a sequencing condition and paging condition for paging the target database table.
Optionally, the response module 24 comprises: the first query unit is used for querying the corresponding operation class according to at least one query condition in the query instruction; the calling unit is used for calling an operation class corresponding to at least one query condition; and the second execution unit is used for inquiring the field content in the target database table by executing the function in the corresponding operation class.
Optionally, the response module 24 includes at least one of the following operations: the second query unit is used for defaulting and querying all field contents in the target database if the at least one query condition does not contain the field screening condition; the third query unit is used for sequencing the field contents in the target database according to a default sequencing condition if the at least one query condition does not contain the sequencing condition; and the fourth query unit is used for paging the target database table according to the default paging condition if the paging condition is not contained in the at least one query condition.
Optionally, the apparatus further comprises: and the rendering module is used for rendering the query result according to the data format corresponding to the data set containing the key value before outputting the query result so as to output a target database table with a universal data format.
It should be noted that, the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
Alternatively, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
s1, acquiring a database name, a database table name and a field name to be inquired;
s2, searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name;
and S3, if receiving a query instruction for querying the field content in the target database table according to at least one query condition, responding to the query instruction to obtain a query result, and outputting the query result.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Based on the above embodiments of the method shown in fig. 1 and the apparatus shown in fig. 2, in order to achieve the above object, an embodiment of the present invention further provides an electronic device, as shown in fig. 3, including a memory 32 and a processor 31, where the memory 32 and the processor 31 are both disposed on a bus 33, the memory 32 stores a computer program, and the processor 31 implements a processing method of the database table shown in fig. 1 when executing the computer program.
Based on such understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a memory (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute the method according to the implementation scenarios of the present invention.
Optionally, the device may also be connected to a user interface, a network interface, a camera, Radio Frequency (RF) circuitry, sensors, audio circuitry, a WI-FI module, and so forth. The user interface may include a Display screen (Display), an input unit such as a keypad (Keyboard), etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (e.g., a bluetooth interface, WI-FI interface), etc.
It will be understood by those skilled in the art that the structure of an electronic device provided in this embodiment is not limited to the physical device, and may include more or fewer components, or some components in combination, or different arrangements of components.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again.
It will be apparent to those skilled in the art that the modules or steps of the present invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A processing method of a database table is characterized by comprising the following steps:
acquiring a database name, a database table name and a field name to be inquired;
searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name;
and if receiving a query instruction for querying the field content in the target database table according to at least one query condition, responding to the query instruction to obtain a query result and outputting the query result.
2. The method of claim 1, wherein searching the plurality of databases for a target database table containing the database table name and one or more field contents corresponding to the field name according to the database name comprises:
and searching a target database from the databases according to the database names, searching a basic database table from the target database according to the database table names, and screening the target database table containing one or more field contents corresponding to the field names from the basic database table according to the field names to be queried by calling query sentences.
3. The method of claim 1, wherein after searching a target database table from a plurality of databases according to the database name, the target database table containing the database table name and one or more field contents corresponding to the field name, the method further comprises:
and if the query instruction for querying the field content in the target database table according to the at least one query condition is not received, taking the target database table as the query result and outputting the target database table.
4. The method of claim 1, wherein prior to obtaining query results in response to the query instruction, the method further comprises:
splicing one or more query conditions by using a condition constructor to obtain spliced query conditions;
encapsulating a function for querying field contents in the target database table according to the spliced query conditions into corresponding operation classes; wherein the query condition comprises at least one of: the method comprises the following steps of screening one or more field contents in a target database table, sorting one or more field contents in the target database table, and paging one or more field contents in the target database table.
5. The method of claim 4, wherein obtaining query results in response to the query instruction comprises:
inquiring a corresponding operation class according to at least one inquiry condition in the inquiry instruction;
calling an operation class corresponding to the at least one query condition;
and querying the field content in the target database table by executing the function in the corresponding operation class.
6. The method of claim 4 or 5, wherein said responding to said query instruction comprises at least one of:
if the at least one query condition does not contain a field screening condition, querying all field contents in the target database by default;
if the at least one query condition does not contain a sorting condition, sorting the field contents in the target database according to a default sorting condition;
and if the at least one query condition does not contain a paging condition, paging the target database table according to a default paging condition.
7. The method of any of claims 1-5, wherein prior to outputting the query result, the method further comprises:
rendering the query result according to a data format corresponding to the data set containing the key value so as to output the target database table with a universal data format.
8. A database table processing apparatus, comprising:
the acquisition module is used for acquiring a database name, a database table name and a field name to be inquired;
the search module is used for searching a target database table containing the database table name and one or more field contents corresponding to the field name from a plurality of databases according to the database name;
and the response module is used for responding to the query instruction to obtain a query result and outputting the query result when receiving the query instruction for querying the field content in the target database table according to at least one query condition.
9. An electronic device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A storage medium having a computer program stored thereon, the computer program, when being executed by a processor, realizing the steps of the method of any one of claims 1 to 7.
CN202210580495.4A 2022-05-26 2022-05-26 Database table processing method and device, electronic equipment and storage medium Pending CN114840551A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210580495.4A CN114840551A (en) 2022-05-26 2022-05-26 Database table processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210580495.4A CN114840551A (en) 2022-05-26 2022-05-26 Database table processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114840551A true CN114840551A (en) 2022-08-02

Family

ID=82572390

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210580495.4A Pending CN114840551A (en) 2022-05-26 2022-05-26 Database table processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114840551A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117874133A (en) * 2023-12-19 2024-04-12 广州极点三维信息科技有限公司 Mass data storage processing method, system, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117874133A (en) * 2023-12-19 2024-04-12 广州极点三维信息科技有限公司 Mass data storage processing method, system, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107391744B (en) Data storage method, data reading method, data storage device, data reading device and equipment
CN111367976B (en) Method and device for exporting EXCEL file data based on JAVA reflection mechanism
CN111797073A (en) Database management method, electronic device, and computer-readable storage medium
CN114564620A (en) Graph data storage method and system and computer equipment
CN113918605A (en) Data query method, device, equipment and computer storage medium
CN110597851B (en) Big data based data processing and report display method
CN114840551A (en) Database table processing method and device, electronic equipment and storage medium
CN110928900B (en) Multi-table data query method, device, terminal and computer storage medium
CN112835638A (en) Configuration information management method and device based on embedded application program
CN112084250A (en) Data storage method, data query method and electronic equipment
CN115617338A (en) Method and device for quickly generating service page and readable storage medium
CN109063215B (en) Data retrieval method and device
CN107977459B (en) Report generation method and device
US20050210011A1 (en) Computer implemented method for retrieving hit count data from a data base system and according computer program product
CN108241624B (en) Query script generation method and device
US20200301922A1 (en) Multiform persistence abstraction
CN114385657A (en) Data storage method, device and storage medium
CN111897812A (en) Data query method and device, electronic equipment and computer readable storage medium
CN112527917A (en) Data processing method and device
CN117909301B (en) Index-based object query method, device, equipment and medium
CN107729013B (en) Method for managing operation buttons on web page and computer-readable storage medium
CN117688008A (en) Metadata integrated management method and device
CN117056414A (en) Method, system, computer and storage medium for rapidly displaying data
CN116108060A (en) Data merging query method, device, equipment and medium
CN114385664A (en) Splitting method, system, device and storage medium for single project micro-service

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