CN103605782A - Data insertion method and device for data table - Google Patents

Data insertion method and device for data table Download PDF

Info

Publication number
CN103605782A
CN103605782A CN201310629536.5A CN201310629536A CN103605782A CN 103605782 A CN103605782 A CN 103605782A CN 201310629536 A CN201310629536 A CN 201310629536A CN 103605782 A CN103605782 A CN 103605782A
Authority
CN
China
Prior art keywords
data
foreign key
tables
key information
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201310629536.5A
Other languages
Chinese (zh)
Inventor
樊在阔
杨基彬
洪超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum 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 Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201310629536.5A priority Critical patent/CN103605782A/en
Publication of CN103605782A publication Critical patent/CN103605782A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets

Abstract

The invention discloses a data insertion method and device for a data table. The data insertion method for the data table comprises the steps of receiving data insertion instructions, wherein the data insertion instructions are used for inserting data in the data table, and the data table is a data table with foreign key constraint; obtaining the foreign key information of the data table; obtaining forbidden instructions corresponding to the foreign key information; forbidding the foreign key constraint of the data table through the forbidden instructions corresponding to the foreign key information; inserting data in the data table after forbidden is executed on the data table based on data insertion instructions. Through the data insertion method and device for the data table, the effect of reducing data inserting time is achieved.

Description

The data insertion method of tables of data and device
Technical field
The present invention relates to database field, in particular to a kind of data insertion method and device of tables of data.
Background technology
In the design of database table, in order to realize the integrality of data between table, can add Primary key and foreign key constraint for row, Primary key is used for limiting this row content can not be repeated, and can not be sky, foreign key constraint must exist in the value of associated primary key column for limiting this train value.By Primary key and foreign key constraint, realize between two tables of data and being associated.In the tables of data with foreign key constraint during data inserting, because tables of data is with foreign key constraint, make can go to access the table that external key is quoted when executing data update, thereby cause data to insert overlong time, consume the resource of central processing unit (CPU) and internal memory.
For in prior art in the tables of data with foreign key constraint data insert the problem of overlong time, effective solution is not yet proposed at present.
Summary of the invention
Fundamental purpose of the present invention is to provide a kind of data insertion method and device of tables of data, inserts the problem of overlong time to solve in prior art in the tables of data with foreign key constraint data.
To achieve these goals, according to an aspect of the present invention, provide a kind of data insertion method of tables of data.According to the data insertion method of tables of data of the present invention, comprise: receive data and insert instruction, data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint; Obtain the foreign key information of tables of data; Obtain illegal instruction corresponding to foreign key information; By the foreign key constraint of illegal instruction disable data table corresponding to foreign key information; And insert data inserting in the tables of data of instruction after carrying out forbidding based on data.
Further, the foreign key information of obtaining tables of data comprises: obtain the system table of Database Systems, system table is the table that includes foreign key information in Database Systems; And the foreign key information of searching tables of data from system table.
Further, the foreign key information of obtaining tables of data comprises: the foreign key information table that obtains tables of data, foreign key information table comprises a plurality of foreign key information, and the foreign key constraint of the illegal instruction disable data table by foreign key information comprises: the foreign key constraint of simultaneously forbidding all foreign key information in foreign key information table by illegal instruction corresponding to foreign key information; Or by illegal instruction corresponding to foreign key information, forbid successively the foreign key constraint of foreign key information in foreign key information table.
Further, in insert the tables of data of instruction after carrying out forbidding based on data, after data inserting, data insertion method also comprises: obtain foreign key information corresponding enable instruction; And by foreign key information corresponding enable the foreign key constraint that tables of data is enabled in instruction.
Further, by the foreign key constraint that instruction enables tables of data of enabling corresponding to foreign key information, comprise: by foreign key information corresponding enable the foreign key constraint that all foreign key information in foreign key information table are enabled in instruction simultaneously; Or by foreign key information corresponding enable the foreign key constraint that foreign key information in foreign key information table is enabled in instruction successively.
To achieve these goals, according to a further aspect in the invention, provide a kind of data insertion apparatus of tables of data.According to the data insertion apparatus of tables of data of the present invention, comprise: receiving element, for receiving data, insert instruction, data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint; The first acquiring unit, for obtaining the foreign key information of tables of data; Second acquisition unit, for obtaining illegal instruction corresponding to foreign key information; Forbidden cell, for passing through the foreign key constraint of illegal instruction disable data table corresponding to foreign key information; And plug-in unit, for insert the tables of data data inserting of instruction after carrying out forbidding based on data.
Further, the first acquiring unit comprises: the first acquisition module, and for obtaining the system table of Database Systems, system table is the table that includes foreign key information in Database Systems; And search module, for search the foreign key information of tables of data from system table.
Further, the first acquiring unit comprises: the second acquisition module, for obtaining the foreign key information table of tables of data, foreign key information table comprises a plurality of foreign key information, forbidden cell comprises: disabled module, for forbid the foreign key constraint of all foreign key information of foreign key information table by illegal instruction corresponding to foreign key information simultaneously, or for forbid successively the foreign key constraint of foreign key information table foreign key information by illegal instruction corresponding to foreign key information.
Further, data insertion apparatus also comprises: the 3rd acquiring unit, for insert the tables of data data inserting of instruction after carrying out forbidding based on data after, obtain foreign key information corresponding enable instruction; And enable unit, for by foreign key information corresponding enable the foreign key constraint that tables of data is enabled in instruction.
Further, enabling unit comprises: enable module, for by foreign key information corresponding enable the foreign key constraint that all foreign key information of foreign key information table are enabled in instruction simultaneously, or for by foreign key information corresponding enable the foreign key constraint that foreign key information table foreign key information is enabled in instruction successively.
By the present invention, adopt the data insertion method of tables of data, after the external constraint with the tables of data of foreign key constraint at forbidding, again to data inserting in tables of data, thereby the table that outside need to not accessing when data inserting, key index is used, and directly to data inserting in tables of data, simplified the process that data are inserted, reduce the time that data are inserted, solved in prior art data in the tables of data with foreign key constraint and inserted the problem of overlong time, and then reached and reduce the effect that data are inserted the time.
Accompanying drawing explanation
The accompanying drawing that forms the application's a part is used to provide a further understanding of the present invention, and schematic description and description of the present invention is used for explaining the present invention, does not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is according to the structural representation of the data insertion apparatus of the tables of data of first embodiment of the invention;
Fig. 2 is according to the structural representation of the data insertion apparatus of the tables of data of second embodiment of the invention;
Fig. 3 is according to the structural representation of the data insertion apparatus of the tables of data of third embodiment of the invention;
Fig. 4 is according to the process flow diagram of the data insertion method of the tables of data of first embodiment of the invention;
Fig. 5 is according to the process flow diagram of the data insertion method of the tables of data of second embodiment of the invention;
Fig. 6 is according to the process flow diagram of the data insertion method of the tables of data of third embodiment of the invention; And
Fig. 7 is according to the process flow diagram of the data insertion method of the tables of data of fourth embodiment of the invention.
Embodiment
It should be noted that, in the situation that not conflicting, embodiment and the feature in embodiment in the application can combine mutually.Describe below with reference to the accompanying drawings and in conjunction with the embodiments the present invention in detail.
In order to make those skilled in the art person understand better the present invention program, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, should belong to the scope of protection of the invention.
It should be noted that, the term " first " in instructions of the present invention and claims and above-mentioned accompanying drawing, " second " etc. are for distinguishing similar object, and needn't be for describing specific order or precedence.Should be appreciated that the data of such use are suitably exchanging in situation, so that embodiments of the invention described herein.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, for example, those steps or unit that the process that has comprised series of steps or unit, method, system, product or equipment are not necessarily limited to clearly list, but can comprise clearly do not list or for these processes, method, product or equipment intrinsic other step or unit.
The embodiment of the present invention provides a kind of data insertion apparatus of tables of data, and this device can be realized its function by computer equipment.
Fig. 1 is according to the structural representation of the data insertion apparatus of the tables of data of first embodiment of the invention.As shown in Figure 1, the data insertion apparatus of this tables of data comprises: receiving element 10, the first acquiring unit 20, second acquisition unit 30, forbidden cell 40 and plug-in unit 50.
Receiving element 10 inserts instruction for receiving data, and data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint.
It is that wherein tables of data can be the tables of data with foreign key constraint, can be any one table with foreign key constraint in database to the instruction of data inserting in tables of data that data are inserted instruction.Receive data and insert instruction, can insert instruction to data inserting in tables of data by data.
The first acquiring unit 20 is for obtaining the foreign key information of tables of data.
After accepting data insertion instruction, can be from database, to obtain the tables of data that needs data inserting, then using this tables of data as basis, obtain the foreign key information corresponding with this tables of data.Foreign key information is to there being foreign key constraint function, wherein foreign key constraint is for limiting in the value that corresponding train value must be present in associated primary key column, when tables of data comprises a plurality of foreign key information, obtain all foreign key information of tables of data, that is to say and obtain foreign key information table corresponding to tables of data.Wherein, foreign key information can be the corresponding foreign key information table of tables of data of searching in the system table by providing in Database Systems with foreign key constraint, and system table is that Database Systems are disclosed for helping the object of Query Database object basic data.By inquiry system table, obtain foreign key information corresponding to tables of data.
Second acquisition unit 30 is for obtaining illegal instruction corresponding to foreign key information.
Illegal instruction is used for forbidding foreign key constraint, and this illegal instruction can be for forbidding the instruction of a foreign key constraint, can be also the instruction of simultaneously forbidding all foreign key constraints.The foreign key constraint that illegal instruction corresponding to foreign key information is used for forbidding tables of data corresponding to foreign key information, obtains this illegal instruction so that the foreign key constraint of disable data table.
Forbidden cell 40 is for passing through the foreign key constraint of illegal instruction disable data table corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, can forbid the foreign key constraint in corresponding tables of data by illegal instruction corresponding to foreign key information.When tables of data only has an external key, can obtain the foreign key information of this external key, the foreign key constraint of this external key is forbidden in the instruction of a foreign key constraint of employing forbidding; When tables of data has a plurality of external key, by obtaining the foreign key information table of tables of data, can adopt the instruction of a foreign key constraint of forbidding to forbid one by one the foreign key constraint that foreign key information table is corresponding, or adopt all foreign key constraints corresponding to instruction forbidding foreign key information table of simultaneously forbidding all foreign key constraints.
Plug-in unit 50 is for inserting the tables of data data inserting of instruction after carrying out forbidding based on data.
After the foreign key constraint by illegal instruction disable data table corresponding to foreign key information, can be to insert instruction to data inserting in the tables of data with foreign key constraint based on receiving data.Due to now, to data inserting in the tables of data with foreign key constraint, the foreign key constraint of tables of data is disabled, therefore, when data inserting in tables of data, do not need to access the table that external key is quoted, thereby optimized data insertion process, directly to data inserting in tables of data.
According to the embodiment of the present invention, after the external constraint with the tables of data of foreign key constraint at forbidding, again to data inserting in tables of data, thereby the table that outside need to not accessing when data inserting, key index is used, and directly to data inserting in tables of data, simplified the process that data are inserted, reduce the time that data are inserted, solved in prior art data in the tables of data with foreign key constraint and inserted the problem of overlong time, and then reached and reduce the effect that data are inserted the time.
Fig. 2 is according to the structural representation of the data insertion apparatus of the tables of data of second embodiment of the invention.The data insertion apparatus of the tables of data of this embodiment can be used as a kind of preferred implementation of data insertion apparatus of the tables of data of above-described embodiment.As shown in Figure 2, the data insertion apparatus of this tables of data comprises: receiving element 10, the first acquiring unit 20, second acquisition unit 30, forbidden cell 40 and plug-in unit 50, wherein, the first acquiring unit 20 comprises: the first acquisition module 201 and search module 202.Second acquisition unit 30, forbidden cell 40 and plug-in unit 50 and the second acquisition unit 30 shown in Fig. 1, forbidden cell 40 are identical with plug-in unit 50 functions, do not repeat here.
The first acquisition module 201 is for obtaining the system table of Database Systems, and system table is the table that includes foreign key information in Database Systems.
System table is that Database Systems are disclosed for helping the object of Query Database object basic data, can find all foreign key information in database from basic data.Obtain the system table of Database Systems so that from the system table by inquiring about corresponding Database Systems to obtain foreign key information table.
Search module 202 for search the foreign key information of tables of data from system table.
From system table, find the foreign key information of the tables of data that needs data inserting, thereby obtain this foreign key information, and this foreign key information is returned, so that the foreign key constraint of disable data table.
Fig. 3 is according to the structural representation of the data insertion apparatus of the tables of data of third embodiment of the invention.The data insertion apparatus of the tables of data of this embodiment can be used as a kind of preferred implementation of data insertion apparatus of the tables of data of above-described embodiment.As shown in Figure 3, the data insertion apparatus of this tables of data comprises: receiving element 10, the first acquiring unit 20, second acquisition unit 30, forbidden cell 40 and plug-in unit 50, wherein, the first acquiring unit 20 comprises the second acquisition module 203, and forbidden cell 40 comprises disabled module 401.Receiving element 10, second acquisition unit 30 and plug-in unit 50 and the receiving element 10 shown in Fig. 1, second acquisition unit 30 are identical with plug-in unit 50 functions, do not repeat here
The second acquisition module 203 is for obtaining the foreign key information table of tables of data, and foreign key information table comprises a plurality of foreign key information.
Database table can include a plurality of external keys, obtaining the foreign key information table of tables of data, can be the information list that obtains all external keys of tables of data, after obtaining all foreign key information, by forbidding all foreign key constraints, thereby reach EMS memory occupation when reducing data and inserting and the consumption of CPU.
Disabled module 401 is for forbid the foreign key constraint of all foreign key information of foreign key information table simultaneously by illegal instruction corresponding to foreign key information.
After having obtained illegal instruction corresponding to foreign key information, by this illegal instruction, forbid foreign key constraints all in foreign key information table simultaneously, thereby reach, the forbidding of the foreign key constraint of tables of data is settled at one go, avoid one by one foreign key constraint being forbidden and being caused long problem consuming time.
Disabled module 401 can also be for forbidding the foreign key constraint of foreign key information table foreign key information successively by illegal instruction corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, by illegal instruction, foreign key constraint is forbidden one by one, thereby avoided omitting some external keys, and cause the forbidding of foreign key constraint incomplete.
Preferably, data insertion apparatus also comprises: the 3rd acquiring unit and enable unit.
The 3rd acquiring unit is for after inserting the tables of data data inserting of instruction after carrying out forbidding based on data, obtain foreign key information corresponding enable instruction.
After data inserting in tables of data, obtain foreign key information corresponding enable instruction, this enables instruction for enabling foreign key constraint corresponding to foreign key information, obtains this and enables instruction so that after data inserting, reactivate foreign key constraint.
Enable unit for by foreign key information corresponding enable the foreign key constraint that tables of data is enabled in instruction.
Obtain foreign key information corresponding enable instruction after, by this, enable the foreign key constraint that tables of data is enabled in instruction.The foreign key constraint of enabling tables of data can be all foreign key constraints of simultaneously enabling tables of data, can be also each foreign key constraint of once enabling tables of data.
Preferably, enabling unit comprises and enables module.
Enable module for by foreign key information corresponding enable the foreign key constraint that all foreign key information of foreign key information table are enabled in instruction simultaneously.
By enabling instruction, enable all foreign key constraints of tables of data, the foreign key constraint process of enabling of tables of data is settled at one go, thereby further reduce the time that foreign key constraint is enabled process.
Enable module can also for by foreign key information corresponding enable the foreign key constraint that foreign key information table foreign key information is enabled in instruction successively.
Enable successively the foreign key constraint of foreign key information in foreign key information table corresponding with the foreign key constraint of a disable data table in above-described embodiment.By enabling instruction, once enable each foreign key constraint of tables of data, thereby can make the foreign key constraint of each forbidding to reactivate, avoid omitting some foreign key constraints.
The embodiment of the present invention also provides a kind of data insertion method of tables of data.The method operates on computer equipment.It should be noted that, the data insertion apparatus of the tables of data that the data insertion method of the tables of data of the embodiment of the present invention can provide by the embodiment of the present invention is carried out, the data insertion method of the tables of data that the data insertion apparatus of the tables of data of the embodiment of the present invention also can provide for the execution embodiment of the present invention.
Fig. 4 is according to the process flow diagram of the data insertion method of the tables of data of first embodiment of the invention.As shown in Figure 4, the data insertion method of this tables of data comprises that step is as follows:
Step S101, receives data and inserts instruction, and data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint.
It is that wherein tables of data can be the tables of data with foreign key constraint, can be any one table with foreign key constraint in database to the instruction of data inserting in tables of data that data are inserted instruction.Receive data and insert instruction, can insert instruction to data inserting in tables of data by data.
Step S102, obtains the foreign key information of tables of data.
After accepting data insertion instruction, can be from database, to obtain the tables of data that needs data inserting, then using this tables of data as basis, obtain the foreign key information corresponding with this tables of data.Foreign key information is to there being foreign key constraint function, wherein foreign key constraint is for limiting in the value that corresponding train value must be present in associated primary key column, when tables of data comprises a plurality of foreign key information, obtain all foreign key information of tables of data, that is to say and obtain foreign key information table corresponding to tables of data.Wherein, foreign key information can be the corresponding foreign key information table of tables of data of searching in the system table by providing in Database Systems with foreign key constraint, and system table is that Database Systems are disclosed for helping the object of Query Database object basic data.By inquiry system table, obtain foreign key information corresponding to tables of data.
Step S103, obtains illegal instruction corresponding to foreign key information.
Illegal instruction is used for forbidding foreign key constraint, and this illegal instruction can be for forbidding the instruction of a foreign key constraint, can be also the instruction of simultaneously forbidding all foreign key constraints.The foreign key constraint that illegal instruction corresponding to foreign key information is used for forbidding tables of data corresponding to foreign key information, obtains this illegal instruction so that the foreign key constraint of disable data table.
Step S104, by the foreign key constraint of illegal instruction disable data table corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, can forbid the foreign key constraint in corresponding tables of data by illegal instruction corresponding to foreign key information.When tables of data only has an external key, can obtain the foreign key information of this external key, the foreign key constraint of this external key is forbidden in the instruction of a foreign key constraint of employing forbidding; When tables of data has a plurality of external key, by obtaining the foreign key information table of tables of data, can adopt the instruction of a foreign key constraint of forbidding to forbid one by one the foreign key constraint that foreign key information table is corresponding, or adopt all foreign key constraints corresponding to instruction forbidding foreign key information table of simultaneously forbidding all foreign key constraints.
Step S105, inserts data inserting in the tables of data of instruction after carrying out forbidding based on data.
After the foreign key constraint by illegal instruction disable data table corresponding to foreign key information, can be to insert instruction to data inserting in the tables of data with foreign key constraint based on receiving data.Due to now, to data inserting in the tables of data with foreign key constraint, the foreign key constraint of tables of data is disabled, therefore, when data inserting in tables of data, do not need to access the table that external key is quoted, thereby optimized data insertion process, directly to data inserting in tables of data.
According to the embodiment of the present invention, after the external constraint with the tables of data of foreign key constraint at forbidding, again to data inserting in tables of data, thereby the table that outside need to not accessing when data inserting, key index is used, and directly to data inserting in tables of data, simplified the process that data are inserted, reduce the time that data are inserted, solved in prior art data in the tables of data with foreign key constraint and inserted the problem of overlong time, and then reached and reduce the effect that data are inserted the time.
Fig. 5 is according to the process flow diagram of the data insertion method of the tables of data of second embodiment of the invention.The data insertion method of the tables of data of this embodiment can be a kind of preferred implementation of data insertion method of the tables of data of above-described embodiment.As shown in Figure 5, the data insertion method of this tables of data comprises that step is as follows:
Step S201, receives data and inserts instruction, and data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint.
It is that wherein tables of data can be the tables of data with foreign key constraint, can be any one table with foreign key constraint in database to the instruction of data inserting in tables of data that data are inserted instruction.Receive data and insert instruction, can insert instruction to data inserting in tables of data by data.
Step S202, obtains the system table of Database Systems, and system table is the table that includes foreign key information in Database Systems.
System table is that Database Systems are disclosed for helping the object of Query Database object basic data, can find all foreign key information in database from basic data.Obtain the system table of Database Systems so that from the system table by inquiring about corresponding Database Systems to obtain foreign key information table.
Step S203, searches the foreign key information of tables of data from system table.
From system table, find the foreign key information of the tables of data that needs data inserting, thereby obtain this foreign key information, and this foreign key information is returned, so that the foreign key constraint of disable data table.
Step S204, obtains illegal instruction corresponding to foreign key information.
Illegal instruction is used for forbidding foreign key constraint, and this illegal instruction can be for forbidding the instruction of a foreign key constraint, can be also the instruction of simultaneously forbidding all foreign key constraints.The foreign key constraint that illegal instruction corresponding to foreign key information is used for forbidding tables of data corresponding to foreign key information, obtains this illegal instruction so that the foreign key constraint of disable data table.
Step S205, by the foreign key constraint of illegal instruction disable data table corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, can forbid the foreign key constraint in corresponding tables of data by illegal instruction corresponding to foreign key information.When tables of data only has an external key, can obtain the foreign key information of this external key, the foreign key constraint of this external key is forbidden in the instruction of a foreign key constraint of employing forbidding; When tables of data has a plurality of external key, by obtaining the foreign key information table of tables of data, can adopt the instruction of a foreign key constraint of forbidding to forbid one by one the foreign key constraint that foreign key information table is corresponding, or adopt all foreign key constraints corresponding to instruction forbidding foreign key information table of simultaneously forbidding all foreign key constraints.
Step S206, inserts data inserting in the tables of data of instruction after carrying out forbidding based on data.
After the foreign key constraint by illegal instruction disable data table corresponding to foreign key information, can be to insert instruction to data inserting in the tables of data with foreign key constraint based on receiving data.Due to now, to data inserting in the tables of data with foreign key constraint, the foreign key constraint of tables of data is disabled, therefore, when data inserting in tables of data, do not need to access the table that external key is quoted, thereby optimized data insertion process, directly to data inserting in tables of data.
Fig. 6 is according to the process flow diagram of the data insertion method of the tables of data of third embodiment of the invention.The data insertion method of the tables of data of this embodiment can be a kind of preferred implementation of data insertion method of the tables of data of above-described embodiment.As shown in Figure 6, the data insertion method of this tables of data comprises that step is as follows:
Step S301, receives data and inserts instruction, and data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint.
It is that wherein tables of data can be the tables of data with foreign key constraint, can be any one table with foreign key constraint in database to the instruction of data inserting in tables of data that data are inserted instruction.Receive data and insert instruction, can insert instruction to data inserting in tables of data by data.
Step S302, obtains the foreign key information table of tables of data, and foreign key information table comprises a plurality of foreign key information.
Database table can include a plurality of external keys, obtaining the foreign key information table of tables of data, can be the information list that obtains all external keys of tables of data, after obtaining all foreign key information, by forbidding all foreign key constraints, thereby reach EMS memory occupation when reducing data and inserting and the consumption of CPU.
Step S303, obtains illegal instruction corresponding to foreign key information.
Illegal instruction is used for forbidding foreign key constraint, and this illegal instruction can be for forbidding the instruction of a foreign key constraint, can be also the instruction of simultaneously forbidding all foreign key constraints.The foreign key constraint that illegal instruction corresponding to foreign key information is used for forbidding tables of data corresponding to foreign key information, obtains this illegal instruction so that the foreign key constraint of disable data table.
Step S304, forbids the foreign key constraint of foreign key information in foreign key information table successively by illegal instruction corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, by illegal instruction, foreign key constraint is forbidden one by one, thereby avoided omitting some external keys, and cause the forbidding of foreign key constraint incomplete.
Alternatively, step S304 is forbidden the foreign key constraint of all foreign key information in foreign key information table simultaneously by illegal instruction corresponding to foreign key information.
After having obtained illegal instruction corresponding to foreign key information, by this illegal instruction, forbid foreign key constraints all in foreign key information table simultaneously, thereby reach, the forbidding of the foreign key constraint of tables of data is settled at one go, avoid one by one foreign key constraint being forbidden and being caused long problem consuming time.
Step S305, inserts data inserting in the tables of data of instruction after carrying out forbidding based on data.
After the foreign key constraint by illegal instruction disable data table corresponding to foreign key information, can be to insert instruction to data inserting in the tables of data with foreign key constraint based on receiving data.Due to now, to data inserting in the tables of data with foreign key constraint, the foreign key constraint of tables of data is disabled, therefore, when data inserting in tables of data, do not need to access the table that external key is quoted, thereby optimized data insertion process, directly to data inserting in tables of data.
Fig. 7 is according to the process flow diagram of the data insertion method of the tables of data of fourth embodiment of the invention.The data insertion method of the tables of data of this embodiment can be a kind of preferred implementation of data insertion method of the tables of data of above-described embodiment.As shown in Figure 7, the data insertion method of this tables of data comprises that step is as follows:
Step S401, receives data and inserts instruction, and data are inserted instruction and are used for to tables of data data inserting, and tables of data is the tables of data with foreign key constraint.
It is that wherein tables of data can be the tables of data with foreign key constraint, can be any one table with foreign key constraint in database to the instruction of data inserting in tables of data that data are inserted instruction.Receive data and insert instruction, can insert instruction to data inserting in tables of data by data.
Step S402, obtains the foreign key information of tables of data.
After accepting data insertion instruction, can be from database, to obtain the tables of data that needs data inserting, then using this tables of data as basis, obtain the foreign key information corresponding with this tables of data.Foreign key information is to there being foreign key constraint function, wherein foreign key constraint is for limiting in the value that corresponding train value must be present in associated primary key column, when tables of data comprises a plurality of foreign key information, obtain all foreign key information of tables of data, that is to say and obtain foreign key information table corresponding to tables of data.Wherein, foreign key information can be the corresponding foreign key information table of tables of data of searching in the system table by providing in Database Systems with foreign key constraint, and system table is that Database Systems are disclosed for helping the object of Query Database object basic data.By inquiry system table, obtain foreign key information corresponding to tables of data.
Step S403, obtains illegal instruction corresponding to foreign key information.
Illegal instruction is used for forbidding foreign key constraint, and this illegal instruction can be for forbidding the instruction of a foreign key constraint, can be also the instruction of simultaneously forbidding all foreign key constraints.The foreign key constraint that illegal instruction corresponding to foreign key information is used for forbidding tables of data corresponding to foreign key information, obtains this illegal instruction so that the foreign key constraint of disable data table.
Step S404, by the foreign key constraint of illegal instruction disable data table corresponding to foreign key information.
After obtaining illegal instruction corresponding to foreign key information, can forbid the foreign key constraint in corresponding tables of data by illegal instruction corresponding to foreign key information.When tables of data only has an external key, can obtain the foreign key information of this external key, the foreign key constraint of this external key is forbidden in the instruction of a foreign key constraint of employing forbidding; When tables of data has a plurality of external key, by obtaining the foreign key information table of tables of data, can adopt the instruction of a foreign key constraint of forbidding to forbid one by one the foreign key constraint that foreign key information table is corresponding, or adopt all foreign key constraints corresponding to instruction forbidding foreign key information table of simultaneously forbidding all foreign key constraints.
Step S405, inserts data inserting in the tables of data of instruction after carrying out forbidding based on data.
After the foreign key constraint by illegal instruction disable data table corresponding to foreign key information, can be to insert instruction to data inserting in the tables of data with foreign key constraint based on receiving data.Due to now, to data inserting in the tables of data with foreign key constraint, the foreign key constraint of tables of data is disabled, therefore, when data inserting in tables of data, do not need to access the table that external key is quoted, thereby optimized data insertion process, directly to data inserting in tables of data.
Step S406, obtain foreign key information corresponding enable instruction.
After data inserting in tables of data, obtain foreign key information corresponding enable instruction, this enables instruction for enabling foreign key constraint corresponding to foreign key information, obtains this and enables instruction so that after data inserting, reactivate foreign key constraint.
Step S407, by foreign key information corresponding enable the foreign key constraint that tables of data is enabled in instruction.
Obtain foreign key information corresponding enable instruction after, by this, enable the foreign key constraint that tables of data is enabled in instruction.The foreign key constraint of enabling tables of data can be all foreign key constraints of simultaneously enabling tables of data, can be also each foreign key constraint of once enabling tables of data.
By the embodiment of the present invention, after tables of data data inserting, then enable the foreign key constraint of tables of data, thereby make tables of data, can be both to use foreign key constraint function, have and do not affect the performance that data are inserted.
Preferably, step S407 can be by foreign key information corresponding enable the foreign key constraint that foreign key information in foreign key information table is enabled in instruction successively.
Enable successively the foreign key constraint of foreign key information in foreign key information table corresponding with the foreign key constraint of a disable data table in above-described embodiment.By enabling instruction, once enable each foreign key constraint of tables of data, thereby can make the foreign key constraint of each forbidding to reactivate, avoid omitting some foreign key constraints.
Alternatively, step S407 can also be by foreign key information corresponding enable the foreign key constraint that all foreign key information in foreign key information table are enabled in instruction simultaneously.
By enabling instruction, enable all foreign key constraints of tables of data, the foreign key constraint process of enabling of tables of data is settled at one go, thereby further reduce the time that foreign key constraint is enabled process.
It should be noted that, in the step shown in the process flow diagram of accompanying drawing, can in the computer system such as one group of computer executable instructions, carry out, and, although there is shown logical order in flow process, but in some cases, can carry out shown or described step with the order being different from herein.
Obviously, those skilled in the art should be understood that, above-mentioned each module of the present invention or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on the network that a plurality of calculation elements form, alternatively, they can be realized with the executable program code of calculation element, thereby, they can be stored in memory storage and be carried out by calculation element, or they are made into respectively to each integrated circuit modules, or a plurality of modules in them or step are made into single integrated circuit module to be realized.Like this, the present invention is not restricted to any specific hardware and software combination.
The foregoing is only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.

Claims (10)

1. a data insertion method for tables of data, is characterized in that, comprising:
Receive data and insert instruction, described data are inserted instruction and are used for to tables of data data inserting, and described tables of data is the tables of data with foreign key constraint;
Obtain the foreign key information of described tables of data;
Obtain illegal instruction corresponding to described foreign key information;
By illegal instruction corresponding to described foreign key information, forbid the foreign key constraint of described tables of data; And
Based on described data, insert data inserting in the described tables of data of instruction after carrying out forbidding.
2. the data insertion method of tables of data according to claim 1, is characterized in that, the foreign key information of obtaining described tables of data comprises:
Obtain the system table of Database Systems, described system table is the table that includes foreign key information described in described Database Systems; And
From described system table, search the foreign key information of described tables of data.
3. the data insertion method of tables of data according to claim 1, is characterized in that,
The foreign key information of obtaining described tables of data comprises: obtain the foreign key information table of described tables of data, described foreign key information table comprises a plurality of foreign key information,
The foreign key constraint of forbidding described tables of data by the illegal instruction of described foreign key information comprises: the foreign key constraint of simultaneously forbidding all foreign key information in described foreign key information table by illegal instruction corresponding to described foreign key information; Or by illegal instruction corresponding to described foreign key information, forbid successively the foreign key constraint of foreign key information in described foreign key information table.
4. the data insertion method of tables of data according to claim 3, is characterized in that, in insert the described tables of data of instruction after execution forbidding based on described data, after data inserting, described data insertion method also comprises:
Obtain described foreign key information corresponding enable instruction; And
By described foreign key information corresponding enable the foreign key constraint that described tables of data is enabled in instruction.
5. the data insertion method of tables of data according to claim 4, is characterized in that, the enable foreign key constraint that instruction enable described tables of data corresponding by described foreign key information comprises:
By described foreign key information corresponding enable the foreign key constraint that all foreign key information in described foreign key information table are enabled in instruction simultaneously; Or
By described foreign key information corresponding enable the foreign key constraint that foreign key information in described foreign key information table is enabled in instruction successively.
6. a data insertion apparatus for tables of data, is characterized in that, comprising:
Receiving element, inserts instruction for receiving data, and described data are inserted instruction and are used for to tables of data data inserting, and described tables of data is the tables of data with foreign key constraint;
The first acquiring unit, for obtaining the foreign key information of described tables of data;
Second acquisition unit, for obtaining illegal instruction corresponding to described foreign key information;
Forbidden cell, for forbidding the foreign key constraint of described tables of data by illegal instruction corresponding to described foreign key information; And
Plug-in unit, for inserting the described tables of data data inserting of instruction after carrying out forbidding based on described data.
7. the data insertion apparatus of tables of data according to claim 6, is characterized in that, described the first acquiring unit comprises:
The first acquisition module, for obtaining the system table of Database Systems, described system table is the table that includes foreign key information described in described Database Systems; And
Search module, for search the foreign key information of described tables of data from described system table.
8. the data insertion apparatus of tables of data according to claim 7, is characterized in that,
Described the first acquiring unit comprises: the second acquisition module, and for obtaining the foreign key information table of described tables of data, described foreign key information table comprises a plurality of foreign key information,
Described forbidden cell comprises: disabled module, for forbid the foreign key constraint of all foreign key information of described foreign key information table by illegal instruction corresponding to described foreign key information simultaneously, or for forbid successively the foreign key constraint of described foreign key information table foreign key information by illegal instruction corresponding to described foreign key information.
9. the data insertion apparatus of tables of data according to claim 8, is characterized in that, described data insertion apparatus also comprises:
The 3rd acquiring unit, for insert the described tables of data data inserting of instruction after carrying out forbidding based on described data after, obtain described foreign key information corresponding enable instruction; And
Enable unit, for by described foreign key information corresponding enable the foreign key constraint that described tables of data is enabled in instruction.
10. the data insertion apparatus of tables of data according to claim 9, is characterized in that, described in enable unit and comprise:
Enable module, for by described foreign key information corresponding enable the foreign key constraint that all foreign key information of described foreign key information table are enabled in instruction simultaneously, or for by described foreign key information corresponding enable the foreign key constraint that described foreign key information table foreign key information is enabled in instruction successively.
CN201310629536.5A 2013-11-29 2013-11-29 Data insertion method and device for data table Pending CN103605782A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310629536.5A CN103605782A (en) 2013-11-29 2013-11-29 Data insertion method and device for data table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310629536.5A CN103605782A (en) 2013-11-29 2013-11-29 Data insertion method and device for data table

Publications (1)

Publication Number Publication Date
CN103605782A true CN103605782A (en) 2014-02-26

Family

ID=50124004

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310629536.5A Pending CN103605782A (en) 2013-11-29 2013-11-29 Data insertion method and device for data table

Country Status (1)

Country Link
CN (1) CN103605782A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114722109A (en) * 2022-04-13 2022-07-08 中国电信股份有限公司 Data import method, system, device and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080288555A1 (en) * 2005-11-10 2008-11-20 International Business Machines Corporation Enforcing constraints from a parent table to a child table

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080288555A1 (en) * 2005-11-10 2008-11-20 International Business Machines Corporation Enforcing constraints from a parent table to a child table

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
CHELEN_JAK: "禁用、启用外键约束和触发器", 《HTTP://BLOG.CSDN.NET/CHELEN_JAK/ARTICLE/DETAILS/8314736》, 18 December 2012 (2012-12-18) *
李超 等: "两级数据库的设计和实现技术研究", 《计算机应用研究》, no. 7, 31 December 2006 (2006-12-31), pages 153 - 155 *
马惟哲 等: "Web 数据库系统物理模型的优化策略", 《计算机应用与软件》, vol. 22, no. 1, 31 January 2005 (2005-01-31) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114722109A (en) * 2022-04-13 2022-07-08 中国电信股份有限公司 Data import method, system, device and storage medium
CN114722109B (en) * 2022-04-13 2024-02-06 中国电信股份有限公司 Data importing method, system, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN102932141B (en) Add order-preserving method and the system of deciphering chip parallel processing message encryption and decryption
CN109829287A (en) Api interface permission access method, equipment, storage medium and device
CN108536739B (en) Metadata sensitive information field identification method, device, equipment and storage medium
EP3012747B1 (en) Tcam-based table query processing method and apparatus
CN102023843A (en) Function calling method and device as well as smart card
CN105740405B (en) Method and device for storing data
CN111315007A (en) Method and device for sending and receiving synchronization signal block
CN103389976A (en) Searching method and searching system for terminal
CN102915344A (en) SQL (structured query language) statement processing method and device
CN104408183B (en) The data lead-in method and device of data system
CN103198066A (en) Word list based information search method and search system
CN103268262A (en) Method for multiple basebands to access single-user identification card, and processor
CN103870762A (en) Partition accessing method and electronic equipment
CN103810204A (en) Information search method and information search device
CN104765792A (en) Dimension data storing method, device and system
CN104822163A (en) General scheduling system and method used for single-antenna multi-mode multi-card terminal
CN103605782A (en) Data insertion method and device for data table
CN115758989B (en) Method and system for repairing digital chip layout design rule time sequence violation
AU2019241002B2 (en) Transaction processing method and system, and server
CN109657060B (en) Safety production accident case pushing method and system
CN107193656B (en) Resource management method of multi-core system, terminal device and computer readable storage medium
CN107592677B (en) Data transmission method and device
CN104079368A (en) Method of transmitting test data of application software and server
CN107193908B (en) The update method and device of visual field list
CN109587755B (en) Access control method, device and mobile terminal

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20140226

RJ01 Rejection of invention patent application after publication