WO2021042532A1 - Database information analysis method and apparatus, computer apparatus, and storage medium - Google Patents

Database information analysis method and apparatus, computer apparatus, and storage medium Download PDF

Info

Publication number
WO2021042532A1
WO2021042532A1 PCT/CN2019/117416 CN2019117416W WO2021042532A1 WO 2021042532 A1 WO2021042532 A1 WO 2021042532A1 CN 2019117416 W CN2019117416 W CN 2019117416W WO 2021042532 A1 WO2021042532 A1 WO 2021042532A1
Authority
WO
WIPO (PCT)
Prior art keywords
database table
database
data
data column
column
Prior art date
Application number
PCT/CN2019/117416
Other languages
French (fr)
Chinese (zh)
Inventor
王保军
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021042532A1 publication Critical patent/WO2021042532A1/en

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/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity

Definitions

  • This application relates to the field of information analysis technology, and in particular to a database information analysis method, device, computer device, and non-volatile readable storage medium.
  • a first aspect of the present application provides a database information analysis method, the method includes: obtaining a SQL file of a software project; extracting all first data columns in the SQL file and a first database where the first data columns are located Table; query all the second data columns in the database connected to the software project and the second database table where the second data column is located; determine whether the first database table is included in the second database table; if If the first database table is not included in the second database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column contains In the second data column, and determine whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the In the second data column, and/or the first database table in which the first data column is located is inconsistent with the second database table in which the second data column is located, then the output exists in the first data column and the A data column that does not exist in the second data column, and/or a first data column that
  • the second aspect of the present application provides a database information analysis device, the device includes: an acquisition module for acquiring SQL files of a software project; an extraction module for extracting all first data columns and all data in the SQL file The first database table where the first data column is located; a query module for querying all the second data columns in the database connected to the software project and the second database table where the second data column is located; first judgment module , Used to determine whether the first database table is included in the second database table; a first output module, used to output the first database table if the first database table is not included in the second database table A database table that exists in the first database table but does not exist in the second database table; a second judgment module for judging whether the first data column is included in the second data column, and judging the first data column Whether the first database table where a data column is located is consistent with the second database table where the second data column is located; the second output module is configured to, if the first data column is not included in the second data column, And/or the first database table where the first data column
  • a third aspect of the present application provides a computer device, the computer device includes a processor, and the processor is configured to implement the database information analysis method when executing computer-readable instructions stored in a memory.
  • a fourth aspect of the present application provides a non-volatile readable storage medium having computer readable instructions stored thereon, and when the computer readable instructions are executed by a processor, the database information analysis method is implemented.
  • This application realizes the analysis and correction of the database information of the software project.
  • Fig. 1 is a flowchart of a method for analyzing database information provided by an embodiment of the present application.
  • Figure 2 is a structural diagram of a database information analysis device provided by an embodiment of the present application.
  • Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present application.
  • the database information analysis method of the present application is applied to one or more computer devices.
  • the computer device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions.
  • Its hardware includes, but is not limited to, a microprocessor and an application specific integrated circuit (ASIC) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), embedded equipment, etc.
  • ASIC application specific integrated circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Processor
  • embedded equipment etc.
  • the computer device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the computer device can interact with the user through a keyboard, a mouse, a remote control, a touch panel, or a voice control device.
  • FIG. 1 is a flowchart of a method for analyzing database information provided in Embodiment 1 of the present application.
  • the database information analysis method is used to analyze and modify the database information of the software project.
  • the database information analysis method includes:
  • SQL is a database query and programming language used to access data in the database, query, update and manage the database.
  • a SQL file configuration interface can be generated, the software project path set by the user in the SQL file configuration interface can be received, and the SQL file can be obtained according to the software project path.
  • the software project path may be D: ⁇ eclipse ⁇ workspaces.
  • the obtaining the SQL file according to the software project path may include: traversing all files of the software project under the software project path, and obtaining the files from all the files of the software project. SQL file. All files of the software project under the software project path can be traversed recursively.
  • Each folder of the software project may contain subfolders and/or files; if the folder contains subfolders, continue to traverse; if the folder contains files, it is determined whether the file is an SQL file; If the file is a SQL file, save the SQL file.
  • the SQL file may be an XML (Extensible Markup Language, Extensible Markup Language) file.
  • the SQL file may include SQL statements.
  • the SQL file is testMapper.xml, and the file includes SQL statements. SQL statements are statements used to operate on the database.
  • the target code can be searched according to the tags in the SQL file; the first data column and the first database table can be extracted according to the keywords in the target code.
  • the target code may include SQL statements, stored procedures, triggers, and so on.
  • the SQL statement is used to perform operations such as adding, deleting, modifying, and querying database tables/data columns.
  • the keywords in the target code are "select", " from", "where”.
  • "Name” and “id” are the first data columns
  • "tbl_student” is the first database table where the first data columns "name” and "id” are located.
  • the first list may be generated according to the first data column and the first database table.
  • the first list may also include field information such as database, database user name, stored procedure, and trigger.
  • the first list may be generated in a preset order.
  • the first list is generated according to the first alphabetical order of the first data column or the first database table.
  • all the second data columns in the database connected to the software project and the second database table where the data columns are located can be queried in the following manner: obtain the data source information of the software project; according to the data The source information establishes a connection with the database; an SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
  • the data source information is the configuration information for creating the database connection, and may include a database user name, a database login password, a link string, a driver class, and the like.
  • the database user name is represented as "username”
  • the database login password is represented as "password”
  • the driver class is represented as "oracle.jdbc.driver.OracleDriver”
  • the link string is represented as "jdbc:oracle:thin:@127.0.0.1: DEV”.
  • a second list may be generated according to the second data column and the second database table.
  • the second list may also include field information such as database, database user name, stored procedure, and trigger.
  • the second list may be generated in a preset order.
  • the second list is generated according to the first alphabetical order of the second data column or the second database table.
  • the inclusion of the first database table in the second database table means that each database table in the first database table is included in the second database table.
  • the first database table includes Table1, Table2, Table3, and Table4, and the second database table includes Table1, Table2, Table3, Table4, and Table5, the first database table is included in the second database table. .
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, Table4, and Table5
  • the first database table is included in the second Database table.
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, and Table4
  • the first database table is not included in the second database. Table.
  • the COMPARE method may be used to compare the first database table in the first list with the second database table in the second list to determine whether the first database table is consistent with the second database table. If the first database table is consistent with the second database table, it is determined that the first database table is included in the second database table.
  • the database table that exists in the first database table but does not exist in the second database table represents a database table that is incorrectly used by the software project.
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, and Table4, and the first database table is not included in the second database table.
  • a database table error prompt or a database table error notification can be sent.
  • the database table error prompt can be issued by voice or text.
  • the notification of the database table error can be sent to the preset contact by means of email, short message, WeChat, etc.
  • the database tables that exist in the second database table but not in the first database table represent database tables that are not used by the software project. Outputting the database tables existing in the second database table but not in the first database table can remind the user to confirm whether the database table information is incorrect.
  • the inclusion of the first data column in the second data column means that each data column in the first data column is included in the second data column.
  • the first data column includes Line1, Line2, Line3, Line4, and the second data column includes Line1, Line2, Line3, Line4, Line5, then the first data column is included in the second data column .
  • the first data column includes Line1, Line2, Line3, Line4, Line5
  • the second data column includes Line1, Line2, Line3, Line4, then the first data column is not included in the second data column.
  • the COMPARE method may be used to compare the first data column in the first list with the second data column in the second list to determine whether the first data column is consistent with the second data column. If the first data row is consistent with the second data row, it is determined that the first data row is included in the second data row.
  • the first database table where the first data column is located is consistent with the second database table where the second data column is located means that the first database table where each first data column is located is the same as the first database table where the second data column is located.
  • the two database tables are consistent.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column Line3 is The first database table is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second database where the second data column Line1 is located.
  • the table is Table1, the second database table where the second data column Line2 is located is Table2, the second database table where the second data column Line3 is located is Table3, and the second database table where the second data column Line4 is located is Table4, then the second database table where the second data column Line4 is located is Table4.
  • the first database table where a data column is located is consistent with the second database table where the second data column is located.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4; the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4, then The first database table where the first data column is located is inconsistent with the second database table where the second data column is located.
  • the second database table where the second data column is located is the same.
  • first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located. Then output data columns that exist in the first data column but do not exist in the second data column, and/or the first database table where the output is located is inconsistent with the second database table where the second data column is located.
  • the first data column includes Line1, Line2, Line3, Line4, Line5
  • the second data column includes Line1, Line2, Line3, Line4, and the first data column is not included in the second data column.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4.
  • the first database table where a data column is located is not consistent with the second database table where the second data column is located, and the first data column where the first database table where the second data column is located is inconsistent with the second database table where the second data column is located is output.
  • the data string error prompt can be issued by voice or text.
  • the notification of the data column error can be sent to the preset contact by means of email, SMS, WeChat, etc.
  • the order of 104, 105 and 106, 107 can be interchanged.
  • the database table is judged first.
  • the data column may be judged first.
  • first database table is not included in the second database table, or the first data column is not included in the second data column, or the first database where the first data column is located If the table is inconsistent with the second database table where the second data column is located, a table structure file of the database is generated.
  • the table structure file of the database indicates all the database tables and database columns contained in the database, and the correspondence between the database columns and the database tables.
  • the method is applied to Java, and generating the table structure file of the database may include:
  • the java entity class is a concept widely used in JAVA software development.
  • the java entity class is a class containing Set and Get methods, and can usually be associated with a database.
  • the database script is generated when the database and the database tables in the database are created.
  • the database script may contain one or more data tables. Parsing the database script into the corresponding java entity class means parsing and packaging the database script into the java entity class corresponding to the one or more data tables. Specifically, the database tables contained in the database script can be identified, and the data information contained in each database table can be parsed and packaged into a corresponding java entity class. In other words, each java entity class corresponds to a data table in the database script, and one or more corresponding java entity classes can be obtained by parsing one database script.
  • the database script can be exported through a set tool (such as PowerDesigner).
  • the database script can be exported according to the received database command.
  • the style of the table structure file can be set according to actual needs. For example, set the styles of multiple data table titles (including fonts, display positions, etc.), and multiple table structure styles (including table size, fill color, data display format, etc.).
  • the table structure file may include database tables, table remarks, data columns, data column remarks, data column types, and so on.
  • tableName is used for database table
  • tableComment is used for table comment
  • columName is used for data column
  • columComment is used for data column comment
  • columType is used for data column. Types of.
  • the corresponding table structure file generated according to the java entity class corresponding to the database script also contains multiple data table structures.
  • Modifying the SQL file according to the table structure file means modifying the database tables that exist in the first database table but not in the second database table in the SQL file, and/or modifying the SQL file Data columns that exist in the first data column but not in the second data column, and/or modify the first database table where the SQL file is located and the second database table where the second data column is located Inconsistent first data column.
  • the structure file searches for a replacement database table for a database table that exists in the first database table but does not exist in the second database table, and searches for data that exists in the first data column but does not exist in the second data column
  • the replacement database column of the column, the replacement database table replaces the database table that exists in the first database table in the SQL file but does not exist in the second database table
  • the replacement database column replaces the SQL A data column that exists in the first data column but does not exist in the second data column in the file.
  • the replacement database table and the replacement database column may be determined according to the table remarks, data column remarks, data column type, etc. in the table structure file.
  • the second data table corresponding to the inconsistent first data column may be searched according to the table structure file, The second data table corresponding to the inconsistent first data column is substituted for the first data table in the SQL file where the inconsistent first data column is located.
  • the database information analysis method of the first embodiment obtains the SQL file of the software project; extracts all the first data columns in the SQL file and the first database table where the first data columns are located; and queries the database connected to the software project All the second data columns and the second database table where the data columns are located; determine whether the first database table is included in the second database table; if the first database table is not included in the second database table In the database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column is included in the second data column, and determine whether the Whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the second data column, and/or the first data column is If the first database table where a data column is located is inconsistent with the second database table where the second data column is located, output data columns that exist in the first data column but not in the second data column, and/ Or output a first data column that is inconsistent with the second database table where the
  • the embodiment analyzes the database information of the software project.
  • the database information used by the software project is inconsistent with the actual database information of the database
  • the database information of the software project is corrected, thereby reducing the inconsistency between the database information used by the software project and the actual database information of the database. The risk of improving software quality.
  • Fig. 2 is a structural diagram of a database information analysis device provided in the second embodiment of the present application.
  • the database information analysis device 20 is applied to a computer device, and is used to analyze and correct the database information of the software project.
  • the database information analysis device 20 may include an acquisition module 201, an extraction module 202, a query module 203, a first judgment module 204, a first output module 205, a second judgment module 206, and a second output module 207 , The generation module 208, the correction module 209.
  • the obtaining module 201 is used to obtain SQL (Structured Query Language, structured query language) files of the software project.
  • SQL is a database query and programming language used to access data in the database, query, update and manage the database.
  • a SQL file configuration interface can be generated, the software project path set by the user in the SQL file configuration interface can be received, and the SQL file can be obtained according to the software project path.
  • the software project path may be D: ⁇ eclipse ⁇ workspaces.
  • the obtaining the SQL file according to the software project path may include: traversing all files of the software project under the software project path, and obtaining the files from all the files of the software project. SQL file. All files of the software project under the software project path can be traversed recursively.
  • Each folder of the software project may contain subfolders and/or files; if the folder contains subfolders, continue to traverse; if the folder contains files, determine whether the file is an SQL file; If the file is a SQL file, save the SQL file.
  • the SQL file may be an XML (Extensible Markup Language, Extensible Markup Language) file.
  • the SQL file may include SQL statements.
  • the SQL file is testMapper.xml, and the file includes SQL statements. SQL statements are statements used to operate on the database.
  • the extraction module 202 is configured to extract all the first data columns in the SQL file and the first database table where the first data columns are located.
  • the target code can be searched according to the tags in the SQL file; the first data column and the first database table can be extracted according to the keywords in the target code.
  • the target code may include SQL statements, stored procedures, triggers, and so on.
  • the SQL statement is used to perform operations such as adding, deleting, modifying, and querying database tables/data columns.
  • the keywords in the target code are "select", " from", "where”.
  • "Name” and “id” are the first data columns
  • "tbl_student” is the first database table where the first data columns "name” and "id” are located.
  • the first list may be generated according to the first data column and the first database table.
  • the first list may also include field information such as database, database user name, stored procedure, and trigger.
  • the first list may be generated in a preset order.
  • the first list is generated according to the first alphabetical order of the first data column or the first database table.
  • the query module 203 is configured to query all the second data columns in the database connected to the software project and the second database table where the second data columns are located.
  • all the second data columns in the database connected to the software project and the second database table where the data columns are located can be queried in the following manner: obtain the data source information of the software project; according to the data The source information establishes a connection with the database; an SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
  • the data source information is the configuration information for creating a database connection, and may include a database user name, a database login password, a link string, a driver category, and the like.
  • the database user name is represented as "username”
  • the database login password is represented as "password”
  • the driver class is represented as "oracle.jdbc.driver.OracleDriver”
  • the link string is represented as "jdbc:oracle:thin:@127.0.0.1: DEV”.
  • a second list may be generated according to the second data column and the second database table.
  • the second list may also include field information such as database, database user name, stored procedure, and trigger.
  • the second list may be generated in a preset order.
  • the second list is generated according to the first alphabetical order of the second data column or the second database table.
  • the first judgment module 204 is configured to judge whether the first database table is included in the second database table.
  • the inclusion of the first database table in the second database table means that each database table in the first database table is included in the second database table.
  • the first database table includes Table1, Table2, Table3, and Table4, and the second database table includes Table1, Table2, Table3, Table4, and Table5, the first database table is included in the second database table. .
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, Table4, and Table5
  • the first database table is included in the second Database table.
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, and Table4
  • the first database table is not included in the second database. Table.
  • the COMPARE method may be used to compare the first database table in the first list with the second database table in the second list to determine whether the first database table is consistent with the second database table. If the first database table is consistent with the second database table, it is determined that the first database table is included in the second database table.
  • the first output module 205 is configured to output a database table that exists in the first database table but does not exist in the second database table if the first database table is not included in the second database table.
  • the database table that exists in the first database table but does not exist in the second database table represents a database table that is incorrectly used by the software project.
  • the first database table includes Table1, Table2, Table3, Table4, and Table5
  • the second database table includes Table1, Table2, Table3, and Table4, and the first database table is not included in the second database table.
  • a database table error prompt or a database table error notification can be sent.
  • the database table error prompt can be issued by voice or text.
  • the notification of the database table error can be sent to the preset contact by means of email, short message, WeChat, etc.
  • the database tables that exist in the second database table but not in the first database table represent database tables that are not used by the software project. Outputting the database tables existing in the second database table but not in the first database table can remind the user to confirm whether the database table information is incorrect.
  • the second determining module 206 is configured to determine whether the first data column is included in the second data column, and whether the first database table in which the first data column is located is the same as the one in which the second data column is located. The second database table is consistent.
  • the inclusion of the first data column in the second data column means that each data column in the first data column is included in the second data column.
  • the first data column includes Line1, Line2, Line3, Line4, and the second data column includes Line1, Line2, Line3, Line4, Line5, then the first data column is included in the second data column .
  • the first data column includes Line1, Line2, Line3, Line4, Line5
  • the second data column includes Line1, Line2, Line3, Line4, then the first data column is not included in the second data column.
  • the COMPARE method may be used to compare the first data column in the first list with the second data column in the second list to determine whether the first data column is consistent with the second data column. If the first data row is consistent with the second data row, it is determined that the first data row is included in the second data row.
  • the first database table where the first data column is located is consistent with the second database table where the second data column is located means that the first database table where each first data column is located is the same as the first database table where the second data column is located.
  • the two database tables are consistent.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column Line3 is The first database table is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second database where the second data column Line1 is located.
  • the table is Table1, the second database table where the second data column Line2 is located is Table2, the second database table where the second data column Line3 is located is Table3, and the second database table where the second data column Line4 is located is Table4, then the second database table where the second data column Line4 is located is Table4.
  • the first database table where a data column is located is consistent with the second database table where the second data column is located.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4; the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4, then The first database table where the first data column is located is inconsistent with the second database table where the second data column is located.
  • the second database table where the second data column is located is the same.
  • the second output module 207 is configured to: if the first data column is not included in the second data column, and/or the first database table where the first data column is located and the second data column are located If the second database table is inconsistent, output data columns that exist in the first data column but not in the second data column, and/or the first database table where the output is located and the second data column where the second data column is located are output. Second, the first data column inconsistent in the database table.
  • the first data column includes Line1, Line2, Line3, Line4, Line5
  • the second data column includes Line1, Line2, Line3, Line4, and the first data column is not included in the second data column.
  • the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4.
  • the first database table where a data column is located is not consistent with the second database table where the second data column is located, and the first data column where the first database table where the second data column is located is inconsistent with the second database table where the second data column is located is output.
  • the data string error prompt can be issued by voice or text.
  • the notification of the data column error can be sent to the preset contact by means of email, SMS, WeChat, etc.
  • the database table is judged first.
  • the data column may be judged first.
  • the generating module 208 is configured to: if the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first data column is located If the first database table of is inconsistent with the second database table where the second data column is located, a table structure file of the database is generated.
  • the table structure file of the database indicates all the database tables and database columns contained in the database, and the correspondence between the database columns and the database tables.
  • the method is applied to Java, and generating the table structure file of the database may include:
  • the java entity class is a concept widely used in JAVA software development.
  • the java entity class is a class containing Set and Get methods, and can usually be associated with a database.
  • the database script is generated when the database and the database tables in the database are created.
  • the database script may contain one or more data tables. Parsing the database script into the corresponding java entity class means parsing and packaging the database script into the java entity class corresponding to the one or more data tables. Specifically, the database tables contained in the database script can be identified, and the data information contained in each database table can be parsed and packaged into a corresponding java entity class. In other words, each java entity class corresponds to a data table in the database script, and one or more corresponding java entity classes can be obtained by parsing one database script.
  • the database script can be exported through a set tool (such as PowerDesigner).
  • the database script can be exported according to the received database command.
  • the style of the table structure file can be set according to actual needs. For example, set the style of multiple data table headings (including font, display position, etc.), and the style of multiple table structure (including table size, fill color, data display format, etc.).
  • the table structure file may include database tables, table remarks, data columns, data column remarks, data column types, and so on.
  • tableName is used for database table
  • tableComment is used for table comment
  • columName is used for data column
  • columComment is used for data column comment
  • columType is used for data column. Types of.
  • the corresponding table structure file generated according to the java entity class corresponding to the database script also contains multiple data table structures.
  • the correction module 209 is configured to correct the SQL file according to the table structure file.
  • Modifying the SQL file according to the table structure file means modifying the database tables that exist in the first database table but not in the second database table in the SQL file, and/or modifying the SQL file Data columns that exist in the first data column but not in the second data column, and/or modify the first database table where the SQL file is located and the second database table where the second data column is located Inconsistent first data column.
  • the structure file searches for a replacement database table for a database table that exists in the first database table but does not exist in the second database table, and searches for data that exists in the first data column but does not exist in the second data column
  • the replacement database column of the column, the replacement database table replaces the database table that exists in the first database table in the SQL file but does not exist in the second database table
  • the replacement database column replaces the SQL A data column that exists in the first data column but does not exist in the second data column in the file.
  • the replacement database table and the replacement database column may be determined according to the table remarks, data column remarks, data column type, etc. in the table structure file.
  • the second data table corresponding to the inconsistent first data column may be searched according to the table structure file, The second data table corresponding to the inconsistent first data column is substituted for the first data table in the SQL file where the inconsistent first data column is located.
  • the database information analysis device 20 of the second embodiment obtains the SQL file of the software project; extracts all the first data columns in the SQL file and the first database table where the first data column is located; queries the database connected to the software project All the second data columns in the data column and the second database table where the data column is located; determine whether the first database table is included in the second database table; if the first database table is not included in the first database table In the second database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column is included in the second data column, and determine all Whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the second data column, and/or the If the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, output data columns that exist in the first data column but not in the second data column, and /Or the first data column where the first database table where the output is located is
  • the second embodiment analyzes the database information of the software project.
  • the database information used by the software project is inconsistent with the actual database information of the database
  • the database information of the software project is corrected, thereby reducing the inconsistency between the database information used by the software project and the actual database information of the database. The risk of improving software quality.
  • This embodiment provides a non-volatile readable storage medium having computer readable instructions stored on the non-volatile readable storage medium, and when the computer readable instructions are executed by a processor, the above embodiment of the database information analysis method is implemented
  • FIG. 3 is a schematic diagram of a computer device provided in Embodiment 4 of this application.
  • the computer device 30 includes a memory 301, a processor 302, and computer-readable instructions 303 stored in the memory 301 and running on the processor 302, such as a database information analysis program.
  • the processor 302 executes the computer-readable instruction 303, the steps in the embodiment of the database information analysis method described above are implemented, for example, 101-109 shown in FIG. 1.
  • the computer-readable instruction realizes the functions of the modules in the foregoing device embodiment when executed by the processor, for example, the modules 201-209 in FIG. 2.
  • the computer-readable instruction 303 may be divided into one or more modules, and the one or more modules are stored in the memory 301 and executed by the processor 302 to complete the method .
  • the computer-readable instruction 303 can be divided into the acquisition module 201, the extraction module 202, the query module 203, the first judgment module 204, the first output module 205, the second judgment module 206, and the second output in FIG.
  • the module 207, the generating module 208, and the correcting module 209, refer to the second embodiment for the specific functions of each module.
  • the computer device 30 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server.
  • the schematic diagram 3 is only an example of the computer device 30 and does not constitute a limitation on the computer device 30. It may include more or less components than those shown in the figure, or combine certain components, or be different.
  • the computer device 30 may also include input and output devices, network access devices, buses, and so on.
  • the so-called processor 302 may be a central processing unit (Central Processing Unit, CPU), other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor can be a microprocessor or the processor 302 can also be any conventional processor, etc.
  • the processor 302 is the control center of the computer device 30, which uses various interfaces and lines to connect the entire computer device 30. Various parts.
  • the memory 301 may be used to store the computer-readable instructions 303, and the processor 302 executes or executes the computer-readable instructions or modules stored in the memory 301 and calls the data stored in the memory 301 to implement Various functions of the computer device 30.
  • the memory 301 may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.); the storage data area may Data (such as audio data) created in accordance with the use of the computer device 30 is stored.
  • the memory 301 may include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • non-volatile memory such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
  • the integrated module of the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a non-volatile readable storage medium.
  • this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through computer-readable instructions.
  • the computer-readable instructions may be stored in a non-volatile memory. In the storage medium, when the computer-readable instructions are executed by the processor, the steps of the foregoing method embodiments can be implemented.
  • the computer-readable instructions may be in the form of source code, object code, executable file, or some intermediate forms.
  • the non-volatile readable storage medium may include: any entity or device capable of carrying the computer readable instructions, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, read-only memory (ROM, Read-Only Memory).

Landscapes

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

Abstract

A database information analysis method and apparatus, a computer apparatus, and a storage medium. The method comprises: obtaining an SQL file of a software project; extracting all the first data columns in the SQL file and a first database table where the first data columns are located; inquiring all the second data columns in a database connected with the software project and a second database table where the second data columns are located; outputting a database table that exists in the first database table but does not exist in the second database table; outputting a data column that exists in the first data columns but does not exist in the second data columns, and/or outputting the first data column of which the first database table is inconsistent with the second database table where the second data columns are located; generating a table structure file of the database; and correcting the SQL file according to the table structure file. The present invention can analyze and correct the database information of the software project.

Description

数据库信息分析方法、装置、计算机装置及存储介质Database information analysis method, device, computer device and storage medium
本申请要求于2019年09月05日提交中国专利局,申请号为201910839266.8申请名称为“数据库信息分析方法、装置、计算机装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims to be submitted to the Chinese Patent Office on September 5, 2019. The application number is 201910839266.8. The application titled "Database Information Analysis Method, Device, Computer Device and Storage Medium" is the priority of the Chinese patent application, the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及信息分析技术领域,具体涉及一种数据库信息分析方法、装置、计算机装置及非易失性可读存储介质。This application relates to the field of information analysis technology, and in particular to a database information analysis method, device, computer device, and non-volatile readable storage medium.
背景技术Background technique
在软件项目迁移或重构的过程中,可能会出现软件项目使用的数据库信息与数据库实际的数据库信息不一致的问题。为了避免软件项目因数据库信息不一致导致软件项目运行出错,需要对软件项目的数据库信息进行分析和修正。In the process of software project migration or reconstruction, there may be a problem that the database information used by the software project is inconsistent with the actual database information of the database. In order to avoid software project running errors due to inconsistent database information, the database information of the software project needs to be analyzed and corrected.
发明内容Summary of the invention
鉴于以上内容,有必要提出一种数据库信息分析方法、装置、计算机装置及非易失性可读存储介质,其可以对软件项目的数据库信息进行分析和修正。In view of the above, it is necessary to propose a database information analysis method, device, computer device and non-volatile readable storage medium, which can analyze and modify the database information of the software project.
本申请的第一方面提供一种数据库信息分析方法,所述方法包括:获取软件项目的SQL文件;提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;判断所述第一数据库表是否包含在所述第二数据库表中;若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则 生成所述数据库的表结构文件;根据所述表结构文件修正所述SQL文件。A first aspect of the present application provides a database information analysis method, the method includes: obtaining a SQL file of a software project; extracting all first data columns in the SQL file and a first database where the first data columns are located Table; query all the second data columns in the database connected to the software project and the second database table where the second data column is located; determine whether the first database table is included in the second database table; if If the first database table is not included in the second database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column contains In the second data column, and determine whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the In the second data column, and/or the first database table in which the first data column is located is inconsistent with the second database table in which the second data column is located, then the output exists in the first data column and the A data column that does not exist in the second data column, and/or a first data column that is inconsistent between the first database table where the output is located and the second database table where the second data column is located; if the first database table does not contain In the second database table, or the first data column is not included in the second data column, or the first database table where the first data column is located and the first database table where the second data column is located 2. If the database tables are inconsistent, a table structure file of the database is generated; the SQL file is corrected according to the table structure file.
本申请的第二方面提供一种数据库信息分析装置,所述装置包括:获取模块,用于获取软件项目的SQL文件;提取模块,用于提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;查询模块,用于查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;第一判断模块,用于判断所述第一数据库表是否包含在所述第二数据库表中;第一输出模块,用于若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;第二判断模块,用于判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;第二输出模块,用于若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;生成模块,用于若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;修正模块,用于根据所述表结构文件修正所述SQL文件。The second aspect of the present application provides a database information analysis device, the device includes: an acquisition module for acquiring SQL files of a software project; an extraction module for extracting all first data columns and all data in the SQL file The first database table where the first data column is located; a query module for querying all the second data columns in the database connected to the software project and the second database table where the second data column is located; first judgment module , Used to determine whether the first database table is included in the second database table; a first output module, used to output the first database table if the first database table is not included in the second database table A database table that exists in the first database table but does not exist in the second database table; a second judgment module for judging whether the first data column is included in the second data column, and judging the first data column Whether the first database table where a data column is located is consistent with the second database table where the second data column is located; the second output module is configured to, if the first data column is not included in the second data column, And/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then the output exists in the first data column but not in the second data column The first database table where the output is located is inconsistent with the second database table where the second data column is located; the generating module is used to if the first database table is not included in the In the second database table, or the first data column is not included in the second data column, or the first database table where the first data column is located and the second database where the second data column is located If the tables are inconsistent, a table structure file of the database is generated; a correction module is used to correct the SQL file according to the table structure file.
本申请的第三方面提供一种计算机装置,所述计算机装置包括处理器,所述处理器用于执行存储器中存储的计算机可读指令时实现所述数据库信息分析方法。A third aspect of the present application provides a computer device, the computer device includes a processor, and the processor is configured to implement the database information analysis method when executing computer-readable instructions stored in a memory.
本申请的第四方面提供一种非易失性可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现所述数据库信息分析方法。A fourth aspect of the present application provides a non-volatile readable storage medium having computer readable instructions stored thereon, and when the computer readable instructions are executed by a processor, the database information analysis method is implemented.
本申请实现了对软件项目的数据库信息进行分析和修正。This application realizes the analysis and correction of the database information of the software project.
附图说明Description of the drawings
图1是本申请实施例提供的数据库信息分析方法的流程图。Fig. 1 is a flowchart of a method for analyzing database information provided by an embodiment of the present application.
图2是本申请实施例提供的数据库信息分析装置的结构图。Figure 2 is a structural diagram of a database information analysis device provided by an embodiment of the present application.
图3是本申请实施例提供的计算机装置的示意图。Fig. 3 is a schematic diagram of a computer device provided by an embodiment of the present application.
具体实施方式detailed description
优选地,本申请的数据库信息分析方法应用在一个或者多个计算机装置中。所述计算机装置是一种能够按照事先设定或存储的指令,自动进行数值计算和/或信息处理的设备,其硬件包括但不限于微处理器、专用集成电路(Application Specific Integrated Circuit, ASIC)、可编程门阵列(Field-Programmable Gate Array,FPGA)、数字处理器(Digital Signal Processor,DSP)、嵌入式设备等。Preferably, the database information analysis method of the present application is applied to one or more computer devices. The computer device is a device that can automatically perform numerical calculation and/or information processing in accordance with pre-set or stored instructions. Its hardware includes, but is not limited to, a microprocessor and an application specific integrated circuit (ASIC) , Programmable Gate Array (Field-Programmable Gate Array, FPGA), Digital Processor (Digital Signal Processor, DSP), embedded equipment, etc.
所述计算机装置可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。所述计算机装置可以与用户通过键盘、鼠标、遥控器、触摸板或声控设备等方式进行人机交互。The computer device may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. The computer device can interact with the user through a keyboard, a mouse, a remote control, a touch panel, or a voice control device.
实施例一Example one
图1是本申请实施例一提供的数据库信息分析方法的流程图。所述数据库信息分析方法用于对软件项目的数据库信息进行分析和修正。FIG. 1 is a flowchart of a method for analyzing database information provided in Embodiment 1 of the present application. The database information analysis method is used to analyze and modify the database information of the software project.
如图1所示,所述数据库信息分析方法包括:As shown in Figure 1, the database information analysis method includes:
101,获取软件项目的SQL(Structured Query Language,结构化查询语言)文件。101. Obtain the SQL (Structured Query Language) file of the software project.
SQL是一种数据库查询和程序设计语言,用于在数据库中存取数据以及查询、更新和管理数据库。SQL is a database query and programming language used to access data in the database, query, update and manage the database.
可以生成SQL文件配置界面,接收用户在所述SQL文件配置界面中设置的软件项目路径,根据所述软件项目路径获取所述SQL文件。例如,所述软件项目路径可以是D:\eclipse\workspaces。A SQL file configuration interface can be generated, the software project path set by the user in the SQL file configuration interface can be received, and the SQL file can be obtained according to the software project path. For example, the software project path may be D:\eclipse\workspaces.
在一具体实施例中,所述根据所述软件项目路径获取所述SQL文件可以包括:遍历所述软件项目路径下所述软件项目所有的文件,从所述软件项目所有的文件中获取所述SQL文件。可以递归遍历所述软件项目路径下所述软件项目所有的文件。所述软件项目的每个文件夹下可以包含子文件夹和/或文件;如果该文件夹下包含子文件夹则继续遍历;如果该文件夹下包含文件,则判断该文件是否是SQL文件;如果该文件是SQL文件,则保存该SQL文件。In a specific embodiment, the obtaining the SQL file according to the software project path may include: traversing all files of the software project under the software project path, and obtaining the files from all the files of the software project. SQL file. All files of the software project under the software project path can be traversed recursively. Each folder of the software project may contain subfolders and/or files; if the folder contains subfolders, continue to traverse; if the folder contains files, it is determined whether the file is an SQL file; If the file is a SQL file, save the SQL file.
所述SQL文件可以是XML(Extensible Markup Language,可扩展标记语言)文件。所述SQL文件可以包括SQL语句。例如,所述SQL文件是testMapper.xml,该文件中包括SQL语句。SQL语句是用于对数据库进行操作的语句。The SQL file may be an XML (Extensible Markup Language, Extensible Markup Language) file. The SQL file may include SQL statements. For example, the SQL file is testMapper.xml, and the file includes SQL statements. SQL statements are statements used to operate on the database.
102,提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表。102. Extract all the first data columns in the SQL file and the first database table where the first data columns are located.
可以根据所述SQL文件中的标签查找目标代码;根据所述目标代码中的关键字提取所述第一数据列和所述第一数据库表。The target code can be searched according to the tags in the SQL file; the first data column and the first database table can be extracted according to the keywords in the target code.
所述目标代码可以包括SQL语句和存储过程、触发器等。所述SQL语句用于对数据库表/数据列进行增加、删除、修改、查询等操作。The target code may include SQL statements, stored procedures, triggers, and so on. The SQL statement is used to perform operations such as adding, deleting, modifying, and querying database tables/data columns.
例如,所述SQL文件可以包括代码“<select id="select_allstudent" result_class="Student">select name from tbl_student where id=#id#</select>”。其中的标签为<select id="select_allstudent"result_class="Student"></select>,目标代码为“select name from tbl_student where id=#id#”,目标代码中的关键字为“select”、“from”、“where”。“name”、“id”为所述第一数据列,“tbl_student”为所述第一数据列“name”、“id”所在的第一数据库表。For example, the SQL file may include the code "<select id="select_allstudent" result_class="Student">select name from tbl_student where id=#id#</select>". The tag is <select id="select_allstudent"result_class="Student"></select>, the target code is "select name from tbl_student where id=#id#", and the keywords in the target code are "select", " from", "where". "Name" and "id" are the first data columns, and "tbl_student" is the first database table where the first data columns "name" and "id" are located.
可以根据所述第一数据列和所述第一数据库表生成第一列表。The first list may be generated according to the first data column and the first database table.
所述第一列表除了第一数据库表、第一数据列,还可以包括数据库、数据库用户名、存储过程、触发器等字段信息。In addition to the first database table and the first data column, the first list may also include field information such as database, database user name, stored procedure, and trigger.
可以按照预设顺序生成所述第一列表。例如,按照所述第一数据列或所述第一数据库表的首字母顺序生成所述第一列表。The first list may be generated in a preset order. For example, the first list is generated according to the first alphabetical order of the first data column or the first database table.
103,查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表。103. Query all the second data columns in the database connected to the software project and the second database table where the second data columns are located.
在一具体实施例中,可以按照以下方式查询所述软件项目连接的数据库中所有的第二数据列和所述数据列所在的第二数据库表:获取所述软件项目的数据源信息;根据数据源信息建立与数据库的连接;执行SQL查询语句,查询所述数据库中所有的第二数据列和所述数据列所在的第二数据库表。In a specific embodiment, all the second data columns in the database connected to the software project and the second database table where the data columns are located can be queried in the following manner: obtain the data source information of the software project; according to the data The source information establishes a connection with the database; an SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
所述数据源信息是所述创建数据库连接的配置信息,可以包括数据库用户名、数据库登录密码、链接串、驱动类等。例如,数据库用户名表示为"username"、数据库登录密码表示为"password",驱动类表示为"oracle.jdbc.driver.OracleDriver",链接串表示为"jdbc:oracle:thin:@127.0.0.1:DEV"。The data source information is the configuration information for creating the database connection, and may include a database user name, a database login password, a link string, a driver class, and the like. For example, the database user name is represented as "username", the database login password is represented as "password", the driver class is represented as "oracle.jdbc.driver.OracleDriver", and the link string is represented as "jdbc:oracle:thin:@127.0.0.1: DEV".
可以根据所述第二数据列和所述第二数据库表生成第二列表。A second list may be generated according to the second data column and the second database table.
所述第二列表除了第二数据列、第二数据库表,还可以包括数据库、数据库用户名、存储过程、触发器等字段信息。In addition to the second data column and the second database table, the second list may also include field information such as database, database user name, stored procedure, and trigger.
可以按照预设顺序生成所述第二列表。例如,按照所述第二数据列或所述第二数据库表的首字母顺序生成所述第二列表。The second list may be generated in a preset order. For example, the second list is generated according to the first alphabetical order of the second data column or the second database table.
104,判断所述第一数据库表是否包含在所述第二数据库表中。104. Determine whether the first database table is included in the second database table.
所述第一数据库表包含在所述第二数据库表中是指所述第一数据库表中的每个数据库表都包含在所述第二数据库表中。The inclusion of the first database table in the second database table means that each database table in the first database table is included in the second database table.
例如,所述第一数据库表包括Table1、Table2、Table3、Table4,所述第二数据库表包括Table1、Table2、Table3、Table4、Table5,则所述第一数据库表包含在所述第二数据库表中。For example, if the first database table includes Table1, Table2, Table3, and Table4, and the second database table includes Table1, Table2, Table3, Table4, and Table5, the first database table is included in the second database table. .
又如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4、Table5,则所述第一数据库表包含在所述第二数据库表中。For another example, if the first database table includes Table1, Table2, Table3, Table4, and Table5, and the second database table includes Table1, Table2, Table3, Table4, and Table5, then the first database table is included in the second Database table.
再如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4,则所述第一数据库表不包含在所述第二数据库表中。For another example, if the first database table includes Table1, Table2, Table3, Table4, and Table5, and the second database table includes Table1, Table2, Table3, and Table4, then the first database table is not included in the second database. Table.
可以根据所述第一列表和所述第二列表判断所述第一数据库表是否包含在所述第二数据库表中。It may be determined whether the first database table is included in the second database table according to the first list and the second list.
可以使用COMPARE方法对所述第一列表中的第一数据库表和所述第二列表中的第二数据库表进行对比,判断所述第一数据库表与所述第二数据库表是否一致。若所述第一数据库表与所述第二数据库表一致,则判断所述第一数据库表包含在所述第二数据库表中。The COMPARE method may be used to compare the first database table in the first list with the second database table in the second list to determine whether the first database table is consistent with the second database table. If the first database table is consistent with the second database table, it is determined that the first database table is included in the second database table.
105,若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表。105. If the first database table is not included in the second database table, output a database table that exists in the first database table but does not exist in the second database table.
所述第一数据库表中存在而所述第二数据库表中不存在的数据库表表示所述软件项目错误使用的数据库表。The database table that exists in the first database table but does not exist in the second database table represents a database table that is incorrectly used by the software project.
例如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4,所述第一数据库表不包含在所述第二数据库表中,输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表Table5。For example, the first database table includes Table1, Table2, Table3, Table4, and Table5, the second database table includes Table1, Table2, Table3, and Table4, and the first database table is not included in the second database table. , Output the database table Table5 that exists in the first database table but does not exist in the second database table.
若所述第一数据库表不包含在所述第二数据库表中,可以发出数据库表错误提示或发送数据库表错误通知。可以通过语音或文字发出所述数据库表错误提示。可以通过邮件、短信、微信等方式将所述数据库表错误通知发送给预设联系人。If the first database table is not included in the second database table, a database table error prompt or a database table error notification can be sent. The database table error prompt can be issued by voice or text. The notification of the database table error can be sent to the preset contact by means of email, short message, WeChat, etc.
可选地,在本实施例中,还可以判断所述第二数据库表是否包含在所述第一数据库表中;若所述第二数据库表不包含在所述第一数据库表中,输出所述第二数据库表中存在而所述第一数据库表中不存在的数据库表。Optionally, in this embodiment, it is also possible to determine whether the second database table is included in the first database table; if the second database table is not included in the first database table, output all A database table that exists in the second database table but does not exist in the first database table.
所述第二数据库表中存在而所述第一数据库表中不存在的数据库表表示所述软件项目没有使用的数据库表。输出所述第二数据库表中存在而所述第一数据库表中不存在的数据库表可以提醒用户确认数据库表信息是否有误。The database tables that exist in the second database table but not in the first database table represent database tables that are not used by the software project. Outputting the database tables existing in the second database table but not in the first database table can remind the user to confirm whether the database table information is incorrect.
106,判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致。106. Determine whether the first data column is included in the second data column, and determine whether the first database table where the first data column is located is consistent with the second database table where the second data column is located.
所述第一数据列包含在所述第二数据列中是指所述第一数据列中的每个数据列都包含在所述第二数据列中。The inclusion of the first data column in the second data column means that each data column in the first data column is included in the second data column.
例如,所述第一数据列包括Line1、Line2、Line3、Line4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,则所述第一数据列包含在所述第二数据列中。For example, if the first data column includes Line1, Line2, Line3, Line4, and the second data column includes Line1, Line2, Line3, Line4, Line5, then the first data column is included in the second data column .
又如,所述第一数据列包括Line1、Line2、Line3、Line4、Line5,所述第二数据列包括Line1、Line2、Line3、Line4,则所述第一数据列不包含在所述第二数据列中。For another example, if the first data column includes Line1, Line2, Line3, Line4, Line5, and the second data column includes Line1, Line2, Line3, Line4, then the first data column is not included in the second data column. Column.
可以根据所述第一列表和所述第二列表判断所述第一数据列是否包含在所述第二数据列中。It may be determined whether the first data column is included in the second data column according to the first list and the second list.
可以使用COMPARE方法对所述第一列表中的第一数据列和所述第二列表中的第二数据列进行对比,判断所述第一数据列与所述第二数据列是否一致。若所述第一数据列与所述第二数据列一致,则判断所述第一数据列包含在所述第二数据列中。The COMPARE method may be used to compare the first data column in the first list with the second data column in the second list to determine whether the first data column is consistent with the second data column. If the first data row is consistent with the second data row, it is determined that the first data row is included in the second data row.
所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致是指每个第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致。The first database table where the first data column is located is consistent with the second database table where the second data column is located means that the first database table where each first data column is located is the same as the first database table where the second data column is located. The two database tables are consistent.
例如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table2,第二数据列Line3所在的第二数据库表为Table3,第二数据列Line4所在的第二数据库表为Table4,则所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致。For example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column Line3 is The first database table is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second database where the second data column Line1 is located The table is Table1, the second database table where the second data column Line2 is located is Table2, the second database table where the second data column Line3 is located is Table3, and the second database table where the second data column Line4 is located is Table4, then the second database table where the second data column Line4 is located is Table4. The first database table where a data column is located is consistent with the second database table where the second data column is located.
又如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4;所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table1,第二数据列Line3所在的第二数据库表为Table1,第二数据列Line4所在的第二数据库表为Table4,则所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致。For another example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4; the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4, then The first database table where the first data column is located is inconsistent with the second database table where the second data column is located.
可以根据所述第一列表和所述第二列表判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致。It is possible to determine whether the first data column is included in the second data column according to the first list and the second list, and to determine whether the first database table in which the first data column is located is the same as the first data column. The second database table where the second data column is located is the same.
107,若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的 第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列。107. If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, Then output data columns that exist in the first data column but do not exist in the second data column, and/or the first database table where the output is located is inconsistent with the second database table where the second data column is located. One data column.
例如,所述第一数据列包括Line1、Line2、Line3、Line4、Line5,所述第二数据列包括Line1、Line2、Line3、Line4,所述第一数据列不包含在所述第二数据列中,输出所述第一数据列中存在而所述第二数据列中不存在的数据列Line5。For example, the first data column includes Line1, Line2, Line3, Line4, Line5, the second data column includes Line1, Line2, Line3, Line4, and the first data column is not included in the second data column. , Output the data row Line5 that exists in the first data row but does not exist in the second data row.
又如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table1,第二数据列Line3所在的第二数据库表为Table1,第二数据列Line4所在的第二数据库表为Table4,所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列Line2、Line3。For another example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4. The first database table where a data column is located is not consistent with the second database table where the second data column is located, and the first data column where the first database table where the second data column is located is inconsistent with the second database table where the second data column is located is output. Line2, Line3.
若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,可以发出数据列错误提示或发送数据列错误通知。可以通过语音或文字发出所述数据列错误提示。可以通过邮件、短信、微信等方式将所述数据列错误通知发送给预设联系人。If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, you can issue Data column error prompt or send data column error notification. The data string error prompt can be issued by voice or text. The notification of the data column error can be sent to the preset contact by means of email, SMS, WeChat, etc.
需要说明的是,上述104、105与106、107的顺序可以互换。上述实施例是先对数据库表进行判断,在其他的实施例中,可以先对数据列进行判断。It should be noted that the order of 104, 105 and 106, 107 can be interchanged. In the foregoing embodiment, the database table is judged first. In other embodiments, the data column may be judged first.
108,若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件。108. If the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first database where the first data column is located If the table is inconsistent with the second database table where the second data column is located, a table structure file of the database is generated.
所述数据库的表结构文件表示所述数据库包含的所有数据库表和数据库列,以及数据库列与数据库表的对应关系。The table structure file of the database indicates all the database tables and database columns contained in the database, and the correspondence between the database columns and the database tables.
在一具体实施例中,所述方法应用于Java,所述生成所述数据库的表结构文件可以包括:In a specific embodiment, the method is applied to Java, and generating the table structure file of the database may include:
1、读取所述数据库的数据库脚本,将所述数据库脚本解析为对应的java实体类。1. Read the database script of the database, and parse the database script into the corresponding java entity class.
所述java实体类是在JAVA软件开发中广泛使用的概念。所述java实体类是一个包含Set和Get方法的类,通常可和数据库联系在一起。The java entity class is a concept widely used in JAVA software development. The java entity class is a class containing Set and Get methods, and can usually be associated with a database.
所述数据库脚本在创建所述数据库和所述数据库中的数据库表时生成。The database script is generated when the database and the database tables in the database are created.
所述数据库脚本可以包含一个或多个数据表。将所述数据库脚本解析为对应的java实体类就是将所述数据库脚本解析封装为所述一个或多个数据表对应的java实体类。具体地,可以识别所述数据库脚本包含的数据库表,将每个数据库表包含的数据信息解析封装为一个对应的java实体类。也就是说,每个java实体类对应所述数据库脚本中的一个数据表,解析一个所述数据库脚本可以得到对应的一个或多个java实体类。The database script may contain one or more data tables. Parsing the database script into the corresponding java entity class means parsing and packaging the database script into the java entity class corresponding to the one or more data tables. Specifically, the database tables contained in the database script can be identified, and the data information contained in each database table can be parsed and packaged into a corresponding java entity class. In other words, each java entity class corresponds to a data table in the database script, and one or more corresponding java entity classes can be obtained by parsing one database script.
可以通过设定的工具(例如PowerDesigner)导出所述数据库脚本。The database script can be exported through a set tool (such as PowerDesigner).
可以根据接收到的数据库命令导出所述数据库脚本。The database script can be exported according to the received database command.
2、根据所述java实体类生成所述表结构文件。2. Generate the table structure file according to the java entity class.
可以根据实际需要设置所述表结构文件的样式。例如,设置多个数据表标题的样式(包括字体、显示位置等),以及多个表格结构的样式(包括表格尺寸、填充色、数据显示格式等)。The style of the table structure file can be set according to actual needs. For example, set the styles of multiple data table titles (including fonts, display positions, etc.), and multiple table structure styles (including table size, fill color, data display format, etc.).
在一具体实施例中,所述表结构文件可以包括数据库表、表备注、数据列、数据列备注、数据列类型等。例如,在所述表结构文件中,用“tableName”表示数据库表,用“tableComment”表示表备注,用“columName”表示数据列,用“columComment”表示数据列备注,用“columType”表示数据列类型。In a specific embodiment, the table structure file may include database tables, table remarks, data columns, data column remarks, data column types, and so on. For example, in the table structure file, "tableName" is used for database table, "tableComment" is used for table comment, "columName" is used for data column, "columComment" is used for data column comment, and "columType" is used for data column. Types of.
本实施例中,若所述数据库脚本中包含多个数据表,可以得到对应的多个java实体类。因此,根据所述数据库脚本对应的java实体类生成对应的表结构文件中,也包含多个数据表结构。In this embodiment, if the database script contains multiple data tables, multiple corresponding java entity classes can be obtained. Therefore, the corresponding table structure file generated according to the java entity class corresponding to the database script also contains multiple data table structures.
109,根据所述表结构文件修正所述SQL文件。109. Correct the SQL file according to the table structure file.
根据所述表结构文件修正所述SQL文件,就是修正所述SQL文件中所述第一数据库表中存在而所述第二数据库表中不存在的数据库表,和/或修正所述SQL文件中所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或修正所述SQL文件中所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列。Modifying the SQL file according to the table structure file means modifying the database tables that exist in the first database table but not in the second database table in the SQL file, and/or modifying the SQL file Data columns that exist in the first data column but not in the second data column, and/or modify the first database table where the SQL file is located and the second database table where the second data column is located Inconsistent first data column.
对于所述第一数据库表中存在而所述第二数据库表中不存在的数据库表或者所述第一数据列中存在而所述第二数据列中不存在的数据列,可以根据所述表结构文件查找所述第一数据库表中存在而所述第二数据库表中不存在的数据库表的替代数据库表,查找所述第一数据列中存在而所述第二数据列中不存在的数据列的替代数据库列,以所述替代数据库表取代所述SQL文件中所述第一数据库表中存在而所述第二数据库表中不存在的数据库表,以所述替代数据库列取代所述SQL文件中所述第一数据列中存在而所述第二数据列中不存在的数据列。可以根据所述表结构文件中的表备注、数据列备注、数 据列类型等确定所述替代数据库表和替代数据库列。For a database table that exists in the first database table but does not exist in the second database table, or a data column that exists in the first data column but does not exist in the second data column, it may be based on the table The structure file searches for a replacement database table for a database table that exists in the first database table but does not exist in the second database table, and searches for data that exists in the first data column but does not exist in the second data column The replacement database column of the column, the replacement database table replaces the database table that exists in the first database table in the SQL file but does not exist in the second database table, and the replacement database column replaces the SQL A data column that exists in the first data column but does not exist in the second data column in the file. The replacement database table and the replacement database column may be determined according to the table remarks, data column remarks, data column type, etc. in the table structure file.
对于所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列,可以根据所述表结构文件查找所述不一致的第一数据列对应的第二数据表,以所述不一致的第一数据列所对应的第二数据表取代所述SQL文件中所述不一致的第一数据列所在的第一数据表。For a first data column that is inconsistent with the first database table in which the second data column is located, the second data table corresponding to the inconsistent first data column may be searched according to the table structure file, The second data table corresponding to the inconsistent first data column is substituted for the first data table in the SQL file where the inconsistent first data column is located.
实施例一的数据库信息分析方法获取软件项目的SQL文件;提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;查询所述软件项目连接的数据库中所有的第二数据列和所述数据列所在的第二数据库表;判断所述第一数据库表是否包含在所述第二数据库表中;若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;根据所述表结构文件修正所述SQL文件。实施例一对软件项目的数据库信息进行分析,当软件项目使用的数据库信息与数据库实际的数据库信息不一致对软件项目的数据库信息进行修正,从而降低软件项目使用的数据库信息与数据库实际的数据库信息不一致的风险,提高软件质量。The database information analysis method of the first embodiment obtains the SQL file of the software project; extracts all the first data columns in the SQL file and the first database table where the first data columns are located; and queries the database connected to the software project All the second data columns and the second database table where the data columns are located; determine whether the first database table is included in the second database table; if the first database table is not included in the second database table In the database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column is included in the second data column, and determine whether the Whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the second data column, and/or the first data column is If the first database table where a data column is located is inconsistent with the second database table where the second data column is located, output data columns that exist in the first data column but not in the second data column, and/ Or output a first data column that is inconsistent with the second database table where the second data column is located; if the first database table is not included in the second database table, or the first database table is If a data column is not included in the second data column, or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then the table structure of the database is generated File; revise the SQL file according to the table structure file. The embodiment analyzes the database information of the software project. When the database information used by the software project is inconsistent with the actual database information of the database, the database information of the software project is corrected, thereby reducing the inconsistency between the database information used by the software project and the actual database information of the database. The risk of improving software quality.
实施例二Example two
图2是本申请实施例二提供的数据库信息分析装置的结构图。所述数据库信息分析装置20应用于计算机装置,用于对软件项目的数据库信息进行分析和修正。Fig. 2 is a structural diagram of a database information analysis device provided in the second embodiment of the present application. The database information analysis device 20 is applied to a computer device, and is used to analyze and correct the database information of the software project.
如图2所示,所述数据库信息分析装置20可以包括获取模块201、提取模块202、查询模块203、第一判断模块204、第一输出模块205、第二判断模块206、第二输出模块207、生成模块208、修正模块209。As shown in FIG. 2, the database information analysis device 20 may include an acquisition module 201, an extraction module 202, a query module 203, a first judgment module 204, a first output module 205, a second judgment module 206, and a second output module 207 , The generation module 208, the correction module 209.
获取模块201,用于获取软件项目的SQL(Structured Query Language,结构化查询语言)文件。The obtaining module 201 is used to obtain SQL (Structured Query Language, structured query language) files of the software project.
SQL是一种数据库查询和程序设计语言,用于在数据库中存取数据以及查询、更新和管理数据库。SQL is a database query and programming language used to access data in the database, query, update and manage the database.
可以生成SQL文件配置界面,接收用户在所述SQL文件配置界面中设置的软件项目路径,根据所述软件项目路径获取所述SQL文件。例如,所述软件项目路径可以是D:\eclipse\workspaces。A SQL file configuration interface can be generated, the software project path set by the user in the SQL file configuration interface can be received, and the SQL file can be obtained according to the software project path. For example, the software project path may be D:\eclipse\workspaces.
在一具体实施例中,所述根据所述软件项目路径获取所述SQL文件可以包括:遍历所述软件项目路径下所述软件项目所有的文件,从所述软件项目所有的文件中获取所述SQL文件。可以递归遍历所述软件项目路径下所述软件项目所有的文件。所述软件项目的每个文件夹下可以包含子文件夹和/或文件;如果该文件夹下包含子文件夹则继续遍历;如果该文件夹下包含文件,则判断该文件是否是SQL文件;如果该文件是SQL文件,则保存该SQL文件。In a specific embodiment, the obtaining the SQL file according to the software project path may include: traversing all files of the software project under the software project path, and obtaining the files from all the files of the software project. SQL file. All files of the software project under the software project path can be traversed recursively. Each folder of the software project may contain subfolders and/or files; if the folder contains subfolders, continue to traverse; if the folder contains files, determine whether the file is an SQL file; If the file is a SQL file, save the SQL file.
所述SQL文件可以是XML(Extensible Markup Language,可扩展标记语言)文件。所述SQL文件可以包括SQL语句。例如,所述SQL文件是testMapper.xml,该文件中包括SQL语句。SQL语句是用于对数据库进行操作的语句。The SQL file may be an XML (Extensible Markup Language, Extensible Markup Language) file. The SQL file may include SQL statements. For example, the SQL file is testMapper.xml, and the file includes SQL statements. SQL statements are statements used to operate on the database.
提取模块202,用于提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表。The extraction module 202 is configured to extract all the first data columns in the SQL file and the first database table where the first data columns are located.
可以根据所述SQL文件中的标签查找目标代码;根据所述目标代码中的关键字提取所述第一数据列和所述第一数据库表。The target code can be searched according to the tags in the SQL file; the first data column and the first database table can be extracted according to the keywords in the target code.
所述目标代码可以包括SQL语句和存储过程、触发器等。所述SQL语句用于对数据库表/数据列进行增加、删除、修改、查询等操作。The target code may include SQL statements, stored procedures, triggers, and so on. The SQL statement is used to perform operations such as adding, deleting, modifying, and querying database tables/data columns.
例如,所述SQL文件可以包括代码“<select id="select_allstudent"result_class="Student">select name from tbl_student where id=#id#</select>”。其中的标签为<select id="select_allstudent"result_class="Student"></select>,目标代码为“select name from tbl_student where id=#id#”,目标代码中的关键字为“select”、“from”、“where”。“name”、“id”为所述第一数据列,“tbl_student”为所述第一数据列“name”、“id”所在的第一数据库表。For example, the SQL file may include the code "<select id="select_allstudent"result_class="Student">select name from tbl_student where id=#id#</select>". The tag is <select id="select_allstudent"result_class="Student"></select>, the target code is "select name from tbl_student where id=#id#", and the keywords in the target code are "select", " from", "where". "Name" and "id" are the first data columns, and "tbl_student" is the first database table where the first data columns "name" and "id" are located.
可以根据所述第一数据列和所述第一数据库表生成第一列表。The first list may be generated according to the first data column and the first database table.
所述第一列表除了第一数据库表、第一数据列,还可以包括数据库、数据库用户名、存储过程、触发器等字段信息。In addition to the first database table and the first data column, the first list may also include field information such as database, database user name, stored procedure, and trigger.
可以按照预设顺序生成所述第一列表。例如,按照所述第一数据列或所述第一数据库表的首字母顺序生成所述第一列表。The first list may be generated in a preset order. For example, the first list is generated according to the first alphabetical order of the first data column or the first database table.
查询模块203,用于查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表。The query module 203 is configured to query all the second data columns in the database connected to the software project and the second database table where the second data columns are located.
在一具体实施例中,可以按照以下方式查询所述软件项目连接的数据库中所有的第二数据列和所述数据列所在的第二数据库表:获取所述软件项目的数据源信息;根据数据源信息建立与数据库的连接;执行SQL查询语句,查询所述数据库中所有的第二数据列和所述数据列所在的第二数据库表。In a specific embodiment, all the second data columns in the database connected to the software project and the second database table where the data columns are located can be queried in the following manner: obtain the data source information of the software project; according to the data The source information establishes a connection with the database; an SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
所述数据源信息是所述创建数据库连接的配置信息,可以包括数据库用户名、数据库登录密码、链接串、驱动类等。例如,数据库用户名表示为"username"、数据库登录密码表示为"password",驱动类表示为"oracle.jdbc.driver.OracleDriver",链接串表示为"jdbc:oracle:thin:@127.0.0.1:DEV"。The data source information is the configuration information for creating a database connection, and may include a database user name, a database login password, a link string, a driver category, and the like. For example, the database user name is represented as "username", the database login password is represented as "password", the driver class is represented as "oracle.jdbc.driver.OracleDriver", and the link string is represented as "jdbc:oracle:thin:@127.0.0.1: DEV".
可以根据所述第二数据列和所述第二数据库表生成第二列表。A second list may be generated according to the second data column and the second database table.
所述第二列表除了第二数据列、第二数据库表,还可以包括数据库、数据库用户名、存储过程、触发器等字段信息。In addition to the second data column and the second database table, the second list may also include field information such as database, database user name, stored procedure, and trigger.
可以按照预设顺序生成所述第二列表。例如,按照所述第二数据列或所述第二数据库表的首字母顺序生成所述第二列表。The second list may be generated in a preset order. For example, the second list is generated according to the first alphabetical order of the second data column or the second database table.
第一判断模块204,用于判断所述第一数据库表是否包含在所述第二数据库表中。The first judgment module 204 is configured to judge whether the first database table is included in the second database table.
所述第一数据库表包含在所述第二数据库表中是指所述第一数据库表中的每个数据库表都包含在所述第二数据库表中。The inclusion of the first database table in the second database table means that each database table in the first database table is included in the second database table.
例如,所述第一数据库表包括Table1、Table2、Table3、Table4,所述第二数据库表包括Table1、Table2、Table3、Table4、Table5,则所述第一数据库表包含在所述第二数据库表中。For example, if the first database table includes Table1, Table2, Table3, and Table4, and the second database table includes Table1, Table2, Table3, Table4, and Table5, the first database table is included in the second database table. .
又如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4、Table5,则所述第一数据库表包含在所述第二数据库表中。For another example, if the first database table includes Table1, Table2, Table3, Table4, and Table5, and the second database table includes Table1, Table2, Table3, Table4, and Table5, then the first database table is included in the second Database table.
再如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4,则所述第一数据库表不包含在所述第二数据库表中。For another example, if the first database table includes Table1, Table2, Table3, Table4, and Table5, and the second database table includes Table1, Table2, Table3, and Table4, then the first database table is not included in the second database. Table.
可以根据所述第一列表和所述第二列表判断所述第一数据库表是否包含在所述第二数据库表中。It may be determined whether the first database table is included in the second database table according to the first list and the second list.
可以使用COMPARE方法对所述第一列表中的第一数据库表和所述第二列表中的第二数据库表进行对比,判断所述第一数据库表与所述第二数据库表是否一致。若所述第一数据库表与所述第二数据库表一致,则判断所述第一数据库表包含在所述第二数据库表中。The COMPARE method may be used to compare the first database table in the first list with the second database table in the second list to determine whether the first database table is consistent with the second database table. If the first database table is consistent with the second database table, it is determined that the first database table is included in the second database table.
第一输出模块205,用于若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表。The first output module 205 is configured to output a database table that exists in the first database table but does not exist in the second database table if the first database table is not included in the second database table.
所述第一数据库表中存在而所述第二数据库表中不存在的数据库表表示所述软件项目错误使用的数据库表。The database table that exists in the first database table but does not exist in the second database table represents a database table that is incorrectly used by the software project.
例如,所述第一数据库表包括Table1、Table2、Table3、Table4、Table5,所述第二数据库表包括Table1、Table2、Table3、Table4,所述第一数据库表不包含在所述第二数据库表中,输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表Table5。For example, the first database table includes Table1, Table2, Table3, Table4, and Table5, the second database table includes Table1, Table2, Table3, and Table4, and the first database table is not included in the second database table. , Output the database table Table5 that exists in the first database table but does not exist in the second database table.
若所述第一数据库表不包含在所述第二数据库表中,可以发出数据库表错误提示或发送数据库表错误通知。可以通过语音或文字发出所述数据库表错误提示。可以通过邮件、短信、微信等方式将所述数据库表错误通知发送给预设联系人。If the first database table is not included in the second database table, a database table error prompt or a database table error notification can be sent. The database table error prompt can be issued by voice or text. The notification of the database table error can be sent to the preset contact by means of email, short message, WeChat, etc.
可选地,在本实施例中,还可以判断所述第二数据库表是否包含在所述第一数据库表中;若所述第二数据库表不包含在所述第一数据库表中,输出所述第二数据库表中存在而所述第一数据库表中不存在的数据库表。Optionally, in this embodiment, it is also possible to determine whether the second database table is included in the first database table; if the second database table is not included in the first database table, output all A database table that exists in the second database table but does not exist in the first database table.
所述第二数据库表中存在而所述第一数据库表中不存在的数据库表表示所述软件项目没有使用的数据库表。输出所述第二数据库表中存在而所述第一数据库表中不存在的数据库表可以提醒用户确认数据库表信息是否有误。The database tables that exist in the second database table but not in the first database table represent database tables that are not used by the software project. Outputting the database tables existing in the second database table but not in the first database table can remind the user to confirm whether the database table information is incorrect.
第二判断模块206,用于判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致。The second determining module 206 is configured to determine whether the first data column is included in the second data column, and whether the first database table in which the first data column is located is the same as the one in which the second data column is located. The second database table is consistent.
所述第一数据列包含在所述第二数据列中是指所述第一数据列中的每个数据列都包含在所述第二数据列中。The inclusion of the first data column in the second data column means that each data column in the first data column is included in the second data column.
例如,所述第一数据列包括Line1、Line2、Line3、Line4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,则所述第一数据列包含在所述第二数据列中。For example, if the first data column includes Line1, Line2, Line3, Line4, and the second data column includes Line1, Line2, Line3, Line4, Line5, then the first data column is included in the second data column .
又如,所述第一数据列包括Line1、Line2、Line3、Line4、Line5,所述第二数据列包括Line1、Line2、Line3、Line4,则所述第一数据列不包含在所述第二数据列中。For another example, if the first data column includes Line1, Line2, Line3, Line4, Line5, and the second data column includes Line1, Line2, Line3, Line4, then the first data column is not included in the second data column. Column.
可以根据所述第一列表和所述第二列表判断所述第一数据列是否包含在所述第二数据列中。It may be determined whether the first data column is included in the second data column according to the first list and the second list.
可以使用COMPARE方法对所述第一列表中的第一数据列和所述第二列表中的第二数据列进行对比,判断所述第一数据列与所述第二数据列是否一致。若所述第一数据列与所述第二数据列一致,则判断所述第一数据列包含在所述第二数据列中。The COMPARE method may be used to compare the first data column in the first list with the second data column in the second list to determine whether the first data column is consistent with the second data column. If the first data row is consistent with the second data row, it is determined that the first data row is included in the second data row.
所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致是指每个第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致。The first database table where the first data column is located is consistent with the second database table where the second data column is located means that the first database table where each first data column is located is the same as the first database table where the second data column is located. The two database tables are consistent.
例如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table2,第二数据列Line3所在的第二数据库表为Table3,第二数据列Line4所在的第二数据库表为Table4,则所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表一致。For example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column Line3 is The first database table is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second database where the second data column Line1 is located The table is Table1, the second database table where the second data column Line2 is located is Table2, the second database table where the second data column Line3 is located is Table3, and the second database table where the second data column Line4 is located is Table4, then the second database table where the second data column Line4 is located is Table4. The first database table where a data column is located is consistent with the second database table where the second data column is located.
又如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4;所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table1,第二数据列Line3所在的第二数据库表为Table1,第二数据列Line4所在的第二数据库表为Table4,则所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致。For another example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4; the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4, then The first database table where the first data column is located is inconsistent with the second database table where the second data column is located.
可以根据所述第一列表和所述第二列表判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致。It is possible to determine whether the first data column is included in the second data column according to the first list and the second list, and to determine whether the first database table in which the first data column is located is the same as the first data column. The second database table where the second data column is located is the same.
第二输出模块207,用于若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列。The second output module 207 is configured to: if the first data column is not included in the second data column, and/or the first database table where the first data column is located and the second data column are located If the second database table is inconsistent, output data columns that exist in the first data column but not in the second data column, and/or the first database table where the output is located and the second data column where the second data column is located are output. Second, the first data column inconsistent in the database table.
例如,所述第一数据列包括Line1、Line2、Line3、Line4、Line5,所述第二数据列包括Line1、Line2、Line3、Line4,所述第一数据列不包含在所述第二数据列中,输出所述第一数据列中存在而所述第二数据列中不存在的数据列Line5。For example, the first data column includes Line1, Line2, Line3, Line4, Line5, the second data column includes Line1, Line2, Line3, Line4, and the first data column is not included in the second data column. , Output the data row Line5 that exists in the first data row but does not exist in the second data row.
又如,所述第一数据列包括Line1、Line2、Line3、Line4,第一数据列Line1所在的第一数据库表为Table1,第一数据列Line2所在的第一数据库表为Table2,第一数据列Line3所在的第一数据库表为Table3,第一数据列Line4所在的第一数据库表为Table4,所述第二数据列包括Line1、Line2、Line3、Line4、Line5,第二数据列Line1所在的第二数据库表为Table1,第二数据列Line2所在的第二数据库表为Table1,第二数据列Line3 所在的第二数据库表为Table1,第二数据列Line4所在的第二数据库表为Table4,所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列Line2、Line3。For another example, the first data column includes Line1, Line2, Line3, Line4, the first database table where the first data column Line1 is located is Table1, the first database table where the first data column Line2 is located is Table2, and the first data column is The first database table where Line3 is located is Table3, the first database table where the first data column Line4 is located is Table4, the second data column includes Line1, Line2, Line3, Line4, Line5, and the second data column Line1 is located in the second The database table is Table1, the second database table where the second data column Line2 is located is Table1, the second database table where the second data column Line3 is located is Table1, and the second database table where the second data column Line4 is located is Table4. The first database table where a data column is located is not consistent with the second database table where the second data column is located, and the first data column where the first database table where the second data column is located is inconsistent with the second database table where the second data column is located is output. Line2, Line3.
若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,可以发出数据列错误提示或发送数据列错误通知。可以通过语音或文字发出所述数据列错误提示。可以通过邮件、短信、微信等方式将所述数据列错误通知发送给预设联系人。If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, you can issue Data column error prompt or send data column error notification. The data string error prompt can be issued by voice or text. The notification of the data column error can be sent to the preset contact by means of email, SMS, WeChat, etc.
需要说明的是,上述模块204、205与模块206、207的顺序可以互换。上述实施例是先对数据库表进行判断,在其他的实施例中,可以先对数据列进行判断。It should be noted that the order of the aforementioned modules 204 and 205 and the modules 206 and 207 can be interchanged. In the foregoing embodiment, the database table is judged first. In other embodiments, the data column may be judged first.
生成模块208,用于若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件。The generating module 208 is configured to: if the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first data column is located If the first database table of is inconsistent with the second database table where the second data column is located, a table structure file of the database is generated.
所述数据库的表结构文件表示所述数据库包含的所有数据库表和数据库列,以及数据库列与数据库表的对应关系。The table structure file of the database indicates all the database tables and database columns contained in the database, and the correspondence between the database columns and the database tables.
在一具体实施例中,所述方法应用于Java,所述生成所述数据库的表结构文件可以包括:In a specific embodiment, the method is applied to Java, and generating the table structure file of the database may include:
1、读取所述数据库的数据库脚本,将所述数据库脚本解析为对应的java实体类。1. Read the database script of the database, and parse the database script into the corresponding java entity class.
所述java实体类是在JAVA软件开发中广泛使用的概念。所述java实体类是一个包含Set和Get方法的类,通常可和数据库联系在一起。The java entity class is a concept widely used in JAVA software development. The java entity class is a class containing Set and Get methods, and can usually be associated with a database.
所述数据库脚本在创建所述数据库和所述数据库中的数据库表时生成。The database script is generated when the database and the database tables in the database are created.
所述数据库脚本可以包含一个或多个数据表。将所述数据库脚本解析为对应的java实体类就是将所述数据库脚本解析封装为所述一个或多个数据表对应的java实体类。具体地,可以识别所述数据库脚本包含的数据库表,将每个数据库表包含的数据信息解析封装为一个对应的java实体类。也就是说,每个java实体类对应所述数据库脚本中的一个数据表,解析一个所述数据库脚本可以得到对应的一个或多个java实体类。The database script may contain one or more data tables. Parsing the database script into the corresponding java entity class means parsing and packaging the database script into the java entity class corresponding to the one or more data tables. Specifically, the database tables contained in the database script can be identified, and the data information contained in each database table can be parsed and packaged into a corresponding java entity class. In other words, each java entity class corresponds to a data table in the database script, and one or more corresponding java entity classes can be obtained by parsing one database script.
可以通过设定的工具(例如PowerDesigner)导出所述数据库脚本。The database script can be exported through a set tool (such as PowerDesigner).
可以根据接收到的数据库命令导出所述数据库脚本。The database script can be exported according to the received database command.
2、根据所述java实体类生成所述表结构文件。2. Generate the table structure file according to the java entity class.
可以根据实际需要设置所述表结构文件的样式。例如,设置多个数据表标题的样式(包括字体、显示位置等),以及多个表格结构的样式(包括表格尺寸、填充色、数据显示 格式等)。The style of the table structure file can be set according to actual needs. For example, set the style of multiple data table headings (including font, display position, etc.), and the style of multiple table structure (including table size, fill color, data display format, etc.).
在一具体实施例中,所述表结构文件可以包括数据库表、表备注、数据列、数据列备注、数据列类型等。例如,在所述表结构文件中,用“tableName”表示数据库表,用“tableComment”表示表备注,用“columName”表示数据列,用“columComment”表示数据列备注,用“columType”表示数据列类型。In a specific embodiment, the table structure file may include database tables, table remarks, data columns, data column remarks, data column types, and so on. For example, in the table structure file, "tableName" is used for database table, "tableComment" is used for table comment, "columName" is used for data column, "columComment" is used for data column comment, and "columType" is used for data column. Types of.
本实施例中,若所述数据库脚本中包含多个数据表,可以得到对应的多个java实体类。因此,根据所述数据库脚本对应的java实体类生成对应的表结构文件中,也包含多个数据表结构。In this embodiment, if the database script contains multiple data tables, multiple corresponding java entity classes can be obtained. Therefore, the corresponding table structure file generated according to the java entity class corresponding to the database script also contains multiple data table structures.
修正模块209,用于根据所述表结构文件修正所述SQL文件。The correction module 209 is configured to correct the SQL file according to the table structure file.
根据所述表结构文件修正所述SQL文件,就是修正所述SQL文件中所述第一数据库表中存在而所述第二数据库表中不存在的数据库表,和/或修正所述SQL文件中所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或修正所述SQL文件中所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列。Modifying the SQL file according to the table structure file means modifying the database tables that exist in the first database table but not in the second database table in the SQL file, and/or modifying the SQL file Data columns that exist in the first data column but not in the second data column, and/or modify the first database table where the SQL file is located and the second database table where the second data column is located Inconsistent first data column.
对于所述第一数据库表中存在而所述第二数据库表中不存在的数据库表或者所述第一数据列中存在而所述第二数据列中不存在的数据列,可以根据所述表结构文件查找所述第一数据库表中存在而所述第二数据库表中不存在的数据库表的替代数据库表,查找所述第一数据列中存在而所述第二数据列中不存在的数据列的替代数据库列,以所述替代数据库表取代所述SQL文件中所述第一数据库表中存在而所述第二数据库表中不存在的数据库表,以所述替代数据库列取代所述SQL文件中所述第一数据列中存在而所述第二数据列中不存在的数据列。可以根据所述表结构文件中的表备注、数据列备注、数据列类型等确定所述替代数据库表和替代数据库列。For a database table that exists in the first database table but does not exist in the second database table, or a data column that exists in the first data column but does not exist in the second data column, it may be based on the table The structure file searches for a replacement database table for a database table that exists in the first database table but does not exist in the second database table, and searches for data that exists in the first data column but does not exist in the second data column The replacement database column of the column, the replacement database table replaces the database table that exists in the first database table in the SQL file but does not exist in the second database table, and the replacement database column replaces the SQL A data column that exists in the first data column but does not exist in the second data column in the file. The replacement database table and the replacement database column may be determined according to the table remarks, data column remarks, data column type, etc. in the table structure file.
对于所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列,可以根据所述表结构文件查找所述不一致的第一数据列对应的第二数据表,以所述不一致的第一数据列所对应的第二数据表取代所述SQL文件中所述不一致的第一数据列所在的第一数据表。For a first data column that is inconsistent with the first database table in which the second data column is located, the second data table corresponding to the inconsistent first data column may be searched according to the table structure file, The second data table corresponding to the inconsistent first data column is substituted for the first data table in the SQL file where the inconsistent first data column is located.
实施例二的数据库信息分析装置20获取软件项目的SQL文件;提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;查询所述软件项目连接的数据库中所有的第二数据列和所述数据列所在的第二数据库表;判断所述第一数据库表是否包含在所述第二数据库表中;若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表 是否与所述第二数据列所在的第二数据库表一致;若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;根据所述表结构文件修正所述SQL文件。实施例二对软件项目的数据库信息进行分析,当软件项目使用的数据库信息与数据库实际的数据库信息不一致对软件项目的数据库信息进行修正,从而降低软件项目使用的数据库信息与数据库实际的数据库信息不一致的风险,提高软件质量。The database information analysis device 20 of the second embodiment obtains the SQL file of the software project; extracts all the first data columns in the SQL file and the first database table where the first data column is located; queries the database connected to the software project All the second data columns in the data column and the second database table where the data column is located; determine whether the first database table is included in the second database table; if the first database table is not included in the first database table In the second database table, output the database tables that exist in the first database table but not in the second database table; determine whether the first data column is included in the second data column, and determine all Whether the first database table where the first data column is located is consistent with the second database table where the second data column is located; if the first data column is not included in the second data column, and/or the If the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, output data columns that exist in the first data column but not in the second data column, and /Or the first data column where the first database table where the output is located is inconsistent with the second database table where the second data column is located; if the first database table is not included in the second database table, or the If the first data column is not included in the second data column, or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then the database table is generated Structure file; revise the SQL file according to the table structure file. The second embodiment analyzes the database information of the software project. When the database information used by the software project is inconsistent with the actual database information of the database, the database information of the software project is corrected, thereby reducing the inconsistency between the database information used by the software project and the actual database information of the database. The risk of improving software quality.
实施例三Example three
本实施例提供一种非易失性可读存储介质,该非易失性可读存储介质上存储有计算机可读指令,该计算机可读指令被处理器执行时实现上述数据库信息分析方法实施例中的步骤,例如图1所示的101-109;或者,该计算机可读指令被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-209。This embodiment provides a non-volatile readable storage medium having computer readable instructions stored on the non-volatile readable storage medium, and when the computer readable instructions are executed by a processor, the above embodiment of the database information analysis method is implemented The steps in FIG. 1, for example, 101-109 shown in FIG. 1; or, when the computer-readable instruction is executed by a processor, the function of each module in the foregoing apparatus embodiment is realized, for example, modules 201-209 in FIG.
实施例四Example four
图3为本申请实施例四提供的计算机装置的示意图。所述计算机装置30包括存储器301、处理器302以及存储在所述存储器301中并可在所述处理器302上运行的计算机可读指令303,例如数据库信息分析程序。所述处理器302执行所述计算机可读指令303时实现上述数据库信息分析方法实施例中的步骤,例如图1所示的101-109。或者,该计算机可读指令被处理器执行时实现上述装置实施例中各模块的功能,例如图2中的模块201-209。FIG. 3 is a schematic diagram of a computer device provided in Embodiment 4 of this application. The computer device 30 includes a memory 301, a processor 302, and computer-readable instructions 303 stored in the memory 301 and running on the processor 302, such as a database information analysis program. When the processor 302 executes the computer-readable instruction 303, the steps in the embodiment of the database information analysis method described above are implemented, for example, 101-109 shown in FIG. 1. Alternatively, the computer-readable instruction realizes the functions of the modules in the foregoing device embodiment when executed by the processor, for example, the modules 201-209 in FIG. 2.
示例性的,所述计算机可读指令303可以被分割成一个或多个模块,所述一个或者多个模块被存储在所述存储器301中,并由所述处理器302执行,以完成本方法。例如,所述计算机可读指令303可以被分割成图2中的获取模块201、提取模块202、查询模块203、第一判断模块204、第一输出模块205、第二判断模块206、第二输出模块207、生成模块208、修正模块209,各模块具体功能参见实施例二。Exemplarily, the computer-readable instruction 303 may be divided into one or more modules, and the one or more modules are stored in the memory 301 and executed by the processor 302 to complete the method . For example, the computer-readable instruction 303 can be divided into the acquisition module 201, the extraction module 202, the query module 203, the first judgment module 204, the first output module 205, the second judgment module 206, and the second output in FIG. The module 207, the generating module 208, and the correcting module 209, refer to the second embodiment for the specific functions of each module.
所述计算机装置30可以是桌上型计算机、笔记本、掌上电脑及云端服务器等计算设备。本领域技术人员可以理解,所述示意图3仅仅是计算机装置30的示例,并不构成对计算机装置30的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述计算机装置30还可以包括输入输出设备、网络接入设备、总线等。The computer device 30 may be a computing device such as a desktop computer, a notebook, a palmtop computer, and a cloud server. Those skilled in the art can understand that the schematic diagram 3 is only an example of the computer device 30 and does not constitute a limitation on the computer device 30. It may include more or less components than those shown in the figure, or combine certain components, or be different. For example, the computer device 30 may also include input and output devices, network access devices, buses, and so on.
所称处理器302可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器302也可以是任何常规的处理器等,所述处理器302是所述计算机装置30的控制中心,利用各种接口和线路连接整个计算机装置30的各个部分。The so-called processor 302 may be a central processing unit (Central Processing Unit, CPU), other general processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor 302 can also be any conventional processor, etc. The processor 302 is the control center of the computer device 30, which uses various interfaces and lines to connect the entire computer device 30. Various parts.
所述存储器301可用于存储所述计算机可读指令303,所述处理器302通过运行或执行存储在所述存储器301内的计算机可读指令或模块,以及调用存储在存储器301内的数据,实现所述计算机装置30的各种功能。所述存储器301可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据计算机装置30的使用所创建的数据(比如音频数据)。此外,存储器301可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。The memory 301 may be used to store the computer-readable instructions 303, and the processor 302 executes or executes the computer-readable instructions or modules stored in the memory 301 and calls the data stored in the memory 301 to implement Various functions of the computer device 30. The memory 301 may mainly include a storage program area and a storage data area, where the storage program area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.); the storage data area may Data (such as audio data) created in accordance with the use of the computer device 30 is stored. In addition, the memory 301 may include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (SD) card, a flash memory card (Flash Card), At least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device.
所述计算机装置30集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个非易失性可读存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,也可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性可读存储介质中,该计算机可读指令在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机可读指令可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述非易失性可读存储介质可以包括:能够携带所述计算机可读指令的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、只读存储器(ROM,Read-Only Memory)。If the integrated module of the computer device 30 is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a non-volatile readable storage medium. Based on this understanding, this application implements all or part of the processes in the above-mentioned embodiments and methods, and can also be completed by instructing relevant hardware through computer-readable instructions. The computer-readable instructions may be stored in a non-volatile memory. In the storage medium, when the computer-readable instructions are executed by the processor, the steps of the foregoing method embodiments can be implemented. Wherein, the computer-readable instructions may be in the form of source code, object code, executable file, or some intermediate forms. The non-volatile readable storage medium may include: any entity or device capable of carrying the computer readable instructions, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, read-only memory (ROM, Read-Only Memory).
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the application and not to limit them. Although the application has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the application can be Make modifications or equivalent replacements without departing from the spirit and scope of the technical solution of the present application.

Claims (20)

  1. 一种数据库信息分析方法,其特征在于,所述方法包括:A method for analyzing database information, characterized in that the method includes:
    获取软件项目的SQL文件;Obtain the SQL file of the software project;
    提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;Extracting all the first data columns in the SQL file and the first database table where the first data columns are located;
    查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;Querying all the second data columns in the database connected to the software project and the second database table where the second data columns are located;
    判断所述第一数据库表是否包含在所述第二数据库表中;Judging whether the first database table is included in the second database table;
    若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;If the first database table is not included in the second database table, output the database tables that exist in the first database table but do not exist in the second database table;
    判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;Determining whether the first data column is included in the second data column, and determining whether the first database table where the first data column is located is consistent with the second database table where the second data column is located;
    若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then output A data column that exists in the first data column but does not exist in the second data column, and/or the first data in the first database table where the output is located is inconsistent with the second database table where the second data column is located Column
    若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;If the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first database table in which the first data column is located and If the second database table where the second data column is located is inconsistent, a table structure file of the database is generated;
    根据所述表结构文件修正所述SQL文件。Modify the SQL file according to the table structure file.
  2. 如权利要求1所述的方法,其特征在于,所述获取软件项目的SQL文件包括:The method according to claim 1, wherein said obtaining the SQL file of the software project comprises:
    生成SQL文件配置界面,接收用户在所述SQL文件配置界面中设置的软件项目路径,根据所述软件项目路径获取所述SQL文件。Generate a SQL file configuration interface, receive the software project path set by the user in the SQL file configuration interface, and obtain the SQL file according to the software project path.
  3. 如权利要求1所述的方法,其特征在于,所述提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表包括:8. The method according to claim 1, wherein said extracting all the first data columns in said SQL file and the first database table where said first data columns are located comprises:
    根据所述SQL文件中的标签查找目标代码;Searching for the target code according to the tags in the SQL file;
    根据所述目标代码中的关键字提取所述第一数据列和所述第一数据库表。The first data column and the first database table are extracted according to the keywords in the target code.
  4. 如权利要求1所述的方法,其特征在于,所述查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表包括:The method according to claim 1, wherein the querying all the second data columns in the database connected to the software project and the second database table where the second data columns are located comprises:
    获取所述软件项目的数据源信息;Acquiring data source information of the software project;
    根据数据源信息建立与数据库的连接;Establish a connection with the database according to the data source information;
    执行SQL查询语句,查询所述数据库中所有的第二数据列和所述数据列所在的第二数据库表。The SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
  5. 如权利要求1所述的方法,其特征在于,所述生成所述数据库的表结构文件包括:The method according to claim 1, wherein said generating a table structure file of said database comprises:
    读取所述数据库的数据库脚本,将所述数据库脚本解析为对应的java实体类;Read the database script of the database, and parse the database script into the corresponding java entity class;
    根据所述java实体类生成所述表结构文件。The table structure file is generated according to the java entity class.
  6. 如权利要求1-5中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-5, wherein the method further comprises:
    判断所述第二数据库表的数据格式是否正确,若所述第二数据库表的数据格式不正确,则发出数据库格式错误提示。It is determined whether the data format of the second database table is correct, and if the data format of the second database table is incorrect, a database format error prompt is issued.
  7. 如权利要求6所述的方法,其特征在于,所述判断所述第二数据库表的数据格式是否正确包括:7. The method of claim 6, wherein said determining whether the data format of the second database table is correct comprises:
    获取所述第二数据库表中第二数据列的数据类型和数据长度;Acquiring the data type and data length of the second data column in the second database table;
    若所述第二数据列的数据类型与预设数据类型一致且所述第二数据列的数据长度与预设数据长度一致,则所述第二数据库表的数据格式正确。If the data type of the second data column is consistent with the preset data type and the data length of the second data column is consistent with the preset data length, the data format of the second database table is correct.
  8. 一种数据库信息分析装置,其特征在于,所述装置包括:A database information analysis device, characterized in that the device includes:
    获取模块,用于获取软件项目的SQL文件;Obtaining module, used to obtain the SQL file of the software project;
    提取模块,用于提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;An extraction module for extracting all the first data columns in the SQL file and the first database table where the first data columns are located;
    查询模块,用于查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;The query module is used to query all the second data columns in the database connected to the software project and the second database table where the second data columns are located;
    第一判断模块,用于判断所述第一数据库表是否包含在所述第二数据库表中;The first judgment module is used to judge whether the first database table is included in the second database table;
    第一输出模块,用于若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;A first output module, configured to output a database table that exists in the first database table but does not exist in the second database table if the first database table is not included in the second database table;
    第二判断模块,用于判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;The second judgment module is configured to judge whether the first data column is included in the second data column, and whether the first database table where the first data column is located is the same as the first database table where the second data column is located. Two database tables are consistent;
    第二输出模块,用于若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;The second output module is configured to, if the first data column is not included in the second data column, and/or the first database table where the first data column is located and the first database table where the second data column is located If the two database tables are inconsistent, output data columns that exist in the first data column but not in the second data column, and/or the first database table where the output is located and the second data column where the second data column is located are output. The first data column inconsistent in the database table;
    生成模块,用于若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;A generating module, configured to: if the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first data column is located If the first database table is inconsistent with the second database table where the second data column is located, a table structure file of the database is generated;
    修正模块,用于根据所述表结构文件修正所述SQL文件。The correction module is used to correct the SQL file according to the table structure file.
  9. 一种计算机装置,其特征在于,所述计算机装置包括处理器和存储器,所述处理器用于执行所述存储器中存储的计算机可读指令以实现以下步骤:A computer device, characterized in that the computer device includes a processor and a memory, and the processor is configured to execute computer-readable instructions stored in the memory to implement the following steps:
    获取软件项目的SQL文件;Obtain the SQL file of the software project;
    提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;Extracting all the first data columns in the SQL file and the first database table where the first data columns are located;
    查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;Querying all the second data columns in the database connected to the software project and the second database table where the second data columns are located;
    判断所述第一数据库表是否包含在所述第二数据库表中;Judging whether the first database table is included in the second database table;
    若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;If the first database table is not included in the second database table, output the database tables that exist in the first database table but do not exist in the second database table;
    判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;Determining whether the first data column is included in the second data column, and determining whether the first database table where the first data column is located is consistent with the second database table where the second data column is located;
    若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then output A data column that exists in the first data column but does not exist in the second data column, and/or the first data in the first database table where the output is located is inconsistent with the second database table where the second data column is located Column
    若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;If the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first database table in which the first data column is located and If the second database table where the second data column is located is inconsistent, a table structure file of the database is generated;
    根据所述表结构文件修正所述SQL文件。Modify the SQL file according to the table structure file.
  10. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述获取软件项目的SQL文件时,包括:9. The computer device according to claim 9, wherein when the processor executes the computer-readable instructions to implement the obtaining of the SQL file of the software project, the method comprises:
    生成SQL文件配置界面,接收用户在所述SQL文件配置界面中设置的软件项目路径,根据所述软件项目路径获取所述SQL文件。Generate a SQL file configuration interface, receive the software project path set by the user in the SQL file configuration interface, and obtain the SQL file according to the software project path.
  11. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表时,包括:The computer device of claim 9, wherein the processor executes the computer-readable instructions to implement the extraction of all the first data columns in the SQL file and the location where the first data columns are located. The first database table includes:
    根据所述SQL文件中的标签查找目标代码;Searching for the target code according to the tags in the SQL file;
    根据所述目标代码中的关键字提取所述第一数据列和所述第一数据库表。The first data column and the first database table are extracted according to the keywords in the target code.
  12. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列 所在的第二数据库表时,包括:The computer device of claim 9, wherein the processor executes the computer-readable instructions to implement the query for all the second data columns and the second data in the database connected to the software project When the second database table where the column is located, include:
    获取所述软件项目的数据源信息;Acquiring data source information of the software project;
    根据数据源信息建立与数据库的连接;Establish a connection with the database according to the data source information;
    执行SQL查询语句,查询所述数据库中所有的第二数据列和所述数据列所在的第二数据库表。The SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
  13. 如权利要求9所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令以实现所述生成所述数据库的表结构文件时,包括:9. The computer device according to claim 9, wherein when the processor executes the computer-readable instructions to implement the generation of the table structure file of the database, the method comprises:
    读取所述数据库的数据库脚本,将所述数据库脚本解析为对应的java实体类;Read the database script of the database, and parse the database script into the corresponding java entity class;
    根据所述java实体类生成所述表结构文件。The table structure file is generated according to the java entity class.
  14. 如权利要求9-13任一项所述的计算机装置,其特征在于,所述处理器执行所述计算机可读指令时还实现以下步骤:The computer device according to any one of claims 9-13, wherein the processor further implements the following steps when executing the computer-readable instruction:
    判断所述第二数据库表的数据格式是否正确,若所述第二数据库表的数据格式不正确,则发出数据库格式错误提示。It is determined whether the data format of the second database table is correct, and if the data format of the second database table is incorrect, a database format error prompt is issued.
  15. 一种非易失性可读存储介质,所述非易失性可读存储介质上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现以下步骤:A non-volatile readable storage medium having computer readable instructions stored on the non-volatile readable storage medium, characterized in that, when the computer readable instructions are executed by a processor, the following steps are implemented:
    获取软件项目的SQL文件;Obtain the SQL file of the software project;
    提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表;Extracting all the first data columns in the SQL file and the first database table where the first data columns are located;
    查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表;Querying all the second data columns in the database connected to the software project and the second database table where the second data columns are located;
    判断所述第一数据库表是否包含在所述第二数据库表中;Judging whether the first database table is included in the second database table;
    若所述第一数据库表不包含在所述第二数据库表中,则输出所述第一数据库表中存在而所述第二数据库表中不存在的数据库表;If the first database table is not included in the second database table, output the database tables that exist in the first database table but do not exist in the second database table;
    判断所述第一数据列是否包含在所述第二数据列中,以及判断所述第一数据列所在的第一数据库表是否与所述第二数据列所在的第二数据库表一致;Determining whether the first data column is included in the second data column, and determining whether the first database table where the first data column is located is consistent with the second database table where the second data column is located;
    若所述第一数据列不包含在所述第二数据列中,和/或所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则输出所述第一数据列中存在而所述第二数据列中不存在的数据列,和/或输出所在的第一数据库表与所述第二数据列所在的第二数据库表不一致的第一数据列;If the first data column is not included in the second data column, and/or the first database table where the first data column is located is inconsistent with the second database table where the second data column is located, then output A data column that exists in the first data column but does not exist in the second data column, and/or the first data in the first database table where the output is located is inconsistent with the second database table where the second data column is located Column
    若所述第一数据库表不包含在所述第二数据库表中,或者所述第一数据列不包含在所述第二数据列中,或者所述第一数据列所在的第一数据库表与所述第二数据列所在的第二数据库表不一致,则生成所述数据库的表结构文件;If the first database table is not included in the second database table, or the first data column is not included in the second data column, or the first database table in which the first data column is located and If the second database table where the second data column is located is inconsistent, a table structure file of the database is generated;
    根据所述表结构文件修正所述SQL文件。Modify the SQL file according to the table structure file.
  16. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述获取软件项目的SQL文件时,包括:15. The storage medium according to claim 15, wherein when the computer-readable instructions are executed by a processor to implement the obtaining of the SQL file of the software project, the method comprises:
    生成SQL文件配置界面,接收用户在所述SQL文件配置界面中设置的软件项目路径,根据所述软件项目路径获取所述SQL文件。Generate a SQL file configuration interface, receive the software project path set by the user in the SQL file configuration interface, and obtain the SQL file according to the software project path.
  17. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述提取所述SQL文件中所有的第一数据列和所述第一数据列所在的第一数据库表时,包括:The storage medium of claim 15, wherein the computer-readable instructions are executed by a processor to implement the extraction of all the first data columns in the SQL file and the first data column where the first data columns are located. A database table includes:
    根据所述SQL文件中的标签查找目标代码;Searching for the target code according to the tags in the SQL file;
    根据所述目标代码中的关键字提取所述第一数据列和所述第一数据库表。The first data column and the first database table are extracted according to the keywords in the target code.
  18. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述查询所述软件项目连接的数据库中所有的第二数据列和所述第二数据列所在的第二数据库表时,包括:The storage medium according to claim 15, wherein the computer-readable instructions are executed by a processor to implement the query for all the second data columns and the second data columns in the database connected to the software project When the second database table is located, it includes:
    获取所述软件项目的数据源信息;Acquiring data source information of the software project;
    根据数据源信息建立与数据库的连接;Establish a connection with the database according to the data source information;
    执行SQL查询语句,查询所述数据库中所有的第二数据列和所述数据列所在的第二数据库表。The SQL query statement is executed to query all the second data columns in the database and the second database table where the data columns are located.
  19. 如权利要求15所述的存储介质,其特征在于,所述计算机可读指令被处理器执行以实现所述生成所述数据库的表结构文件时,包括:15. The storage medium of claim 15, wherein when the computer-readable instructions are executed by a processor to realize the generation of the table structure file of the database, the method comprises:
    读取所述数据库的数据库脚本,将所述数据库脚本解析为对应的java实体类;Read the database script of the database, and parse the database script into the corresponding java entity class;
    根据所述java实体类生成所述表结构文件。The table structure file is generated according to the java entity class.
  20. 如权利要求15-19任一项所述的存储介质,其特征在于,所述计算机可读指令被处理器执行时还实现以下步骤:18. The storage medium according to any one of claims 15-19, wherein the computer-readable instructions further implement the following steps when being executed by the processor:
    判断所述第二数据库表的数据格式是否正确,若所述第二数据库表的数据格式不正确,则发出数据库格式错误提示。It is determined whether the data format of the second database table is correct, and if the data format of the second database table is incorrect, a database format error prompt is issued.
PCT/CN2019/117416 2019-09-05 2019-11-12 Database information analysis method and apparatus, computer apparatus, and storage medium WO2021042532A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910839266.8A CN110737642B (en) 2019-09-05 2019-09-05 Database information analysis method, database information analysis device, computer device and storage medium
CN201910839266.8 2019-09-05

Publications (1)

Publication Number Publication Date
WO2021042532A1 true WO2021042532A1 (en) 2021-03-11

Family

ID=69267744

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/117416 WO2021042532A1 (en) 2019-09-05 2019-11-12 Database information analysis method and apparatus, computer apparatus, and storage medium

Country Status (2)

Country Link
CN (1) CN110737642B (en)
WO (1) WO2021042532A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114996364A (en) * 2022-04-28 2022-09-02 北京原点数安科技有限公司 Classification and classification method and device for audit logs of PaaS cloud database and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046812A (en) * 2006-06-12 2007-10-03 华为技术有限公司 Method of data base table recording structure and detection and its device
CN101067814A (en) * 2007-05-10 2007-11-07 浪潮集团山东通用软件有限公司 Mapping conversion method between data access level Xml format data and relational data
US9195730B2 (en) * 2010-12-30 2015-11-24 International Business Machines Corporation Verifying correctness of a database system via extended access paths
CN107688618A (en) * 2017-08-08 2018-02-13 平安科技(深圳)有限公司 Data comparison method, apparatus, computer equipment and storage medium
CN108388606A (en) * 2018-02-06 2018-08-10 福建星瑞格软件有限公司 A kind of method and computer equipment verifying library literary name section name in Sql sentences
CN109508355A (en) * 2018-10-19 2019-03-22 平安科技(深圳)有限公司 A kind of data pick-up method, system and terminal device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050149582A1 (en) * 2003-12-29 2005-07-07 Wissmann Joseph T. Method and system for synchronization of copies of a database
US8938424B2 (en) * 2012-10-31 2015-01-20 Ca, Inc. System and method of assessing the state of a database product for installation consistency
CN103929763A (en) * 2013-01-11 2014-07-16 阿尔卡特朗讯 Method for comparison and reconstruction of geographic redundancy database
CN104252481B (en) * 2013-06-27 2018-10-19 阿里巴巴集团控股有限公司 The dynamic check method and apparatus of master-slave database consistency
CN104699748B (en) * 2014-12-19 2018-06-12 深圳市燃气集团股份有限公司 It is a kind of to show the method and its system for being not fixed row report
CN109254969A (en) * 2018-08-31 2019-01-22 平安科技(深圳)有限公司 Tables of data processing method, device, equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101046812A (en) * 2006-06-12 2007-10-03 华为技术有限公司 Method of data base table recording structure and detection and its device
CN101067814A (en) * 2007-05-10 2007-11-07 浪潮集团山东通用软件有限公司 Mapping conversion method between data access level Xml format data and relational data
US9195730B2 (en) * 2010-12-30 2015-11-24 International Business Machines Corporation Verifying correctness of a database system via extended access paths
CN107688618A (en) * 2017-08-08 2018-02-13 平安科技(深圳)有限公司 Data comparison method, apparatus, computer equipment and storage medium
CN108388606A (en) * 2018-02-06 2018-08-10 福建星瑞格软件有限公司 A kind of method and computer equipment verifying library literary name section name in Sql sentences
CN109508355A (en) * 2018-10-19 2019-03-22 平安科技(深圳)有限公司 A kind of data pick-up method, system and terminal device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114996364A (en) * 2022-04-28 2022-09-02 北京原点数安科技有限公司 Classification and classification method and device for audit logs of PaaS cloud database and storage medium

Also Published As

Publication number Publication date
CN110737642B (en) 2022-09-02
CN110737642A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN108762743B (en) Data table operation code generation method and device
US20200401431A1 (en) Adaptive web-based robotic process automation
US8601438B2 (en) Data transformation based on a technical design document
US10789295B2 (en) Pattern-based searching of log-based representations of graph databases
US8417690B2 (en) Automatically avoiding unconstrained cartesian product joins
US20150261507A1 (en) Validating sql queries in a report
US9507751B2 (en) Managing seed data
CN108563694B (en) SQL execution method and device for logic deletion, computer equipment and storage medium
US20160072927A1 (en) Odata enabled mobile software applications
US11487742B2 (en) Consistency checks between database systems
US20180089252A1 (en) Verifying correctness in graph databases
CN112015722A (en) Database management method, data blood relationship analysis method and related device
WO2024152665A1 (en) Code construction method and apparatus, and computer device and storage medium
US10289620B1 (en) Reporting and data governance management
WO2021022702A1 (en) Log insertion method and apparatus, computer apparatus and storage medium
WO2021022703A1 (en) Software project reconstruction method and device, and computer device and storage medium
US10372760B2 (en) Building queries directed to objects hosted on clouds
WO2018076971A1 (en) Xml data manipulation method and apparatus
WO2021042532A1 (en) Database information analysis method and apparatus, computer apparatus, and storage medium
CN111444208B (en) Data updating method and related equipment
CN109271161B (en) Template code generation method and device, storage device and computer device
WO2020024778A1 (en) Method, system and device for modifying xml file in batch and computer-readable storage medium
US10318524B2 (en) Reporting and data governance management
CN115295109A (en) Medical data tracing method and device, storage medium and terminal equipment
US9916154B2 (en) File-based transport of table content

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19944576

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19944576

Country of ref document: EP

Kind code of ref document: A1