CN115878631B - Method and apparatus for altering a table structure of a database table - Google Patents

Method and apparatus for altering a table structure of a database table Download PDF

Info

Publication number
CN115878631B
CN115878631B CN202310054937.6A CN202310054937A CN115878631B CN 115878631 B CN115878631 B CN 115878631B CN 202310054937 A CN202310054937 A CN 202310054937A CN 115878631 B CN115878631 B CN 115878631B
Authority
CN
China
Prior art keywords
field
changed
content
table field
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310054937.6A
Other languages
Chinese (zh)
Other versions
CN115878631A (en
Inventor
梁英宗
陈燕宁
邵亚利
靳梅阳
倪芳
王立城
赵扬
刘芳
付振
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Smartchip Microelectronics Technology Co Ltd
Beijing Core Kejian Technology Co Ltd
Original Assignee
Beijing Smartchip Microelectronics Technology Co Ltd
Beijing Core Kejian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Smartchip Microelectronics Technology Co Ltd, Beijing Core Kejian Technology Co Ltd filed Critical Beijing Smartchip Microelectronics Technology Co Ltd
Priority to CN202310054937.6A priority Critical patent/CN115878631B/en
Publication of CN115878631A publication Critical patent/CN115878631A/en
Application granted granted Critical
Publication of CN115878631B publication Critical patent/CN115878631B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to the field of chips, in particular to the field of production process data informatization, and discloses a method and a device for changing a table structure of a database table. The method comprises the following steps: modifying a preset database field table and/or a preset data content table according to the change operation and the change item; acquiring list field name information and list field content information from a preset database field list and a preset data content list based on the data type identifier to be changed; and generating a database table based on the acquired table field name information and table field content information to obtain a changed database table. Thereby, a table structure of the change database table is realized.

Description

Method and apparatus for altering a table structure of a database table
Technical Field
The present invention relates to the field of chips, and more particularly, to the field of production process data informatization, and in particular, to a method and apparatus for changing a table structure of a database table.
Background
At present, domestic industrial chips face the problems of decentralized quality control, disordered basic data information and upstream and downstream data chain breakage, and the reason for the problems is that a unified data model and interface for the industrial chip quality basic information are lacking, so that an industrial chip quality basic information database needs to be established to solve the problems. In order to hierarchically and standardize the storage of large data generated in the whole production process (streaming, packaging, testing) of industrial chips, various types of database table sets need to be created for unstructured data such as device processes, circuit designs, packaging materials, and chip functional performance and reliability tests. However, on one hand, various data lack unified specifications and standards, users cannot clearly provide table fields of the database at the beginning of database development, new requirements are continuously put forward in the development process, and the table fields are modified frequently; on the other hand, the relational database has a problem of originally fixed table structure and lacking flexibility. Finally, the system development is performed under the condition that the requirement is ambiguous, so that a large amount of invalid reworking is caused, manpower and material resources and financial resources are wasted, the risk of project warranty delivery is increased, and potential safety hazards are buried in the system stability. In addition, the table structure of the database is not clear in the initial development stage, the data structure is complex and changeable due to the requirement of users, but the table structure of the traditional relational database is fixed once created, and the correct execution of the front end and the back end codes of the system can be influenced if the table structure is required to be modified in the later stage, and even the stable operation of the whole system is affected in severe cases. In addition, if a large amount of data is already recorded in the fixed table structure of the relational database, the adjustment of the original table structure not only increases the workload of data re-entry, but also can cause the loss and damage of the data in the process.
Disclosure of Invention
It is an aim of embodiments of the present invention to provide a method and apparatus for altering the table structure of a database table which solves or at least partially solves the above mentioned problems.
To achieve the above object, an aspect of an embodiment of the present invention provides a method for changing a table structure of a database table, the method including: modifying a preset database field table and/or a preset data content table according to a change operation and a change item, wherein the change item comprises a to-be-changed data type identifier, a to-be-changed table field name and a to-be-changed table field identifier corresponding to the to-be-changed table field name of the to-be-changed database table corresponding to the change operation, the preset database field table stores data type identifier and table field name information, the data type identifier corresponds to at least one piece of table field name information in the preset database field table, the table field name information comprises a table field name, a table field sequence and a table field identifier, the table field name, the table field sequence and the table field identifier correspond to each other, the preset data content table stores the data type identifier and table field content information, and the table field content information comprises the data type identifier and at least one piece of table field content information corresponding to the table field identifier and the table field identifier corresponding to the table field identifier; acquiring the table field name information and the table field content information from the preset database field table and the preset data content table based on the data type identifier to be changed; and generating the database table based on the acquired table field name information and table field content information to obtain a changed database table.
Optionally, the change item further includes to-be-changed content, where the to-be-changed content includes to-be-changed table field content and/or to-be-changed table field sequence.
Optionally, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: when the change operation is table field addition, the to-be-changed content comprises the to-be-changed table field content and the to-be-changed table field sequence, and table field information aiming at the to-be-changed data type identifier, the to-be-changed table field name, the to-be-changed table field sequence and the to-be-changed table field identifier is stored in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; adding a field identifier of the table to be changed according to the table field content information corresponding to the type identifier of the data to be changed in the preset data content table; at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table; receiving the setting of the table field content corresponding to the to-be-changed table field name by a user, and storing the set table field content in the table field content information corresponding to the added to-be-changed table field identifier so as to modify the preset data content table; and/or in the case that the change operation is table field modification and the content to be changed includes the table field content to be changed, the table field name to be changed includes a substitute table field name and a substituted table field name, and in the preset database field table, for the table field information corresponding to the data type identifier to be changed, the substitute table field name is substituted for the substituted table field name, so as to modify the preset database field table; for the preset data content table, at least displaying the name of the substitute table field corresponding to the field identification of the table to be changed; receiving the setting of the table field content corresponding to the substitute table field name by a user, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table; and/or under the condition that the change operation is table field ordering, the to-be-changed content comprises the to-be-changed table field sequence, and in the preset database field table, aiming at the table field information corresponding to the to-be-changed data type identifier, the table field sequence of the to-be-changed table field name is modified into the to-be-changed table field sequence so as to modify the preset database field table.
Optionally, in the case that the change operation is table field deletion, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: deleting table field information corresponding to the data type identifier to be changed and the table field name to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; and deleting the table field identification to be changed and the table field content corresponding to the table field identification to be changed aiming at the table field content information corresponding to the data type identification to be changed in the preset data content table so as to modify the preset data content table.
Optionally, in the case that the change operation is table field modification, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: and in the preset database field table, replacing the replaced table field name with the replaced table field name aiming at the table field information corresponding to the data type identifier to be changed so as to modify the preset database field table.
Accordingly, another aspect of an embodiment of the present application provides an apparatus for changing a table structure of a database table, the apparatus comprising: the modification module is used for modifying a preset database field table and/or a preset data content table according to modification operation and modification matters, wherein the modification matters comprise to-be-modified data type identifiers, to-be-modified table field names and to-be-modified table field identifiers corresponding to-be-modified table field names corresponding to the modification operation, the preset database field table stores data type identifiers and table field name information, the data type identifiers correspond to at least one piece of table field name information in the preset database field table, the table field name information comprises table field names, table field sequences and table field identifiers, the table field names, the table field sequences and the table field identifiers correspond to each other, the preset data content table stores the data type identifiers and table field content information, the table field content information comprises the table field identifiers and the table field names corresponding to the table field identifiers; the acquisition module is used for acquiring the table field name information and the table field content information from the preset database field table and the preset data content table based on the data type identifier to be changed; and the generation module is used for generating the database table based on the acquired table field name information and the table field content information so as to obtain a changed database table.
Optionally, the change item further includes to-be-changed content, where the to-be-changed content includes to-be-changed table field content and/or to-be-changed table field sequence.
Optionally, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: when the change operation is table field addition, the to-be-changed content comprises the to-be-changed table field content and the to-be-changed table field sequence, and table field information aiming at the to-be-changed data type identifier, the to-be-changed table field name, the to-be-changed table field sequence and the to-be-changed table field identifier is stored in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; adding a field identifier of the table to be changed according to the table field content information corresponding to the type identifier of the data to be changed in the preset data content table; at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table; receiving the setting of the table field content corresponding to the to-be-changed table field name by a user, and storing the set table field content in the table field content information corresponding to the added to-be-changed table field identifier so as to modify the preset data content table; and/or in the case that the change operation is table field modification and the content to be changed includes the table field content to be changed, the table field name to be changed includes a substitute table field name and a substituted table field name, and in the preset database field table, for the table field information corresponding to the data type identifier to be changed, the substitute table field name is substituted for the substituted table field name, so as to modify the preset database field table; for the preset data content table, at least displaying the name of the substitute table field corresponding to the field identification of the table to be changed; receiving the setting of the table field content corresponding to the substitute table field name by a user, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table; and/or under the condition that the change operation is table field ordering, the to-be-changed content comprises the to-be-changed table field sequence, and in the preset database field table, aiming at the table field information corresponding to the to-be-changed data type identifier, the table field sequence of the to-be-changed table field name is modified into the to-be-changed table field sequence so as to modify the preset database field table.
Optionally, in the case that the change operation is table field deletion, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: deleting table field information corresponding to the data type identifier to be changed and the table field name to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; and deleting the table field identification to be changed and the table field content corresponding to the table field identification to be changed aiming at the table field content information corresponding to the data type identification to be changed in the preset data content table so as to modify the preset data content table.
Optionally, in the case that the change operation is table field modification, the modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: and in the preset database field table, replacing the replaced table field name with the replaced table field name aiming at the table field information corresponding to the data type identifier to be changed so as to modify the preset database field table.
In addition, another aspect of the embodiments of the present application further provides a processor configured to perform the above method.
Additionally, another aspect of the embodiments also provides a machine-readable storage medium having instructions stored thereon, which when executed by a processor, cause the processor to be configured to perform the above-described method.
Furthermore, another aspect of the embodiments of the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the above-described method.
According to the technical scheme, the preset database field table and the preset data content table are modified according to the changing operation and the changing matters, wherein the content of the preset database field table and the preset data content table for the same database table is related based on the data type identification, after the modification operation is completed, the table structure of the database table is changed based on the data type identification of the database table to be changed corresponding to the changing operation, table field name information and table field content information corresponding to the data type identification of the database table to be changed corresponding to the changing operation are obtained from the preset database field table and the preset data content table, the database table is generated based on the obtained table field name information and table field content information, so that the change of the table structure of the database table is completed, and the problems of fixed table structure and lack of flexibility of the database table are solved; the method has the advantages that the table structure of the database table is changed, the database table can be developed under the condition that the requirement on the database table is not clear, and the table structure can be changed later, so that rework is not needed after the development is completed, a large amount of reworking probability is reduced, waste of manpower, material resources and financial resources is reduced, the risk of project quality and quantity guarantee delivery is reduced, and the potential safety hazard for system safety is reduced; the table structure of the database table is changed, and after the database table is established in the early stage, if the table structure is changed in the later stage, the correct execution of the front end and the back end codes can not be influenced, and the stable operation of the system can not be influenced; in addition, the data is not required to be re-recorded when the table structure is changed, so that the workload of data re-recording is reduced, and the probability of data loss and damage is reduced.
Drawings
FIG. 1 is a flow chart of a method for altering a table structure of a database table provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of table fields in a table of encapsulating materials provided in accordance with another embodiment of the present application;
FIG. 3 is a schematic diagram of table fields in a table of encapsulating materials provided in accordance with another embodiment of the present application;
FIG. 4 is a schematic diagram of a data_type table provided by another embodiment of the present application;
FIG. 5 is a schematic diagram of the relationship among a data_column table, a data_type table, and a data_content table provided by another embodiment of the present application; and
fig. 6 is a schematic structural diagram of an apparatus for changing a table structure of a database table according to another embodiment of the present application.
Description of the reference numerals
1. Modifying the module; 2. an acquisition module; 3. and generating a module.
Detailed Description
The following describes specific embodiments of the present invention in detail with reference to the drawings. It should be understood that the detailed description and specific examples, while indicating and illustrating the invention, are not intended to limit the invention. One aspect of an embodiment of the present application provides a method for altering a table structure of a database table.
FIG. 1 is a flow chart of a method for altering a table structure of a database table provided in an embodiment of the present application. As shown in fig. 1, the method includes the following.
In step S10, the preset database field table and/or the preset data content table is modified according to the change operation and the change item. Wherein the change operation is any operation that can be performed on the table structure, e.g., the change operation may be a table field append, a table field modify, a table field sort, a table field delete, etc. The change event may include a to-be-changed data type identifier of the to-be-changed database table corresponding to the change operation, a to-be-changed table field identifier corresponding to the to-be-changed table field name and the to-be-changed table field name, that is, the change event indicates that the data type identifier and the table field name of the database table need to be changed.
In addition, the preset database field table stores data type identifiers and table field name information, the data type identifiers correspond to at least one piece of table field name information in the preset database field table, the number of pieces of table field name information corresponding to one data type identifier depends on the number of table fields in the database table corresponding to the data type identifier, and one data type identifier corresponds to one database table; the table field name information includes a table field name, a table field order, and a table field identification, which are in one-to-one correspondence. In addition, in the preset database field table, identification may be used to distinguish one piece of data including a data type identification and a table field information. For example, referring to one piece of data in the preset database field table shown in table 1, wherein data_column_id is an identifier of one piece of data in the preset database field table, and the database field table identifier is used for distinguishing the same data type identifier from corresponding different table field name information; the data_type_id is a data type identifier, the name is a table field name, the order_index is a table field sequence, the column_code is a table field identifier, and the data_column table is a preset database field table.
TABLE 1
Fields Description of the invention
data_column_id Id of data_column table
data_type_id Id of data_type table
name Table field name
order_index Table field order
column_code Table field identification
In addition, the preset data content table stores data type identifiers and table segment content information, the data type identifiers and at least one piece of table segment content information are corresponding to the preset data content table, the number of pieces of table segment content information corresponding to one data type identifier depends on the number of rows of data in the database table corresponding to the data type identifier, and one row of data corresponds to one table segment content information; the table field content information comprises table field identifiers and table field contents corresponding to table field names corresponding to the table field identifiers, wherein the table field identifiers are in one-to-one correspondence with the table field contents; the table field identification points to a table field name, and when the table field name to which the table field identification points is modified, the table field content corresponding to the table field identification will correspond to the modified table field name. Additionally, in embodiments of the present application, the table field identification and table field content may be stored in key-value pairs. In addition, in the preset data content table, identification may be used to distinguish one piece of data including a data type identification and a table field content information. For example, referring to one piece of data in the preset data content table shown in table 2, where data_content_id is an identifier of one piece of data in the preset data content table, the data content table identifier is used to distinguish that the same data type identifier corresponds to different table field content information, and one data_content_id corresponds to one line of data in the database table; the data_content table is a preset data content table, the data_type_id is a data type identifier, and the content is table field content information.
TABLE 2
Fields Description of the invention
data_content_id Id of data_content table
data_type_id Id of data_type table
content Table field content information
In the embodiment of the present application, the data for the same database table are stored in the preset database field table and the preset data content table respectively. The method comprises the steps that table field names and table field sequences are stored in a preset database field table, and table field contents are stored in a preset data content table; the data of the same database table in the preset database field table and the preset data content table are associated with the table field identifier through a data type identifier, wherein the data type identifier represents the database table, and the table field identifier points to the table field name. The table field names and the table field contents included in the database table can be obtained from the preset database field table and the preset data content table based on the data type identifiers corresponding to the database table, and the table field names and the table field contents are corresponding based on the table field identifiers, so that the database table can be obtained. In addition, when a table field name is modified in the preset database field table, the table field identifier corresponding to the table field name points to the modified table field name, and further the modified table field name is displayed when the related content in the preset data content table is displayed.
In step S11, table field name information and table field content information are acquired from a preset database field table and a preset data content table based on the data type identifier to be changed. The method comprises the steps that data of different database tables are stored in a preset database field table and a preset data content table, and table field name information and table field content information corresponding to the database table to be changed corresponding to a change operation are obtained from the preset database field table and the preset data content table based on the type identification of the data to be changed of the database table to be changed corresponding to the change operation.
In step S12, a database table is generated based on the acquired table field name information and table field content information to obtain a changed database table. The obtained table field name information and table field content information indicate the table field names included in the database table and the table field content corresponding to each table field name, and then a data table can be generated.
According to the technical scheme, the preset database field table and the preset data content table are modified according to the changing operation and the changing matters, wherein the content of the preset database field table and the preset data content table for the same database table is related based on the data type identification, after the modification operation is completed, the table structure of the database table is changed based on the data type identification of the database table to be changed corresponding to the changing operation, table field name information and table field content information corresponding to the data type identification of the database table to be changed corresponding to the changing operation are obtained from the preset database field table and the preset data content table, the database table is generated based on the obtained table field name information and table field content information, so that the change of the table structure of the database table is completed, and the problems of fixed table structure and lack of flexibility of the database table are solved; the method has the advantages that the table structure of the database table is changed, the database table can be developed under the condition that the requirement on the database table is not clear, and the table structure can be changed later, so that rework is not needed after the development is completed, a large amount of reworking probability is reduced, waste of manpower, material resources and financial resources is reduced, the risk of project quality and quantity guarantee delivery is reduced, and the potential safety hazard for system safety is reduced; the table structure of the database table is changed, and after the database table is established in the early stage, if the table structure is changed in the later stage, the correct execution of the front end and the back end codes can not be influenced, and the stable operation of the system can not be influenced; in addition, the data is not required to be re-recorded when the table structure is changed, so that the workload of data re-recording is reduced, and the probability of data loss and damage is reduced.
In the embodiment of the present application, the changing operation may be directed to the table field name, or may be directed to the table field content and/or the table field sequence. Optionally, in an embodiment of the present application, the change event further includes to-be-changed content, where the to-be-changed content includes to-be-changed table field content and/or to-be-changed table field sequence.
Optionally, in an embodiment of the present application, modifying the preset database field table and/or the preset data content table according to the change operation and the change item may include the following.
In the case that the change operation is table field addition (adding table field names), the to-be-changed content includes to-be-changed table field content and to-be-changed table field sequence, and table field information for the to-be-changed data type identifier, the to-be-changed table field name, the to-be-changed table field sequence and the to-be-changed table field identifier is stored in the preset database field table to modify the preset database field table, wherein the table field information includes database field table identifier, data type identifier and table field name information. As shown in table 1, a piece of data including data_column_id, data_type_ id, name, order _index, and column_code is a piece of table field information. In addition, the stored table field information is newly added data for the table field, and a plurality of pieces of table field information are added by adding a plurality of table fields. And adding a field identifier of the table to be changed according to the table field content information corresponding to the type identifier of the data to be changed in the preset data content table. Specifically, in the preset data content table, adding a table-to-be-changed field identifier for each table field content information corresponding to the type identifier of the data to be changed, and adding a table-to-be-changed field identifier corresponding to each table field name of the table to be changed for each table field content information. And at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table. Specifically, the table field identifier points to the table field name, after the data content table is preset, the table field identifier corresponding to the table field name to be changed is preset in the data content table, and according to the type identifier of the data to be changed and the table field identifier to be changed, the table field name to be changed corresponding to the table field identifier to be changed can be obtained by combining the preset database field table, and the table field name to be changed can be displayed. In addition, the to-be-changed data type identifier corresponds to the content information of the several table segments, and then the names of the several table segments to be changed are displayed. In addition, for the data type identifier to be changed, other table field names can be obtained through other table field identifiers, and other table field names and corresponding table field contents can be displayed. In addition, referring to table 2, data_content_id and data_type_id may be displayed as well, and displayed in correspondence relation shown in table 2, one piece of data including data_content_id, data_type_id, and a table field name and a corresponding table field content corresponding to one line of data in the database table. Receiving the setting of the table field content corresponding to the table field name to be changed by a user, and storing the set table field content in the table field content information corresponding to the added table field name to be changed so as to modify the preset data content table.
And/or, in the case that the change operation is a table field modification and the contents to be changed include contents of a table field to be changed, the table field name to be changed includes a substitute table field name and a substituted table field name. In the preset database field table, aiming at the table field information corresponding to the data type identifier to be changed, replacing the replaced table field name with the replaced table field name so as to modify the preset database field table. It should be noted that, in the embodiment of the present application, a change may be performed for a plurality of table field names, so long as it is identified that it is clear which alternate table field name is used instead of which alternate table field name. And displaying at least the name of the substitute table field corresponding to the field identification of the table to be changed in the preset data content table. According to the analysis, the table field names corresponding to the table field identifiers are changed when the replaced table field names are used for replacing the replaced table field names, and the replaced table field names are obtained based on the table field identifiers to be changed. Further, after the substitution, the contents displayed for the preset data contents table may refer to the related contents in the table field addition. And receiving the setting of the table field content corresponding to the replaced table field name by the user, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table.
And/or under the condition that the change operation is the list field ordering, the to-be-changed content comprises a list field sequence to be changed, and in the preset database field list, aiming at the list field information corresponding to the to-be-changed data type identification, the list field sequence of the list field name to be changed is changed into the list field sequence to be changed so as to modify the preset database field list.
Optionally, in an embodiment of the present application, in a case where the change operation is a table field deletion, modifying the preset database field table and/or the preset data content table according to the change operation and the change item may include the following. And deleting the table field information corresponding to the data type identifier to be changed and the table field name to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises the database field table identifier, the data type identifier and the table field name information. In a preset database field table, one piece of table field information can be determined based on the data type identifier and the table field name, and the table field information corresponding to the data type identifier to be changed and the table field name to be changed is deleted, so that the table field name to be changed is deleted in the database table. And deleting the to-be-changed table field identification and the table field content corresponding to the to-be-changed table field identification aiming at the table field content information corresponding to the to-be-changed data type identification in the preset data content table so as to modify the preset data content table. And deleting the field identification of the table to be changed and the table field content corresponding to the field identification of the table to be changed in the preset data content table, so as to realize deleting the table field content corresponding to the table field name of the database table to be changed.
Optionally, in an embodiment of the present application, in a case where the change operation is a table field modification, modifying the preset database field table and/or the preset data content table according to the change operation and the change item may include the following. Wherein in this embodiment merely modifying the table field name does not modify the table field content. In the preset database field table, aiming at the table field information corresponding to the data type identifier to be changed, replacing the replaced table field name with the replaced table field name so as to modify the preset database field table.
Alternatively, in the embodiment of the present application, the type identifier of the data to be changed may be obtained in various manners. For example, a preset correspondence between the database table and the data type identifier is preset, the user inputs the database table to be changed, and the data type identifier to be changed of the database table to be changed is determined based on the preset correspondence. In addition, a data type identifier corresponding to the database table can be set, the user selects the data type identifier to be changed of the database table to be changed, and the selection of the user is received so as to obtain the data type identifier to be changed. For example, a preset data type table is used to store the data type identifier corresponding to the database table. For example, referring to table 3, the data_type_id is a data type identifier, and a database table corresponds to a data type identifier, where the data_type table is a preset data type table. And the user selects the data_type_id of the database table to be changed of the field of the change table to obtain the type identifier of the data to be changed.
TABLE 3 Table 3
Fields Description of the invention
data_type_id Id of data_type table
The following describes the technical solutions provided in the embodiments of the present application by taking the encapsulating material table as an example with reference to tables 1 to 3 and fig. 2.
As shown in FIG. 2, the database package material table contains the names of the words of manufacturer, product, description, tg/. Degree.C, CTE1 (10-6/. Degree.C), CTE2 (10-6/. Degree.C), flexural modulus/MPa, flexural strength/GPa and the like, and the names of the words displayed by the front page are stored in the data_column table in the form of data record, and the structure is shown in Table 1.
Referring to table 1, taking the example of adding the table field name "hygroscopicity (85 ℃/85% rh,168 h)" to the encapsulation material table, the added table field name is written in the data_column table in the format of (data_column_id, data_type_id=d829d7d05d05b8e01bc fde1f0f2c, name=hygroscopicity (85 ℃/85% rh,168 h), order_index, column_code), wherein data_column_id is the unique primary key, data_type_id is the external key of the data_column table, the primary key of the data_type table, the entire table field name of the encapsulation material table is retrieved in the data_column table through the data_type_id, and the specific table field name is stored in the name field. As shown in FIG. 3, "hygroscopicity (85 ℃ C./85% RH,168 h)" has been increased.
In addition, in the embodiment of the present application, the data record in the encapsulating material table is stored in the content field of the data_content table in the manner of { "field 1": "value 1", "field 2": "value 2",.+ -. And "field N": "value N" } key value pair, as shown in table 2, where field 1, field 2 … … field N is the table field identifier described in the embodiment of the present application, i.e. column_code, and value 1, value 2 … … value N is the table field content described in the embodiment of the present application.
The data_type table stores data_type_id including a data type name and a type (WAT, CP, DOE, general data type, repository type) to which data corresponds, etc., as shown in table 3, as shown in fig. 4. All the created data types can be queried through the data_type table as shown in fig. 4. Further, in fig. 4, one line of data corresponds to one data_type_id, and one data_type_id corresponds to one database table.
The E-R relationship among the data_column table, the data_content table, and the data_type table is shown in fig. 5, one piece of data in the data_type table represents a data type identifier, and the name field in the data_column table stores a table field name corresponding to a plurality of pieces of data in the data_column table. When a custom table field name is newly added in the data_column table, the data corresponding to the table field name is stored in the data_content table. Therefore, the relation between the data_column table and the data_content table is many-to-many, and the relation between the two tables is established through the data_type table. And constructing a table-to-table relationship to form a custom table field and realizing a table field data maintenance function.
In summary, the technical solution provided in the embodiments of the present application implements the construction of a non-fixed table structure of a relational database through reasonable design between tables, so as to implement the function of customizing the table field to implement data storage according to different user requirements. In addition, the technical scheme provided by the embodiment of the application relates to the field of chips, in particular to the field of production process data informatization, a non-fixed and extensible database table structure is designed on the basis of a relational database, so that the service requirement that a user can still change table fields on the premise of not influencing the normal operation of a system after generating a relational database table is met, and the problem that the robustness of the system is influenced due to the fact that the requirement change and the repeated change of the database table structure in the whole life cycle of database development and operation is solved. In addition, the technical scheme provided by the embodiment of the application builds a non-fixed and extensible database table structure on the basis of the relational database, and allows a user to modify, add, delete and sort the table fields of the table on the basis of the generated database table; the technical scheme provided by the embodiment of the application is high in expandability, breaks through the constraint that the table structure is fixed once the database table in the relational database is created, and is suitable for developing a system in which the design of the table field of the database table is not clear for the initial user and the table field is required to be changed in the later period.
Accordingly, another aspect of the embodiments of the present application provides an apparatus for altering a table structure of a database table.
Fig. 6 is a block diagram of an apparatus for changing a table structure of a database table according to another embodiment of the present application. As shown in fig. 6, the apparatus includes a modification module 1, an acquisition module 2, and a generation module 3. The modification module 1 is configured to modify a preset database field table and/or a preset data content table according to a modification operation and a modification item, where the modification item includes a to-be-modified data type identifier of the to-be-modified database table corresponding to the modification operation, a to-be-modified table field name corresponding to the to-be-modified table field name, a to-be-modified table field identifier corresponding to the to-be-modified table field name, a preset database field table storing data type identifier and table field name information, and a data type identifier corresponding to at least one table field name information in the preset database field table, the table field name information including a table field name, a table field order, and a table field identifier, the table field name, the table field order, and the table field identifier corresponding to one another, and the preset data content table storing data type identifier and table field content information corresponding to at least one table field content corresponding to the table field name, the table field identifier corresponding to the table field identifier; the acquisition module 2 is used for acquiring table field name information and table field content information from a preset database field table and a preset data content table based on the data type identifier to be changed; the generating module 3 is configured to generate a database table based on the acquired table field name information and table field content information, so as to obtain a changed database table.
Optionally, in an embodiment of the present application, the change event further includes to-be-changed content, where the to-be-changed content includes to-be-changed table field content and/or to-be-changed table field sequence.
Optionally, in an embodiment of the present application, modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: when the change operation is table field addition, the content to be changed comprises table field content to be changed and table field sequence to be changed, and table field information aiming at a data type identifier to be changed, a table field name to be changed, the table field sequence to be changed and the table field identifier to be changed is stored in a preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; adding a field identifier of the table to be changed according to table field content information corresponding to the type identifier of the data to be changed in a preset data content table; at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table; receiving the setting of the table field content corresponding to the table field name to be changed by a user, and storing the set table field content in the table field content information corresponding to the added table field name to be changed so as to modify the preset data content table; and/or when the change operation is table field modification and the content to be changed comprises table field content to be changed, the table field name to be changed comprises a substitute table field name and a substituted table field name, and in the preset database field table, the substitute table field name is used for substituting the substituted table field name for table field information corresponding to the type identifier of the data to be changed so as to modify the preset database field table; at least displaying the name of the substitute table field corresponding to the field identification of the table to be changed aiming at a preset data content table; receiving the setting of a user on the table field content corresponding to the replaced table field name, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table; and/or under the condition that the change operation is the list field ordering, the to-be-changed content comprises the list field sequence to be changed, and in the preset database field list, aiming at the list field information corresponding to the to-be-changed data type identification, the list field sequence of the list field name to be changed is changed into the list field sequence to be changed so as to modify the preset database field list.
Optionally, in an embodiment of the present application, in a case where the change operation is a table field deletion, modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: deleting table field information corresponding to the data type identifier to be changed and the table field name to be changed in a preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; and deleting the table field identification to be changed and the table field content corresponding to the table field identification to be changed aiming at the table field content information corresponding to the data type identification to be changed in the preset data content table so as to modify the preset data content table.
Optionally, in an embodiment of the present application, in a case where the change operation is table field modification, modifying the preset database field table and/or the preset data content table according to the change operation and the change item includes: in the preset database field table, aiming at the table field information corresponding to the data type identifier to be changed, replacing the replaced table field name with the replaced table field name so as to modify the preset database field table.
The specific working principle and benefits of the apparatus for changing a table structure of a database table provided in the embodiment of the present application are similar to those of the method for changing a table structure of a database table provided in the embodiment of the present application, and will not be described herein.
The device for changing the table structure of the database table comprises a processor and a memory, wherein the modification module, the acquisition module, the generation module and the like are all stored in the memory as program units, and the processor executes the program modules stored in the memory to realize corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel may be provided with one or more kernel parameters to implement the monitoring method described in the above embodiment.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
In addition, another aspect of the embodiments of the present application further provides a processor configured to perform the method described in the above embodiments.
Additionally, another aspect of the embodiments also provides a machine-readable storage medium having stored thereon instructions that, when executed by a processor, cause the processor to be configured to perform the method described in the embodiments.
Furthermore, another aspect of the embodiments of the present application provides a computer program product comprising a computer program which, when executed by a processor, implements the method described in the embodiments.
In addition, another aspect of the embodiments of the present application further provides an apparatus, where the apparatus includes a processor, a memory, and a program stored on the memory and capable of running on the processor, and the processor executes the program to implement the method described in the foregoing embodiments.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer-readable media include both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (12)

1. A method for altering a table structure of a database table, the method comprising:
modifying a preset database field table and/or a preset data content table according to a change operation and a change item, wherein the change item comprises a to-be-changed data type identifier, a to-be-changed table field name and a to-be-changed table field identifier corresponding to the to-be-changed table field name of the to-be-changed database table corresponding to the change operation, the preset database field table stores data type identifier and table field name information, the data type identifier corresponds to at least one piece of table field name information in the preset database field table, the table field name information comprises a table field name, a table field sequence and a table field identifier, the table field name, the table field sequence and the table field identifier correspond to each other, the preset data content table stores the data type identifier and table field content information, and the table field content information comprises the data type identifier and at least one piece of table field content information corresponding to the table field identifier and the table field identifier corresponding to the table field identifier;
Acquiring the table field name information and the table field content information from the preset database field table and the preset data content table based on the data type identifier to be changed; and
and generating the database table based on the acquired table field name information and the table field content information to obtain a changed database table.
2. The method of claim 1, wherein the change event further comprises to-be-changed content comprising to-be-changed table field content and/or to-be-changed table field order.
3. The method according to claim 2, wherein modifying the preset database field table and/or the preset data content table according to the change operation and the change item comprises:
in the case where the change operation is a table field addition, the contents to be changed include the contents of the table field to be changed and the order of the table field to be changed,
storing table field information aiming at the data type identifier to be changed, the table field name to be changed, the table field sequence to be changed and the table field identifier to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information;
Adding a field identifier of the table to be changed according to the table field content information corresponding to the type identifier of the data to be changed in the preset data content table;
at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table; and
receiving the setting of the table field content corresponding to the table field name to be changed by a user, and storing the set table field content in the table field content information corresponding to the added table field identifier to be changed so as to modify the preset data content table; and/or
In the case where the change operation is a table field modification and the contents to be changed include the contents of the table field to be changed, the table field name to be changed includes a substitute table field name and a substituted table field name,
in the preset database field table, for the table field information corresponding to the data type identifier to be changed, replacing the replaced table field name with a replaced table field name so as to modify the preset database field table;
for the preset data content table, at least displaying the name of the substitute table field corresponding to the field identification of the table to be changed; and
Receiving the setting of the table field content corresponding to the substitute table field name by a user, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table; and/or
And under the condition that the change operation is list field ordering, the content to be changed comprises the list field sequence to be changed, and in the preset database field list, aiming at the list field information corresponding to the data type identifier to be changed, the list field sequence of the list field name to be changed is modified into the list field sequence to be changed so as to modify the preset database field list.
4. The method of claim 1, wherein, in the case where the change operation is a table field deletion, the modifying the preset database field table and/or the preset data content table according to the change operation and the change event comprises:
deleting table field information corresponding to the data type identifier to be changed and the table field name to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; and
And deleting the table field identification to be changed and the table field content corresponding to the table field identification to be changed aiming at the table field content information corresponding to the data type identification to be changed in the preset data content table so as to modify the preset data content table.
5. The method according to claim 1, wherein, in case the change operation is a table field modification, the modifying the preset database field table and/or the preset data content table according to the change operation and the change transaction comprises:
and in the preset database field table, replacing the replaced table field name with the replaced table field name aiming at the table field information corresponding to the data type identifier to be changed so as to modify the preset database field table.
6. An apparatus for altering a table structure of a database table, the apparatus comprising:
the modification module is used for modifying a preset database field table and/or a preset data content table according to modification operation and modification matters, wherein the modification matters comprise to-be-modified data type identifiers, to-be-modified table field names and to-be-modified table field identifiers corresponding to-be-modified table field names corresponding to the modification operation, the preset database field table stores data type identifiers and table field name information, the data type identifiers correspond to at least one piece of table field name information in the preset database field table, the table field name information comprises table field names, table field sequences and table field identifiers, the table field names, the table field sequences and the table field identifiers correspond to each other, the preset data content table stores the data type identifiers and table field content information, the table field content information comprises the table field identifiers and the table field names corresponding to the table field identifiers;
The acquisition module is used for acquiring the table field name information and the table field content information from the preset database field table and the preset data content table based on the data type identifier to be changed; and
and the generation module is used for generating the database table based on the acquired table field name information and table field content information so as to obtain a changed database table.
7. The apparatus of claim 6, wherein the change event further comprises to-be-changed content comprising to-be-changed table field content and/or to-be-changed table field order.
8. The apparatus of claim 7, wherein modifying the pre-set database field table and/or the pre-set data content table according to the change operation and the change event comprises:
in the case where the change operation is a table field addition, the contents to be changed include the contents of the table field to be changed and the order of the table field to be changed,
storing table field information aiming at the data type identifier to be changed, the table field name to be changed, the table field sequence to be changed and the table field identifier to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information;
Adding a field identifier of the table to be changed according to the table field content information corresponding to the type identifier of the data to be changed in the preset data content table;
at least displaying the names of the fields of the to-be-changed table corresponding to the added fields of the to-be-changed table aiming at the added preset data content table; and
receiving the setting of the table field content corresponding to the table field name to be changed by a user, and storing the set table field content in the table field content information corresponding to the added table field identifier to be changed so as to modify the preset data content table; and/or
In the case where the change operation is a table field modification and the contents to be changed include the contents of the table field to be changed, the table field name to be changed includes a substitute table field name and a substituted table field name,
in the preset database field table, for the table field information corresponding to the data type identifier to be changed, replacing the replaced table field name with a replaced table field name so as to modify the preset database field table;
for the preset data content table, at least displaying the name of the substitute table field corresponding to the field identification of the table to be changed; and
Receiving the setting of the table field content corresponding to the substitute table field name by a user, and storing the set table field content in the table field content information corresponding to the table field identifier to be changed so as to modify the preset data content table; and/or
And under the condition that the change operation is list field ordering, the content to be changed comprises the list field sequence to be changed, and in the preset database field list, aiming at the list field information corresponding to the data type identifier to be changed, the list field sequence of the list field name to be changed is modified into the list field sequence to be changed so as to modify the preset database field list.
9. The apparatus of claim 6, wherein, in the case where the change operation is a table field deletion, the modifying the preset database field table and/or the preset data content table according to the change operation and the change event comprises:
deleting table field information corresponding to the data type identifier to be changed and the table field name to be changed in the preset database field table so as to modify the preset database field table, wherein the table field information comprises a database field table identifier, a data type identifier and table field name information; and
And deleting the table field identification to be changed and the table field content corresponding to the table field identification to be changed aiming at the table field content information corresponding to the data type identification to be changed in the preset data content table so as to modify the preset data content table.
10. The apparatus of claim 6, wherein, in the case where the change operation is a table field modification, the modifying the preset database field table and/or the preset data content table according to the change operation and the change event comprises:
and in the preset database field table, replacing the replaced table field name with the replaced table field name aiming at the table field information corresponding to the data type identifier to be changed so as to modify the preset database field table.
11. An apparatus for altering the table structure of a database table, the apparatus comprising a processor, a memory and a program stored on the memory and executable on the processor, the processor implementing the method of any one of claims 1 to 5 when the program is executed by the processor.
12. A machine-readable storage medium having instructions stored thereon, which when executed by a processor cause the processor to be configured to perform the method of any of claims 1 to 5.
CN202310054937.6A 2023-02-03 2023-02-03 Method and apparatus for altering a table structure of a database table Active CN115878631B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310054937.6A CN115878631B (en) 2023-02-03 2023-02-03 Method and apparatus for altering a table structure of a database table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310054937.6A CN115878631B (en) 2023-02-03 2023-02-03 Method and apparatus for altering a table structure of a database table

Publications (2)

Publication Number Publication Date
CN115878631A CN115878631A (en) 2023-03-31
CN115878631B true CN115878631B (en) 2023-05-12

Family

ID=85758626

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310054937.6A Active CN115878631B (en) 2023-02-03 2023-02-03 Method and apparatus for altering a table structure of a database table

Country Status (1)

Country Link
CN (1) CN115878631B (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110597821B (en) * 2019-09-20 2022-05-17 中国银行股份有限公司 Method and device for changing database table structure
CN111444175A (en) * 2020-02-27 2020-07-24 平安科技(深圳)有限公司 Database table changing method and device, computer equipment and storage medium
CN112883418B (en) * 2021-02-03 2024-02-09 中国工商银行股份有限公司 Method and device for protecting table field value of database
CN113420026B (en) * 2021-06-22 2023-10-31 康键信息技术(深圳)有限公司 Database table structure changing method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN115878631A (en) 2023-03-31

Similar Documents

Publication Publication Date Title
US20150205885A1 (en) CREATING NoSQL DATABASE INDEX FOR SEMI-STRUCTURED DATA
CN111124474B (en) API version control method and device
CN109145055B (en) Data synchronization method and system based on Flink
CN112487083B (en) Data verification method and device
CN106951231B (en) Computer software development method and device
CN107016016A (en) A kind of method and device of data processing
CN110727482A (en) Interface updating method and device
CN107609011B (en) Database record maintenance method and device
CN108073595B (en) Method and device for realizing data updating and snapshot in OLAP database
CN114691732A (en) Method and device for positioning abnormal transaction, nonvolatile storage medium and processor
CN113254163B (en) Processing method and device of block chain data
CN115878631B (en) Method and apparatus for altering a table structure of a database table
CN107562533B (en) Data loading processing method and device
CN106407345B (en) Dirty data updating method and device
CN111813880B (en) Homeland space planning project management method, system and storage medium
CN109299125B (en) Database updating method and device
CN112559444A (en) SQL (structured query language) file migration method and device, storage medium and equipment
CN105302604A (en) Application version update method and apparatus
CN108228604B (en) Model construction method based on memory object, information query method and device
CN116594917B (en) UI testing method and device, electronic equipment and machine-readable storage medium
CN110990378A (en) Block chain-based data consistency comparison method, device and medium
CN115455035B (en) Data query model construction method and computer-readable storage medium
CN114416886A (en) Method, device and equipment for determining data relationship and storage medium
CN117390060A (en) Batch data unloading processing method and device, electronic equipment and readable storage medium
CN116755922A (en) Error code information management method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant