Summary of the invention
In view of this, the embodiment of the present invention provides a kind of database maintenance method and device, utilizes the remarks fulfillment database to safeguard, effectively reduces code redundancy, has greatly improved development efficiency, has reduced maintenance cost.
The embodiment of the present invention provides a kind of database maintenance method, comprising:
While building table, be each field increase remarks of table name and table, and described remarks deposited in the remarks attribute of built table; Wherein, described remarks comprise the attribute of title and/or the field of field;
When the page is safeguarded, obtain specific field and corresponding remark information in table;
The name of field in the remarks of each Related fields is referred to as to fixed part and shows, and present the different forms that represents according to the attribute of field in remarks.
The embodiment of the present invention also provides a kind of database maintenance device, comprising:
Remarks add module, for when building table, are recorded as table name and show the remark information that each field increases, and described remarks are deposited in the remarks attribute of built table; Wherein, described remarks comprise the attribute of title and/or the field of field;
The data selection module, for when the page is safeguarded, obtain specific field and corresponding remark information in table;
Page display module, be referred to as fixed part for the name of the remarks field by each Related fields and show, and present the different forms that represents according to the attribute of field in remarks.
The database maintenance method and the device that utilize the embodiment of the present invention to provide, no matter in database, how many tables are arranged, no matter in maintenance process, database is carried out to what kind of additions and deletions and change operation, only utilize a set of maintenance program just can solve, realize that the mobilism of the page and data is processed.This mode effectively reduces code redundancy, has greatly improved development efficiency, has reduced maintenance cost.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described,
Figure 1 shows that the data general-purpose maintaining method process flow diagram that the embodiment of the present invention provides.As shown in Figure 1, the method comprises:
Step 101: while building table, be each field increase remarks of table name and table, and described remarks deposited in the remarks attribute of built table; Wherein, described remarks comprise the attribute of title and/or the field of field.
In an embodiment of the present invention, the remarks of some field may only comprise the title of field, and the remarks of some field may also further comprise the attribute of field.The title of field and the attribute of field can be isolated with other symbols of " comma " or definition.
In an embodiment of the present invention, the attribute of field comprises querying attributes, data type attribute or dictionary relating attribute.
Illustrate, can take following statement to build table:
Wherein, table_name is table name, and can define table_name according to the difference of showing is different values; The row name of BH, BJ, JBNY, BZRJGH, BJLXM table, according to the difference of table, also can define row different value by name.
Comment on table XX_BJSJXX is' class data message ';
By this statement, be that table name adds remarks, these remarks are the title of table.
Comment on column XX_BJSJXX.BH is' class number, QUERY';
The BH field that is the XX_BJSJXX table by this statement is added remarks.Wherein " class number " is the title of field, the attribute that " QUERY " is field, and querying attributes, be illustrated in subsequent processes, and this field can be used as can inquire about field and be presented in the page.Here, the title of the attribute of field and field is by " comma " isolation.
Comment on column XX_BJSJXX.BJ is' class, QUERY';
The BJ field that is the XX_BJSJXX table by this statement is added remarks.The title that wherein " class " is field, the attribute that " QUERY " is field, be illustrated in subsequent processes, and this field can be used as can inquire about field and be presented in the page.Here, the title of the attribute of field and field is by " comma " isolation.
Comment on column XX_BJSJXX.JBNY is' builds class days, DATEYEAR';
The JBNY field that is the XX_BJSJXX table by this statement is added remarks.Wherein " class's of building days " are the title of field, the attribute that " DATEYEAR " is field, and the data type attribute, mean that this field is current follow-up, can present in the mode of date choice box.Here, the title of the attribute of field and field is by " comma " isolation.
The comment on column XX_BJSJXX.BZRJGH is' form master teach job number ';
The BZRJGH field that is the XX_BJSJXX table by this statement is added remarks.Wherein " form master teaches job number " is the title of this field.
Comment on column XX_BJSJXX.BJLXM is' class type codes, associated dictionary DM_HB_ZXXBJLX';
The BJLXM field that is the XX_BJSJXX table by this statement is added remarks.Wherein " class's type codes " is the title of field, and " associated dictionary DM_HB_ZXXBJLX " is the attribute of field, and the dictionary relating attribute, be illustrated in when down-stream is processed and understand associated dictionary table " DM_HB_ZXXBJLX ".Here, the title of the attribute of field and field is by " comma " isolation.
The above example of some remarks just, it will be understood by those skilled in the art that can also be self-defined other remarks mode, as long as down-stream has corresponding processing mode to each remarks.
In an embodiment of the present invention, the remarks to each field can be left in the remarks attribute of table, obtain by the USER_COL_COMMENTS field of inquiry view USER_TAB_COMMENTS.
Step 102: when the page is safeguarded, obtain specific field and corresponding remark information in table.
Illustrate, can take following statement to obtain field information in table:
SELECT?TABLE_NAME,COLUMN_NAME,COMMENTS?FROM?USER_COL_COMMENTS?WHERE?TABLE_NAME='XX_BJSJXX';
Still, with the data instance of step 101, the field now obtained and remark information can be as shown in the table:
Step 103: when adding the display page of this table, the name of field in the remarks of each Related fields is referred to as to fixed part and shows, and present the different forms that represents according to the attribute of field in remarks.
Still, with the data instance of step 101, Figure 2 shows that the example that this form finally presents.As shown in Figure 2, the first title of classifying field in the remarks of each Related fields as; Second classifies as according to the attribute of field in remarks and presents the different forms that represents.As be the date choice box after the days of graduating, after class's type codes, be drop-down list, wherein the value in drop-down list is the content in dictionary table.
In one example, attribute can also be shown as independent " information inquiry " part for the field of " QUERY ", as shown in Figure 3.When being retrieved, be input to the value in querying condition according to the user, dynamically splice query statement, inquire the information in table, then select to need the field derived, the information in table is presented to the user.
In the time need to being derived the information of database, the field name in remarks is presented to the user and select, the field name of selecting according to the user, the field attribute of analysis remarks, according to field attribute, derive the information in table.
In an embodiment of the present invention, when the table of needs maintenance is too much, before step 102, may further include:
Obtain the tables of data of partly or entirely obtaining;
Such as, can utilize following statement to obtain:
select*from?user_tab_comments;
This statement can be realized all tables with remark information are chosen, and for follow-up management person, is operated.
The embodiment of the present invention also further provides a kind of database maintenance device.This device comprises:
Remarks add module, for when building table, are recorded as table name and show the remark information that each field increases; Wherein, described remarks comprise the attribute of title and/or the field of field;
The data selection module, for when the page is safeguarded, obtain specific field and corresponding remark information in table;
Page display module, be referred to as fixed part for the name of the remarks field by each Related fields and show, and present the different forms that represents according to the attribute of field in remarks.
The database maintenance method and the device that utilize the embodiment of the present invention to provide, no matter in database, how many tables are arranged, no matter in maintenance process, database is carried out to what kind of additions and deletions and change operation, only utilize a set of maintenance program just can solve, realize that the mobilism of the page and data is processed.This mode effectively reduces code redundancy, has greatly improved development efficiency, has reduced maintenance cost.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement etc., within all should being included in protection scope of the present invention.