CN109271404A - Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium - Google Patents

Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium Download PDF

Info

Publication number
CN109271404A
CN109271404A CN201811248442.2A CN201811248442A CN109271404A CN 109271404 A CN109271404 A CN 109271404A CN 201811248442 A CN201811248442 A CN 201811248442A CN 109271404 A CN109271404 A CN 109271404A
Authority
CN
China
Prior art keywords
statement
data base
syntax tree
database
base manipulation
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.)
Withdrawn
Application number
CN201811248442.2A
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 THUNISOFT INFORMATION TECHNOLOGY Co Ltd
Original Assignee
BEIJING THUNISOFT INFORMATION 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 THUNISOFT INFORMATION TECHNOLOGY Co Ltd filed Critical BEIJING THUNISOFT INFORMATION TECHNOLOGY Co Ltd
Priority to CN201811248442.2A priority Critical patent/CN109271404A/en
Publication of CN109271404A publication Critical patent/CN109271404A/en
Withdrawn legal-status Critical Current

Links

Landscapes

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

Abstract

It deletes method, anti-error delete device and electronic equipment this application involves a kind of database is anti-error.Whether it includes limiting the mistake of the condition of deletion that the anti-error method of deleting of the database comprises determining that in data base manipulation statement;And in response to including limiting the mistake of the condition of deletion in the determination data base manipulation statement, the data base manipulation statement is forbidden to operate database.In this way, it is limited based on the mistake in the specific data base manipulation statement of scene settings that database is accidentally deleted in practical O&M about the condition of deletion, it and include after limiting the mistake of the condition of deletion in determining the data base manipulation statement, the data base manipulation statement is forbidden to operate database, in this way, the data being effectively prevented in database are accidentally deleted.

Description

Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium
Technical field
The present invention relates generally to database field, deletes method more particularly to database is anti-error, anti-error deletes device and electricity Sub- equipment.
Background technique
Database is widely used in all trades and professions.In practical applications, miscellaneous people (including research staff, fortune Dimension personnel etc.) various O&M operations can be carried out to database simultaneously, for example, the data etc. in modification, deletion database.It is operating In the process, if limited in data base manipulation statement comprising the mistake to the condition of deletion, this data that should not be deleted is deleted, Catastrophic consequence can be caused to actual environment like that.
Accordingly, there exist a kind of to can be avoided the demand that database is accidentally deleted under the premise of not influencing database normal use.
Summary of the invention
In order to solve the above-mentioned technical problem, the application is proposed.Embodiments herein provides the anti-error side of deleting of database Method, it is anti-error delete device and electronic equipment, based on the specific data of scene settings that database is accidentally deleted in practical O&M Mistake in the action statement of library about the condition of deletion limits, and before data base manipulation statement operates database, To the data base manipulation statement determined in the determination data base manipulation statement whether include to delete condition mistake It accidentally limits, to include after limiting the mistake of the condition of deletion, forbidding the data in determining the data base manipulation statement Library action statement operates database, and in this way, the data being effectively prevented in database are accidentally deleted.
According to the one side of the application, provide that a kind of database is anti-error to delete method, comprising: determine data base manipulation statement In whether include to delete condition mistake limit;And in response to including to deletion in the determination data base manipulation statement The mistake of condition limits, and the data base manipulation statement is forbidden to operate database.
It deletes in method above-mentioned database is anti-error, limiting the mistake of the condition of deletion includes at least one of: the number It is cancel statement or update sentence according to library action statement, and does not have querying condition or institute in the cancel statement or update sentence It is true for having querying condition forever;The data base manipulation statement is truncation table statement;The data base manipulation statement is to delete table Sentence;And the parameter value for the data item disposably deleted or updated in the data base manipulation statement is more than preset threshold.
It deletes in method above-mentioned database is anti-error, determines in data base manipulation statement whether to include mistake to the condition of deletion It limits, comprising: morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the data base manipulation statement Syntax tree;Determine that the syntax tree is cancel statement or the syntax tree for updating sentence, and without inquiry item in the syntax tree Part;And in response to the determination syntax tree be cancel statement or the syntax tree for updating sentence, and it is not looked into the syntax tree Inquiry condition determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
It deletes in method above-mentioned database is anti-error, determines in data base manipulation statement whether to include mistake to the condition of deletion It limits, comprising: morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the data base manipulation statement Syntax tree;It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and has all look into the syntax tree Inquiry condition is true;It and in response to the determination syntax tree is cancel statement or the syntax tree for updating sentence, and the syntax tree In have all querying conditions be it is true, determine to include limiting the mistake of the condition of deletion in data base manipulation statement
It deletes in method above-mentioned database is anti-error, determines in data base manipulation statement whether to include mistake to the condition of deletion It limits, comprising: morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the data base manipulation statement Syntax tree;Determine that the syntax tree is the syntax tree that table statement is truncated;And in response to the determination syntax tree be truncated table The syntax tree of sentence determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
It deletes in method above-mentioned database is anti-error, determines in data base manipulation statement whether to include mistake to the condition of deletion It limits, comprising: morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the data base manipulation statement Syntax tree;Determine that the syntax tree is the syntax tree for deleting table statement;And in response to the determination syntax tree be delete table The syntax tree of sentence determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
It deletes in method above-mentioned database is anti-error, determines in data base manipulation statement whether to include mistake to the condition of deletion It limits, comprising: morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the data base manipulation statement Syntax tree;It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and is disposably deleted in the syntax tree Or the parameter value of the data item updated is more than preset threshold;And in response to the determination syntax tree be cancel statement or update The syntax tree of sentence, and the parameter value for the data item disposably deleted or updated in the syntax tree is more than preset threshold, is determined It include limiting the mistake of the condition of deletion in data base manipulation statement.
It deletes in method above-mentioned database is anti-error, the database is anti-error to delete method, further includes: in response to determining database Include limiting the mistake of the condition of deletion in action statement, exports a notification signal to prompt the data base manipulation statement banned Only execute.
It deletes in method above-mentioned database is anti-error, whether includes mistake to the condition of deletion in determining data base manipulation statement Further comprises before accidentally limiting: whether log-on data library is anti-error deletes operation for switching;And it determines and is wrapped in data base manipulation statement It includes that limit the mistake of the condition of deletion include: that the starting database is anti-error to delete operation in response to being switched to, determines database behaviour Make to include limiting the mistake of the condition of deletion in sentence.
It deletes in method above-mentioned database is anti-error, the database is anti-error to delete method, further includes: in response to the database When into session (session) rank, do not start that the database is anti-error to delete operation, to allow the data base manipulation statement pair Database in current sessions window is operated.
It deletes in method above-mentioned database is anti-error, the database is SQL database, and, the database manipulation language Sentence is SQL statement.
According to the another aspect of the application, also provide that a kind of database is anti-error to delete device comprising: determination unit is used for Determine in data base manipulation statement whether include limiting the mistake of the condition of deletion;And forbid unit, in response to determination Include in the data base manipulation statement to delete condition mistake limit, forbid the data base manipulation statement to database into Row operation.
It deletes in device above-mentioned database is anti-error, limiting the mistake of the condition of deletion includes at least one of: the number It is cancel statement or update sentence according to library action statement, and does not have querying condition or institute in the cancel statement or update sentence It is true for having querying condition forever;The data base manipulation statement is truncation table statement;The data base manipulation statement is to delete table Sentence;And the parameter value for the data item disposably deleted or updated in the data base manipulation statement is more than preset threshold.
It deletes in device above-mentioned database is anti-error, the determination unit is further used for: to the data base manipulation statement Morphological analysis and syntactic analysis are carried out, to obtain the syntax tree of the data base manipulation statement;The syntax tree is determined to delete Sentence or the syntax tree for updating sentence, and there is no querying condition in the syntax tree;And it is in response to the determination syntax tree Cancel statement or the syntax tree for updating sentence, and there is no querying condition in the syntax tree, it determines in data base manipulation statement and wraps It includes and the mistake of the condition of deletion is limited.
It deletes in device above-mentioned database is anti-error, the determination unit is further used for: to the data base manipulation statement Morphological analysis and syntactic analysis are carried out, to obtain the syntax tree of the data base manipulation statement;The syntax tree is determined to delete Sentence or the syntax tree for updating sentence, and it is true for having all querying conditions in the syntax tree;And in response to described in determination Syntax tree is cancel statement or the syntax tree for updating sentence, and having all querying conditions in the syntax tree is very, to determine number According to include in the action statement of library to delete condition mistake limit.
It deletes in device above-mentioned database is anti-error, the determination unit is further used for: to the data base manipulation statement Morphological analysis and syntactic analysis are carried out, to obtain the syntax tree of the data base manipulation statement;Determine the syntax tree for truncation The syntax tree of table statement;And in response to the determination syntax tree be truncated table statement syntax tree, determine database manipulation language It include limiting the mistake of the condition of deletion in sentence.
It deletes in device above-mentioned database is anti-error, the determination unit is further used for: to the data base manipulation statement Morphological analysis and syntactic analysis are carried out, to obtain the syntax tree of the data base manipulation statement;The syntax tree is determined to delete The syntax tree of table statement;And in response to the determination syntax tree be delete table statement syntax tree, determine database manipulation language It include limiting the mistake of the condition of deletion in sentence.
It deletes in device above-mentioned database is anti-error, the determination unit is further used for: to the data base manipulation statement Morphological analysis and syntactic analysis are carried out, to obtain the syntax tree of the data base manipulation statement;The syntax tree is determined to delete Sentence or the syntax tree for updating sentence, and the parameter value for the data item disposably deleted or updated in the syntax tree is more than default Threshold value;It and in response to the determination syntax tree is cancel statement or the syntax tree for updating sentence, and primary in the syntax tree Property delete or update data item parameter value be more than preset threshold, determine in data base manipulation statement include to delete condition Mistake limits.
It deletes in device above-mentioned database is anti-error, the anti-error device of deleting further includes notification unit, in response to determination Include limiting the mistake of the condition of deletion in data base manipulation statement, exports a notification signal to prompt the database manipulation language Sentence is prohibited to execute.
It deletes in device above-mentioned database is anti-error, the anti-error device of deleting further comprises: switch unit, is for switching No log-on data library is anti-error to delete operation;And the determination unit is in response to being switched to, the starting database is anti-error to be deleted Operation determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
It deletes in device above-mentioned database is anti-error, the switch unit is further used for: in response to the data base access When session (session) rank, it is switched to that not log-on data library is anti-error to delete operation;And described unit is forbidden to be further used for The data base manipulation statement is allowed to operate the database in current sessions window.
It deletes in device above-mentioned database is anti-error, the database is SQL database, and, the database manipulation language Sentence is SQL statement.
According to the another aspect of the application, a kind of electronic equipment is provided, comprising: processor;And memory, described Computer program instructions are stored in memory, the computer program instructions make the place when being run by the processor Reason device execution database as described above is anti-error to delete method.
According to the another aspect of the application, a kind of computer readable storage medium is provided, computer program is stored thereon with Instruction is operable to execute that database as described above is anti-error to be deleted when the computer program instructions are executed by a computing apparatus Method.
Database provided by the present application is anti-error delete method, it is anti-error delete device and electronic equipment, can effectively pass through detection It include limiting the mistake of the condition of deletion in data base manipulation statement, to prevent the data in database from accidentally being deleted.
Detailed description of the invention
From the detailed description with reference to the accompanying drawing to the embodiment of the present invention, these and/or other aspects of the invention and Advantage will become clearer and be easier to understand, in which:
Fig. 1 illustrates the anti-error flow charts for deleting method of the database according to the embodiment of the present application.
Fig. 2 is illustrated to be determined in data base manipulation statement according to anti-error delete in method of the database of the embodiment of the present application The flow chart limited including the mistake to the condition of deletion.
Fig. 3 illustrates the anti-error block diagram for deleting device of database according to the embodiment of the present application.
Fig. 4 illustrates the block diagram of the electronic equipment according to the embodiment of the present application.
Specific embodiment
In the following, example embodiment according to the application will be described in detail with reference to the attached drawings.Obviously, described embodiment is only A part of the embodiment of the application, rather than the whole embodiments of the application, it should be understood that the application is not by example described herein The limitation of embodiment.
Application is summarized
As described above, database is widely used in all trades and professions.In practical applications, miscellaneous people can be right simultaneously Database carries out various O&M operations, for example, the data etc. in modification, deletion database.In operation, if database It is limited in action statement comprising the mistake to the condition of deletion, deletes this data that should not be deleted, it like that can be to actual environment Cause catastrophic consequence.
In practical O&M, the scene that the data base manipulation statement of mistake causes data accidentally to be deleted and lost is found, packet It includes: deleting or update the mistake setting for not having querying condition or querying condition in sentence in database;The truncated table of mistake or Table statement is deleted, the data in entire tables of data is caused fully to be deleted;Disposably delete or update a large amount of data item etc..
In view of the above technical problems, the basic conception of the application is based on the field that database is accidentally deleted in practical O&M The mistake that scape sets in specific data base manipulation statement about the condition of deletion limits, and in data base manipulation statement to data Before library is operated, to the data base manipulation statement determined in the determination data base manipulation statement whether include The mistake of the condition of deletion is limited, also, includes limiting the mistake of the condition of deletion in determining the data base manipulation statement Later, forbid the data base manipulation statement to operate database, in this way, prevent the data in database Accidentally deleted.
Based on this, the present invention provide a kind of database it is anti-error delete method, it is anti-error delete device and electronic equipment, first determine It whether include limiting the mistake of the condition of deletion in data base manipulation statement;Then, in response to the determination database manipulation language Include limiting the mistake of the condition of deletion in sentence, the data base manipulation statement is forbidden to operate database.In this way, passing through In Test database action statement whether include to delete condition mistake limit, prevent the data in database accidentally deleted and Lead to loss of data.
After describing the basic principle of the application, carry out the various non-limits for specifically introducing the application below with reference to the accompanying drawings Property embodiment processed.
Exemplary process
Fig. 1 illustrates the anti-error flow charts for deleting method of the database according to the embodiment of the present application.As shown in Figure 1, according to this Apply for that the database of embodiment is anti-error and delete method, comprising: S110 determines in data base manipulation statement whether include to deletion condition Mistake limit;And S120, in response to including limiting the mistake of the condition of deletion in the determination data base manipulation statement, The data base manipulation statement is forbidden to operate database.
In step s 110, determine in data base manipulation statement whether include limiting the mistake of the condition of deletion.Institute as above It states, in practical O&M, it is found that the data base manipulation statement of mistake causes data to be had by the scene accidentally deleted and lost: in data Delete or update the mistake setting for not having querying condition or querying condition in sentence in library;The truncated table of mistake deletes predicative Sentence, causes the data in entire tables of data fully to be deleted;Disposably delete or update a large amount of data item etc..
Scene is accidentally deleted for above-mentioned database, in the embodiment of the present application, setting, which limits the mistake of the condition of deletion, includes At least one of: the data base manipulation statement is cancel statement or update sentence, and in the cancel statement or more newspeak There is no querying condition in sentence or all querying conditions are true forever;The data base manipulation statement is truncation table statement;The number It is to delete table statement according to library action statement;And the data item disposably deleted or updated in the data base manipulation statement Parameter value is more than preset threshold.
Correspondingly, when detecting includes that as above any mistake limits in data base manipulation statement, determine data It include limiting the mistake of the condition of deletion in the action statement of library.In turn, it executes step S120: being grasped in response to the determination database Make to include limiting the mistake of the condition of deletion in sentence, the data base manipulation statement is forbidden to operate database.Also It is to say, when determining to limit in the data base manipulation statement comprising the mistake to the condition of deletion, forbids the database manipulation Sentence operates the database, and in this way, the data being effectively prevented in database are accidentally deleted.Having Whether during body is implemented, can be used under type detects in the data base manipulation statement includes mistake restriction to the condition of deletion.
Fig. 2 is illustrated to be determined in data base manipulation statement according to anti-error delete in method of the database of the embodiment of the present application The flow chart limited including the mistake to the condition of deletion.As shown in Fig. 2, firstly, carrying out morphology to the data base manipulation statement Analysis and syntactic analysis, to obtain the syntax tree of the data base manipulation statement.Those skilled in the art it would be appreciated that, number It is structured statement according to library action statement, with specific grammer.Therefore, institute can be generated by morphological analysis and syntactic analysis The syntax tree of data base manipulation statement is stated, and by being analyzed the syntax tree whether to determine the data base manipulation statement It is limited including the mistake to the condition of deletion.
Correspondingly, it is limited corresponding to the above-mentioned mistake to the condition of deletion, further analyzes whether the syntax tree is deletion Sentence or the syntax tree for updating sentence, also, determine whether have querying condition in the syntax tree.In this way, described in the determination Syntax tree is cancel statement or the syntax tree for updating sentence, and after not having querying condition in the syntax tree, just determine described in It include limiting the mistake of the condition of deletion in data base manipulation statement.
Correspondingly, it is limited corresponding to the above-mentioned mistake to the condition of deletion, further analyzes whether the syntax tree is deletion Sentence or the syntax tree for updating sentence, and have whether all querying conditions are true in the syntax tree.In this way, described in the determination Syntax tree is cancel statement or the syntax tree for updating sentence, and after having all querying conditions to be true in the syntax tree, just Determine to include limiting the mistake of the condition of deletion in the data base manipulation statement
Correspondingly, it is limited corresponding to the above-mentioned mistake to the condition of deletion, further analyzes whether the syntax tree is truncation The syntax tree of table statement.In this way, just determining the database after determining the syntax tree that the syntax tree is truncation table statement It include limiting the mistake of the condition of deletion in action statement.
Correspondingly, it is limited corresponding to the above-mentioned mistake to the condition of deletion, further analyzes whether the syntax tree is deletion The syntax tree of table statement.In this way, just determining the database after determining the syntax tree that the syntax tree is deletion table statement It include limiting the mistake of the condition of deletion in action statement.
Correspondingly, it is limited corresponding to the above-mentioned mistake to the condition of deletion, further analyzes whether the syntax tree is deletion Sentence or update sentence syntax tree, and the parameter value for the data item disposably deleted or updated in the syntax tree whether be more than Preset threshold.In this way, determining that the syntax tree is cancel statement or the syntax tree for updating sentence, and it is primary in the syntax tree Property delete or update data item parameter value be more than preset threshold, just determine in the data base manipulation statement to include to deletion The mistake of condition limits.It is noted that in specific implementation, which can be according to the O&M situation or need of database It asks and does adaptive adjustment.In this regard, not limited to by the application.
It can be " to determine in the data base manipulation statement in specific implementation to enhance the practicability of the database Limited including the mistake to the condition of deletion, the data base manipulation statement forbidden to operate database " pattern configurations it is special Fixed operation mode, for example, " careful mode ".That is, forbidding including pair when the database is under " careful mode " The data base manipulation statement that the mistake of deletion condition limits operates the database.
It should be understood that being somebody's turn to do " careful mode " can artificially close, to allow the data base manipulation statement to the database It is operated.Optionally, described " operation with caution " mode can automatically be turned off in session-level.For example, working as some client End is connected to database, when needing to carry out large batch of update to data, can automatically turn off " operation with caution " mode, turn off Afterwards, current sessions can carry out any of the above operation.Also, the modification of the parameter is only effective to current sessions, which moves State modification does not influence remaining session.
That is, in determining data base manipulation statement include before limiting the mistake of the condition of deletion can to whether Log-on data library is anti-error to delete operation and switches over, that is, switches and whether enter above-mentioned " operation with caution " mode, and open being switched to When moving that the database is anti-error to delete operation, that is, when being switched to above-mentioned " operation with caution " mode, determining in data base manipulation statement is No includes limiting the mistake of the condition of deletion, and forbid the data base manipulation statement in the case where limiting including the mistake Database is operated.In addition, may be selected in determining data base manipulation statement to enhance the interactivity of the database After limiting including the mistake to the condition of deletion, a notification signal is exported to prompt the data base manipulation statement to be prohibited to execute. For example, including limiting the mistake of the condition of deletion in determining data base manipulation statement, output " is checked whether and deleted comprising mistake Except " notification signal, to prompt the user of client that need to operate with caution.
Hereinafter, being SQL statement for example by SQL database, the data base manipulation statement of the database, illustrate institute State the anti-error concrete application for deleting method of database.It would be appreciated that the database provided herein is anti-error to delete method also It can be applied to other kinds of database, for example, oracle database etc..In this regard, not limited to by the application.
It corresponds in SQL database, the above-mentioned mistake to the condition of deletion limits tool and turns to:
First: the SQL statement is cancel statement (Delete), and querying condition (where is not added in cancel statement Condition) or querying condition be forever true, such as where condition is 1=1.
Second: the SQL statement is to update sentence (Update), and querying condition (where is not added in updating sentence Condition) or querying condition be forever true, such as where condition is 1=1.
Third: the SQL statement is truncation table statement (Truncate Table).It is noted that compared to deletion Full table statement (Drop table), truncation table statement execute speed faster, and data are more difficult to restore.
4th: the SQL statement is to delete table statement (Drop table), wherein the deletion table statement can not only Truncated data, meanwhile, also the structure of table is cleaned up.
5th: the SQL statement is cancel statement (Delete), also, the data item disposably deleted is more than default threshold Value.
6th: the SQL statement is to update sentence (Update), also, the data item disposably updated is more than default threshold Value.
Correspondingly, when detect include in the SQL statement it is as above any described when limiting the mistake of the condition of deletion, Just determine to include limiting the mistake of the condition of deletion in the SQL statement.In turn, in response to including in the determination SQL statement The mistake of the condition of deletion is limited, the SQL statement is forbidden to operate the SQL database.
It similarly, can be " to determine to include limiting the mistake of the condition of deletion in the SQL statement, forbid the SQL statement SQL database is operated " the specific operation mode of pattern configurations, for example, " careful mode ".In other words, as the SQL Database is under " careful mode ", forbids the SQL statement limited comprising the mistake to the condition of deletion to the SQL data Library is operated.
Under careful mode, whether detection determines in the SQL statement to include the rule for limiting the mistake of the condition of deletion It is then as follows.
Firstly, morphological analysis and syntactic analysis are carried out to the SQL statement, to obtain the syntax tree of the SQL statement.This The technical staff in field it would be appreciated that, SQL is structured statement, with specific grammer.Therefore, morphological analysis can be passed through The syntax tree of the SQL statement is generated with syntactic analysis, and by being analyzed the syntax tree to determine that the SQL statement is No includes limiting the mistake of the condition of deletion.
Correspondingly, correspond to first mistake to limit, can further analyze whether the syntax tree is cancel statement (Delete) syntax tree, also, determine whether to have where condition in the syntax tree or all where conditions are No is true.In this way, determine the syntax tree be cancel statement syntax tree, and do not have in the syntax tree where condition or After all where conditions of person are true, determine to include limiting the mistake of the condition of deletion in the SQL statement.
Correspondingly, correspond to Article 2 mistake to limit, can further analyze whether the syntax tree is to update sentence (Update) syntax tree, also, determine whether to have where condition in the syntax tree or all where conditions are No is true.In this way, determine the syntax tree be update sentence syntax tree, and do not have in the syntax tree where condition or After all where conditions of person are true, determine to include limiting the mistake of the condition of deletion in the SQL statement.
Correspondingly, correspond to Article 3 mistake to limit, can further analyze whether the syntax tree is truncation table statement The syntax tree of (Truncate Table).In this way, determining institute after determining the syntax tree that the syntax tree is truncation table statement State includes limiting the mistake of the condition of deletion in SQL statement.
Correspondingly, correspond to Article 4 mistake to limit, can further analyze whether the syntax tree is to delete table statement The syntax tree of (Drop Table).In this way, after determining the syntax tree that the syntax tree is deletion table statement, just described in judgement It include limiting the mistake of the condition of deletion in SQL statement.
Correspondingly, correspond to Article 5 mistake to limit, can further analyze whether the syntax tree is cancel statement (Delete) syntax tree, and whether the parameter value for the data item disposably deleted in the syntax tree is more than preset threshold.This Sample is determining that the syntax tree is the syntax tree of cancel statement, and the parameter for the data item disposably deleted in the syntax tree Value is more than preset threshold, just determines to include limiting the mistake of the condition of deletion in the SQL statement.It is noted that having During body is implemented, which can do adaptive adjustment according to the O&M situation or demand of database.In this regard, not being the application Limited to.
Correspondingly, correspond to Article 6 mistake to limit, can further analyze whether the syntax tree is to update sentence (Update) syntax tree, and whether the parameter value of the data item disposably updated in the syntax tree is more than preset threshold.This Sample is determining that the syntax tree is the syntax tree for updating sentence, and the parameter of the data item disposably updated in the syntax tree Value is more than preset threshold, just determines to include limiting the mistake of the condition of deletion in the SQL statement.It is noted that having During body is implemented, which can do adaptive adjustment according to the O&M situation or demand of database.In this regard, not being the application Limited to.
It should be understood that " careful " mode of being somebody's turn to do can be closed artificially, to allow the SQL statement to carry out the SQL database Operation.Optionally, described " operation with caution " mode can automatically be turned off in session-level.For example, when some client connects It is connected to database, " operation with caution " mode, after turning off, current meeting when needing to carry out large batch of update to data, can be turned off Words can carry out any of the above operation.Also, the modification of the parameter is only effective to current sessions, and the dynamic of the parameter is modified to it Remaining session does not influence.
In addition, may be selected to include to deletion item in determining the SQL statement to enhance the interactivity of the database After the mistake of part limits, a notification signal is exported to prompt the SQL statement to be prohibited to execute.For example, in determining SQL statement It is limited including the mistake to the condition of deletion, the notification signal of output " check whether and deleted comprising mistake ", to prompt client User need to operate with caution.
To sum up, method is deleted according to the database provided herein is anti-error, based on the database in practical O&M Mistake in the specific data base manipulation statement of the scene settings accidentally deleted about the condition of deletion limits, and grasps in database Make to determine with the determination database manipulation language data base manipulation statement before sentence operates database It whether include limiting the mistake of the condition of deletion in sentence, to include to the condition of deletion in determining the data base manipulation statement After mistake limits, forbids the data base manipulation statement to operate database, in this way, be effectively prevented Data in database are accidentally deleted.
Schematic apparatus
Fig. 3 illustrates the anti-error block diagram for deleting device of database according to the embodiment of the present application.
As shown in figure 3, the anti-error device 300 of deleting of database according to the embodiment of the present application comprises determining that unit 310, it is used for Determine in data base manipulation statement whether include limiting the mistake of the condition of deletion;And forbid unit 320, in response to Determine to include limiting the mistake of the condition of deletion in the data base manipulation statement, forbids the data base manipulation statement to data Library is operated.
In one example, it deletes in device 300 above-mentioned database is anti-error, it includes following for limiting the mistake of the condition of deletion At least one: the data base manipulation statement is cancel statement or updates sentence, and in the cancel statement or is updated in sentence There is no querying condition or all querying conditions are true forever;The data base manipulation statement is truncation table statement;The database Action statement is to delete table statement;And the parameter for the data item disposably deleted or updated in the data base manipulation statement Value is more than preset threshold.
In one example, it deletes in device 300 above-mentioned database is anti-error, the determination unit 310 is further used for: Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the syntax tree of the data base manipulation statement; It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and there is no querying condition in the syntax tree;And it rings And should not there is no querying condition in the syntax tree, really in determining that the syntax tree is cancel statement or the syntax tree for updating sentence Determine to include limiting the mistake of the condition of deletion in data base manipulation statement.
In one example, it deletes in device 300 above-mentioned database is anti-error, the determination unit 310 is further used for: Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the syntax tree of the data base manipulation statement; It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and there are all querying conditions to be in the syntax tree Very;And in response to the determination syntax tree be cancel statement or the syntax tree for updating sentence, and have in the syntax tree all Querying condition be it is true, determine to include limiting the mistake of the condition of deletion in data base manipulation statement.
In one example, it deletes in device 300 above-mentioned database is anti-error, the determination unit 310 is further used for: Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the syntax tree of the data base manipulation statement; Determine that the syntax tree is the syntax tree that table statement is truncated;And in response to the determination syntax tree be truncated table statement language Method tree determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
In one example, it deletes in device 300 above-mentioned database is anti-error, the determination unit 310 is further used for: Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the syntax tree of the data base manipulation statement; Determine that the syntax tree is the syntax tree for deleting table statement;And in response to the determination syntax tree be delete table statement language Method tree determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
In one example, it deletes in device 300 above-mentioned database is anti-error, the determination unit 310 is further used for: Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the syntax tree of the data base manipulation statement; Determine that the syntax tree is cancel statement or the syntax tree for updating sentence, and the number disposably deleted or updated in the syntax tree Parameter value according to item is more than preset threshold;And in response to the determination syntax tree be cancel statement or update sentence grammer Tree, and the parameter value for the data item disposably deleted or updated in the syntax tree is more than preset threshold, determines database manipulation It include limiting the mistake of the condition of deletion in sentence.
In one example, delete in device 300 above-mentioned database is anti-error, further include notification unit 330, in response to Determine to include limiting the mistake of the condition of deletion in data base manipulation statement, exports a notification signal to prompt the database to grasp It is prohibited to execute as sentence.
In one example, it deletes in device 300 above-mentioned database is anti-error, further includes switch unit 340, be for switching No log-on data library is anti-error to delete operation;And the determination unit 310 is for anti-error in response to being switched to the starting database Operation is deleted, determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
In one example, it deletes in device 300 above-mentioned database is anti-error, the switch unit 340 is further used for: ringing Described in Ying Yu when data base access session (session) rank, do not start that the database is anti-error to delete operation;And described forbid Unit 320 is further used for that the data base manipulation statement is allowed to operate the database in current sessions window.
In one example, it deletes in device 300 above-mentioned database is anti-error, the database is SQL database, and, The data base manipulation statement is SQL statement.
Here, it will be understood by those skilled in the art that the anti-error each unit and module deleted in device 300 of above-mentioned database Concrete function and operation have been described above referring to figs. 1 to Fig. 2 description anti-error delete in method of database be discussed in detail, and because This, will omit its repeated description.
As described above, the anti-error device of deleting of database according to the embodiment of the present application may be implemented in various terminal equipment, Such as in database server.In one example, it can be used as one according to the anti-error device of deleting of the database of the embodiment of the present application A software module and/or hardware module and be integrated into the terminal device.For example, the anti-error device of deleting of the database can be this A software module in the operating system of terminal device, or can be and be directed to the application that the terminal device is developed Program;Certainly, the database is anti-error deletes device equally and can be one of numerous hardware modules of the terminal device.
Alternatively, in another example, the database is anti-error deletes device and the terminal device is also possible to discrete terminal Equipment, and the anti-error device of deleting of the database can be connected to the terminal device by wired and or wireless network, and according to The data format of agreement transmits interactive information.
Exemplary electronic device
In the following, being described with reference to Figure 4 the electronic equipment according to the embodiment of the present application.
Fig. 4 illustrates the block diagram of the electronic equipment according to the embodiment of the present application.
As shown in figure 4, electronic equipment 10 includes one or more processors 11 and memory 12.
Processor 11 can be central processing unit (CPU) or have data-handling capacity and/or instruction execution capability Other forms processing unit, and can control the other assemblies in electronic equipment 10 to execute desired function.
Memory 12 may include one or more computer program products, and the computer program product may include each The computer readable storage medium of kind form, such as volatile memory and/or nonvolatile memory.The volatile storage Device for example may include random access memory (RAM) and/or cache memory (cache) etc..It is described non-volatile to deposit Reservoir for example may include read-only memory (ROM), hard disk, flash memory etc..It can be deposited on the computer readable storage medium One or more computer program instructions are stored up, processor 11 can run described program instruction, to realize this Shen described above The database of each embodiment please is anti-error to delete method and/or other desired functions.
In one example, electronic equipment 10 can also include: input unit 13 and output device 14, these components pass through The interconnection of bindiny mechanism's (not shown) of bus system and/or other forms.
For example, the input unit 13 can be such as keyboard, mouse etc..
The output unit 14 can be output to the outside various information, including notification information etc..The output equipment 14 can wrap Include such as display, loudspeaker, printer and communication network and its remote output devices connected etc..
Certainly, to put it more simply, illustrated only in Fig. 4 it is some in component related with the application in the electronic equipment 10, The component of such as bus, input/output interface etc. is omitted.In addition to this, according to concrete application situation, electronic equipment 10 is also It may include any other component appropriate.
Exemplary computer program product
Other than the above method and equipment, embodiments herein can also be computer program product comprising meter Calculation machine program instruction, it is above-mentioned that the computer program instructions make the processor execute this specification when being run by processor According to the anti-error step deleted in method of database of the various embodiments of the application described in " illustrative methods " part.
The computer program product can be write with any combination of one or more programming languages for holding The program code of row the embodiment of the present application operation, described program design language includes object oriented program language, such as Java, C++ etc. further include conventional procedural programming language.Program code can fully on the user computing device It executes, partly execute on a user device, being executed as an independent software package, part part on the user computing device It executes or is executed in remote computing device or server completely on a remote computing.
In addition, embodiments herein can also be computer readable storage medium, it is stored thereon with computer program and refers to It enables, the computer program instructions make the processor execute above-mentioned " the exemplary side of this specification when being run by processor According to the anti-error step deleted in method of database of the various embodiments of the application described in method " part.
The computer readable storage medium can be using any combination of one or more readable mediums.Readable medium can To be readable signal medium or readable storage medium storing program for executing.Readable storage medium storing program for executing for example can include but is not limited to electricity, magnetic, light, electricity Magnetic, the system of infrared ray or semiconductor, device or device, or any above combination.Readable storage medium storing program for executing it is more specific Example (non exhaustive list) includes: the electrical connection with one or more conducting wires, portable disc, hard disk, random access memory Device (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc Read-only memory (CD-ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.
The basic principle of the application is described in conjunction with specific embodiments above, however, it is desirable to, it is noted that in this application The advantages of referring to, advantage, effect etc. are only exemplary rather than limitation, must not believe that these advantages, advantage, effect etc. are the application Each embodiment is prerequisite.In addition, detail disclosed above is merely to exemplary effect and the work being easy to understand With, rather than limit, it is that must be realized using above-mentioned concrete details that above-mentioned details, which is not intended to limit the application,.
Device involved in the application, device, equipment, system block diagram only as illustrative example and be not intended to It is required that or hint must be attached in such a way that box illustrates, arrange, configure.As those skilled in the art will appreciate that , it can be connected by any way, arrange, configure these devices, device, equipment, system.Such as "include", "comprise", " tool " etc. word be open vocabulary, refer to " including but not limited to ", and can be used interchangeably with it.Vocabulary used herein above "or" and "and" refer to vocabulary "and/or", and can be used interchangeably with it, unless it is not such that context, which is explicitly indicated,.Here made Vocabulary " such as " refers to phrase " such as, but not limited to ", and can be used interchangeably with it.
It may also be noted that each component or each step are can to decompose in the device of the application, device and method And/or reconfigure.These decompose and/or reconfigure the equivalent scheme that should be regarded as the application.
The above description of disclosed aspect is provided so that any person skilled in the art can make or use this Application.Various modifications in terms of these are readily apparent to those skilled in the art, and are defined herein General Principle can be applied to other aspect without departing from scope of the present application.Therefore, the application is not intended to be limited to Aspect shown in this, but according to principle disclosed herein and the consistent widest range of novel feature.
In order to which purpose of illustration and description has been presented for above description.In addition, this description is not intended to the reality of the application It applies example and is restricted to form disclosed herein.Although already discussed above multiple exemplary aspects and embodiment, this field skill Its certain modifications, modification, change, addition and sub-portfolio will be recognized in art personnel.

Claims (10)

1. a kind of database is anti-error to delete method, comprising:
Determine in data base manipulation statement whether include limiting the mistake of the condition of deletion;And
In response to including limiting the mistake of the condition of deletion in the determination data base manipulation statement, forbid the database manipulation Sentence operates database.
2. database as described in claim 1 is anti-error to delete method, wherein it includes following that the mistake of described pair of deletion condition, which limits, At least one:
The data base manipulation statement is cancel statement or updates sentence, and is not looked into the cancel statement or update sentence Inquiry condition or all querying conditions are true forever;
The data base manipulation statement is truncation table statement;
The data base manipulation statement is to delete table statement;And
The parameter value for the data item disposably deleted or updated in the data base manipulation statement is more than preset threshold.
3. database as claimed in claim 2 is anti-error to delete method, wherein determine in data base manipulation statement whether to include to deleting Include: except the mistake of condition limits
Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the grammer of the data base manipulation statement Tree;
It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and there is no querying condition in the syntax tree;With And
It is cancel statement or the syntax tree for updating sentence in response to the determination syntax tree, and without inquiry item in the syntax tree Part determines to include limiting the mistake of the condition of deletion in data base manipulation statement.
4. database as claimed in claim 2 is anti-error to delete method, wherein determine in data base manipulation statement whether to include to deleting Include: except the mistake of condition limits
Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the grammer of the data base manipulation statement Tree;
It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and has all querying conditions in the syntax tree It is true;And
It is cancel statement or the syntax tree for updating sentence in response to the determination syntax tree, and has all look into the syntax tree Inquiry condition is very, to determine to include limiting the mistake of the condition of deletion in data base manipulation statement.
5. database as claimed in claim 2 is anti-error to delete method, wherein determine in data base manipulation statement whether to include to deleting Include: except the mistake of condition limits
Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the grammer of the data base manipulation statement Tree;
Determine that the syntax tree is the syntax tree that table statement is truncated;And
It is the syntax tree that table statement is truncated in response to the determination syntax tree, determines in data base manipulation statement to include to deletion item The mistake of part limits.
6. database as claimed in claim 2 is anti-error to delete method, wherein determine in data base manipulation statement whether to include to deleting Include: except the mistake of condition limits
Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the grammer of the data base manipulation statement Tree;
Determine that the syntax tree is the syntax tree for deleting table statement;And
It is the syntax tree for deleting table statement in response to the determination syntax tree, determines in data base manipulation statement to include to deletion item The mistake of part limits.
7. database as claimed in claim 2 is anti-error to delete method, wherein determine in data base manipulation statement whether to include to deleting Except the mistake of condition limits, comprising:
Morphological analysis and syntactic analysis are carried out to the data base manipulation statement, to obtain the grammer of the data base manipulation statement Tree;
It determines that the syntax tree is cancel statement or the syntax tree for updating sentence, and disposably deletes or update in the syntax tree Data item parameter value be more than preset threshold;And
It is cancel statement or the syntax tree for updating sentence in response to the determination syntax tree, and is disposably deleted in the syntax tree Or the parameter value of the data item updated is more than preset threshold, determines to include limiting the mistake of the condition of deletion in data base manipulation statement It is fixed.
8. a kind of database is anti-error to delete device, comprising:
Whether determination unit includes limiting the mistake of the condition of deletion for determining in data base manipulation statement;And
Forbid unit, for forbidding in response to including limiting the mistake of the condition of deletion in the determination data base manipulation statement The data base manipulation statement operates database.
9. a kind of electronic equipment, comprising:
Processor;And
Memory is stored with computer program instructions in the memory, and the computer program instructions are by the processing Device executes the processor, and such as database of any of claims 1-7 is anti-error deletes method.
10. a kind of computer readable storage medium, which is characterized in that be stored with computer on the computer readable storage medium Program instruction is operable to execute as any in claim 1-7 when the computer program instructions are executed by a computing apparatus Database is anti-error described in item deletes method.
CN201811248442.2A 2018-10-25 2018-10-25 Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium Withdrawn CN109271404A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811248442.2A CN109271404A (en) 2018-10-25 2018-10-25 Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811248442.2A CN109271404A (en) 2018-10-25 2018-10-25 Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium

Publications (1)

Publication Number Publication Date
CN109271404A true CN109271404A (en) 2019-01-25

Family

ID=65195143

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811248442.2A Withdrawn CN109271404A (en) 2018-10-25 2018-10-25 Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium

Country Status (1)

Country Link
CN (1) CN109271404A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103338208A (en) * 2013-07-16 2013-10-02 五八同城信息技术有限公司 Method and system for SQL injection and defense
US20180084007A1 (en) * 2016-09-20 2018-03-22 Microsoft Technology Licensing, Llc Database query injection detection and prevention
CN108563694A (en) * 2018-03-19 2018-09-21 广州视源电子科技股份有限公司 Method, apparatus, computer equipment and storage medium are executed to the SQL that logic is deleted

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103338208A (en) * 2013-07-16 2013-10-02 五八同城信息技术有限公司 Method and system for SQL injection and defense
US20180084007A1 (en) * 2016-09-20 2018-03-22 Microsoft Technology Licensing, Llc Database query injection detection and prevention
CN108563694A (en) * 2018-03-19 2018-09-21 广州视源电子科技股份有限公司 Method, apparatus, computer equipment and storage medium are executed to the SQL that logic is deleted

Similar Documents

Publication Publication Date Title
WO2020081453A1 (en) Human-computer interaction processing system, method, storage medium and electronic device
US20150077419A1 (en) Visualization of data related to unstructured text
CN107391115B (en) A kind of method, apparatus and computer equipment for realizing pop-up alternative events
US11625405B2 (en) System and method for object-oriented pattern matching in arbitrary data object streams
CN107679700A (en) Business flow processing method, apparatus and server
CN105335435B (en) File management method and information processing equipment
CN107273369B (en) Table data modification method and device
CN109657177A (en) The generation method of the page, device, storage medium and computer equipment after upgrading
WO2014194654A1 (en) Method and apparatus for page view switching
CN113568626B (en) Dynamic packaging and application package opening method and device and electronic equipment
CN108241496A (en) The smooth upgrading method and device of application program
US20150007130A1 (en) Software development using gestures
US10482162B2 (en) Automatic equation transformation from text
US9037994B2 (en) Navigation to a data definition in a diff context
KR20200063886A (en) Natural language processing based call center support system and method
CN103713945B (en) The recognition methods of game and device
US20210397646A1 (en) Method, electronic device, and storage medium for processing visual data of deep model
CN109240698A (en) A kind of incremental compilation processing method and processing device
CN114036501A (en) APP detection method, system, device, equipment and storage medium
US9646157B1 (en) Systems and methods for identifying repackaged files
CN109271404A (en) Database is anti-error to delete method, apparatus, electronic equipment and computer-readable medium
CN111385661B (en) Method, device, terminal and storage medium for voice control of full screen playing
CN109074324A (en) Programable display, terminal installation and control system
JP2012178137A (en) Security policy management server and security monitoring system
CN114881235A (en) Inference service calling method and device, electronic equipment and storage medium

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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20190125