CN116010419A - Method and device for creating unique index and optimizing logic deletion - Google Patents

Method and device for creating unique index and optimizing logic deletion Download PDF

Info

Publication number
CN116010419A
CN116010419A CN202310075206.XA CN202310075206A CN116010419A CN 116010419 A CN116010419 A CN 116010419A CN 202310075206 A CN202310075206 A CN 202310075206A CN 116010419 A CN116010419 A CN 116010419A
Authority
CN
China
Prior art keywords
data
deletion
annotation
logical
logic
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
CN202310075206.XA
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.)
Jiangxi Digital Internet Connection Information Security Technology Co ltd
Original Assignee
Jiangxi Digital Internet Connection Information Security 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 Jiangxi Digital Internet Connection Information Security Technology Co ltd filed Critical Jiangxi Digital Internet Connection Information Security Technology Co ltd
Priority to CN202310075206.XA priority Critical patent/CN116010419A/en
Publication of CN116010419A publication Critical patent/CN116010419A/en
Pending legal-status Critical Current

Links

Images

Landscapes

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

Abstract

The specification discloses a method and a device for creating a unique index and optimizing logic deletion, which are characterized in that firstly, database operation sentences are obtained, the type of the database operation sentences is determined, if the type of the database operation sentences is the unique index, first data corresponding to the database operation sentences are obtained, logic deletion notes corresponding to the first data are determined, and fields corresponding to the logic deletion notes are added to the unique index corresponding to the first data. If the type of the database operation statement is a deletion operation, updating a field corresponding to the logical deletion annotation of the first data according to the logical deletion annotation so as to logically delete the first data. If the type of the database operation statement is modification or inquiry, automatically searching the first data which is not deleted by the logic according to the logic deletion annotation.

Description

Method and device for creating unique index and optimizing logic deletion
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for creating a unique index and optimizing logical deletion.
Background
Currently, when performing a delete operation on a database table, a logical delete operation is often performed on the database table, rather than a physical delete operation. While in performing logical deletion of database tables, a conflict problem of unique indexes of the logically deleted database tables may occur.
For example, if a data table has a unique index of a and a constraint field of f (non-logical deletion field), and a record r in the data table is logically deleted, if a record is newly added and the value of f in the record r is the same, the newly added record fails due to the existence of the unique index of a.
Meanwhile, when the database table is operated, the processing flow of the logical deletion field is required to be manually increased, and the operation efficiency is low.
Therefore, how to solve the problem that the unique index conflicts after the database table is deleted logically, and at the same time, improving the operation efficiency of the database table is a problem to be solved.
Disclosure of Invention
The specification provides a method, a device, a medium and an electronic device for creating a unique index and optimizing logical deletion, so as to partially solve the technical problem that the unique index generates conflict after a database table is deleted by the logic.
The technical scheme adopted in the specification is as follows:
the present specification provides a method of creating a unique index and optimizing logical deletion, comprising:
acquiring a database operation statement and determining the type of the database operation statement;
if the type is the unique index, acquiring first data corresponding to the database operation statement, determining a logic deletion annotation corresponding to the first data, and adding a field corresponding to the logic deletion annotation to the unique index corresponding to the first data;
if the type is a deletion operation, updating a field corresponding to the logical deletion annotation of the first data according to the attribute value of the logical deletion annotation so as to logically delete the first data;
and if the type is modification or inquiry, automatically searching the field corresponding to the logical deletion annotation as the first data which is not logically deleted according to the attribute value of the logical deletion annotation.
Optionally, if the type is modification or query, automatically retrieving, according to the logical deletion annotation, the first data whose field corresponding to the logical deletion annotation is not logically deleted, including:
and judging whether the entity class corresponding to the first data contains the logic deletion identifier or not, and if so, automatically searching the field corresponding to the logic deletion annotation as the first data which is not deleted by logic according to the logic deletion annotation.
Optionally, if the type is creating a unique index, acquiring first data corresponding to the database operation statement, determining a logical deletion annotation corresponding to the first data, and adding a field corresponding to the logical deletion annotation to the unique index corresponding to the first data, where the method specifically includes:
if the type is a unique index, acquiring first data corresponding to the database operation statement;
judging whether the entity class corresponding to the first data contains the logic deletion identifier, if so, determining a field corresponding to the logic deletion annotation corresponding to the first data, and adding the field corresponding to the logic deletion annotation to the unique index corresponding to the first data.
Optionally, the determining whether the entity class corresponding to the first data includes the logical deletion identifier specifically includes:
judging whether the entity class corresponding to the first data contains the logic deletion identifier or not, and executing the database operation statement if the entity class corresponding to the first data does not contain the logic deletion identifier.
Optionally, if the type is a delete operation, updating a field corresponding to the logical delete annotation of the first data according to the logical delete annotation, so as to logically delete the first data, including:
if the type is a deletion operation, judging whether the entity class corresponding to the first data contains the logic deletion identifier or not;
and if the logic deletion identification is determined to be included, updating a field corresponding to the logic deletion annotation of the first data according to the logic deletion annotation so as to logically delete the first data.
Optionally, the determining whether the entity class corresponding to the first data includes the logical deletion identifier specifically includes:
judging whether the entity class corresponding to the first data contains the logic deletion identifier, and executing the database operation statement if the entity class corresponding to the first data does not contain the logic deletion identifier, so as to realize the physical deletion of the first data.
Optionally, the logical delete annotation attribute value includes: updating the logical delete annotation to be at least one of a field corresponding to a current primary key, updating the logical delete annotation to be a field corresponding to a current timestamp, and updating the field corresponding to the logical delete annotation to be NULL.
The present specification provides an apparatus for creating a unique index and optimizing logical deletion, comprising:
the acquisition module is used for acquiring the database operation statement and determining the type of the database operation statement;
the unique index creating module is used for acquiring first data corresponding to the database operation statement, determining a logical deletion annotation corresponding to the first data and adding a field corresponding to the logical deletion annotation to the unique index corresponding to the first data if the type is the unique index;
the deleting module is used for updating a field corresponding to the logical deletion annotation of the first data according to the attribute value of the logical deletion annotation if the type is a deleting operation so as to logically delete the first data;
and the modification and query module is used for automatically searching the first data which is not logically deleted in the field corresponding to the logical deletion annotation according to the attribute value of the logical deletion annotation if the type is modification or query.
The present specification provides a computer readable storage medium storing a computer program which when executed by a processor implements the method of creating a unique index and optimizing logical deletion described above.
The present specification provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above method of creating unique indexes and optimizing logical deletions when executing the program.
The above-mentioned at least one technical scheme that this specification adopted can reach following beneficial effect:
in the method for creating the unique index and optimizing the logic deletion provided by the specification, firstly, a database operation statement is obtained, the type of the database operation statement is determined, if the type of the database operation statement is the unique index, first data corresponding to the database operation statement is obtained, a logic deletion annotation corresponding to the first data is determined, and a field corresponding to the logic deletion annotation is added to the unique index corresponding to the first data. If the type of the database operation statement is a deletion operation, updating a field corresponding to the logical deletion annotation of the first data according to the logical deletion annotation so as to logically delete the first data. If the type of the database operation statement is modification or inquiry, automatically searching the first data which is not deleted by the logic according to the logic deletion annotation.
According to the method, in the method for creating the unique index and optimizing the logic deletion, the logic deletion annotation can be added to the unique index of the database data to increase the diversity of the unique index, so that the condition that the new data table record cannot be created due to the conflict between the logic deletion field and the unique index when the data table record is newly added is avoided, and the technical problem that the unique index conflicts after the database table is deleted is solved. Meanwhile, when query or modification operation is executed, data which is not deleted logically can be automatically searched, so that the operation efficiency is improved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification, illustrate and explain the exemplary embodiments of the present specification and their description, are not intended to limit the specification unduly. In the drawings:
FIG. 1 is a flow chart of a method of creating unique indexes and optimizing logical deletions provided in the present specification;
FIG. 2 is a flow chart of a new operation provided in the present specification;
FIG. 3 is a flow chart of a delete operation provided herein;
FIG. 4 is a schematic diagram of an apparatus for creating unique indexes and optimizing logical deletions provided herein;
fig. 5 is a schematic diagram of an electronic device corresponding to fig. 1 provided in the present specification.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present specification more apparent, the technical solutions of the present specification will be clearly and completely described below with reference to specific embodiments of the present specification and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present specification. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The following describes in detail the technical solutions provided by the embodiments of the present specification with reference to the accompanying drawings.
FIG. 1 is a flow chart of a method for creating unique indexes and optimizing logical deletions provided in the present specification, comprising the steps of:
s101: and acquiring a database operation statement and determining the type of the database operation statement.
As can be seen from the foregoing description, the core innovation point of a method for creating a unique index and optimizing logical deletion provided in the present specification is that, due to the diversity of logical deletion annotations, the unique index will not collide due to the same content, so in the present specification, the execution subject for implementing the method for creating a unique index and optimizing logical deletion may be a terminal device such as a desktop computer or a notebook computer used by an operator, and the following description is provided only by the terminal device as the execution subject of the method for creating a unique index and optimizing logical deletion provided in the present specification.
Firstly, the terminal device may acquire a database operation statement and determine a type to which the database operation statement belongs, where the database operation statement may be an SQL statement, and the type to which the database operation statement belongs may be any one of addition, deletion, modification, and query.
S102: and if the type is the unique index, acquiring the first data corresponding to the database operation statement, determining a logic deletion annotation corresponding to the first data, and adding a field corresponding to the logic deletion annotation to the unique index corresponding to the first data.
If the terminal device determines that the type to which the database operation statement belongs is creating the unique index, the terminal device obtains the first data corresponding to the database operation statement, determines a logical deletion annotation corresponding to the first data, and adds a field corresponding to the logical deletion annotation to the unique index corresponding to the first data, wherein the logical deletion can be implemented by modifying the corresponding logical deletion field, for example, the logical deletion field is defined as del_flag, the data type is set as big unsigned,0 indicates undeleted (default value), other values indicate deleted, and when the value of the logical deletion field is modified from 0 to other values, the terminal device represents logical deletion of the data corresponding to the logical deletion field. Note that, the logical delete annotation (e.g., @ logdelefield) may be used to identify a logical delete field, and set an attribute delVal to define the value of the logical delete field when data is logically deleted, support id, now, and NULL, respectively, indicating that the logical delete field value is set to the primary key id, the current timestamp (millisecond), and NULL.
In this specification, the attribute values of the logical delete annotations include: the update logical delete annotation is at least one of a field corresponding to the current primary key, a field corresponding to the update logical delete annotation is a current timestamp, and a field corresponding to the update logical delete annotation is NULL.
It should be noted that, each database table may have a corresponding entity object, where the entity object includes a logical deletion identifier that whether to logically delete the database table, so after the terminal device determines that the type to which the database operation statement belongs is that a unique index is created, it may first determine whether the entity class corresponding to the first data includes the logical deletion identifier, if so, it may determine a logical deletion annotation corresponding to the first data, and then may add a field corresponding to the logical deletion annotation to the unique index corresponding to the first data.
If it is determined that the logical delete identifier is not included, the database operation statement may be directly executed without adding the logical delete annotation to the unique index.
S103: and if the type is a deletion operation, updating a field corresponding to the logical deletion annotation of the first data according to the attribute value of the logical deletion annotation so as to logically delete the first data.
If the terminal device determines that the type to which the database operation statement belongs is a deletion operation, the field corresponding to the logical deletion annotation can be updated according to the attribute value of the logical deletion annotation so as to logically delete the first data.
Similarly, the terminal device may determine whether the entity class corresponding to the first data includes a logical deletion identifier after determining that the type to which the database operation statement belongs is a deletion operation. If the terminal equipment determines that the logical deletion identifier is included, it can be determined that the first data can be logically deleted, and the first data corresponding to the logical deletion annotation can be updated according to the logical deletion annotation so as to logically delete the first data. If the logical deletion identifier is not included, it is determined that the first data cannot be logically deleted, and then the database operation statement may be directly executed to implement physical deletion of the first data.
If the terminal device determines that the type of the database operation statement belongs to the modification operation or the query operation, the terminal device can judge whether the first data corresponding to the database operation statement contains the logic deletion annotation, and if the terminal device determines that the first data does not contain the logic deletion annotation, the terminal device can directly execute the corresponding database operation statement.
S104: and if the type is modification or inquiry, automatically searching the field corresponding to the logical deletion annotation as the first data which is not logically deleted according to the attribute value of the logical deletion annotation.
Similarly, the terminal device may also determine whether the entity class corresponding to the first data includes a logical deletion annotation after determining that the type to which the database operation statement belongs is a modification operation or a query operation, if it is determined that the logical deletion annotation is not included, the terminal device may directly execute the corresponding database operation statement, and if it is determined that the entity class corresponding to the first data does not include a logical deletion identifier, it is only necessary to directly perform the modification operation or the query operation without executing a subsequent operation.
The following describes a flow chart of a new operation provided for the present specification in connection with fig. 2:
in fig. 2, the terminal device may then parse the data TABLE from the ON and TABLE conditions in the SQL statement in response to creating the unique index, and scan to determine the attribute of the corresponding data entity object.
And then judging whether the attribute of the entity object contains the logic deletion identifier, if so, analyzing the field or the field combination of the unique index constraint from the SQL sentence, and if not, automatically adding the logic deletion annotation into the combined field of the unique index constraint to update and create the unique index SQL. If it is determined that the logical delete annotation is contained, creating the unique index SQL statement may be performed directly. If the logical deletion annotation is not included, the SQL statement creating the unique index may be directly executed.
A flowchart of a deletion operation provided for the present specification is described below with reference to fig. 3.
In fig. 3, in response to executing the deletion operation, the terminal device parses the data table FROM the FROM condition in the SQL statement, scans and determines the attribute of the data entity object, and then can determine whether the attribute of the entity object includes the logical deletion identifier, and if not, can directly execute the deletion of the SQL statement.
If the logical deletion mark is included, the logical deletion annotation of the data table can be obtained, the type of the logical deletion annotation is judged, and the logical deletion SQL statement is updated according to the type of the logical deletion annotation so as to execute the updated logical deletion SQL statement.
As can be seen from the above method, in the method for creating the unique index and optimizing the logical deletion provided in the present specification, the field constrained by the logical deletion annotation may be added to the unique index of the database data, so as to increase the diversity of the unique index, so that the unique index corresponding to the logically deleted data does not conflict with the unique index of the newly created data due to the same unique index, thereby solving the technical problem that the unique index conflicts after the logical deletion of the database table.
The method for creating the unique index and optimizing the logic deletion provided by one or more embodiments of the present specification further provides a corresponding device for creating the unique index and optimizing the logic deletion based on the same thought, as shown in fig. 4.
FIG. 4 is a schematic diagram of an apparatus for creating unique indexes and optimizing logical deletions provided in this specification, comprising:
an obtaining module 401, configured to obtain a database operation statement, and determine a type to which the database operation statement belongs;
a unique index creating module 402, configured to obtain first data corresponding to the database operation statement if the type is a new operation, determine a logical deletion annotation corresponding to the first data, and add the logical deletion annotation to a unique index corresponding to the first data;
a deletion module 403, configured to update, if the type is a deletion operation, first data corresponding to the logical deletion annotation according to the logical deletion annotation, so as to logically delete the first data;
and the modification and query module 404 is configured to automatically retrieve, according to the logical deletion annotation, the first data whose field corresponding to the logical deletion annotation is not logically deleted if the type is modification or query.
Optionally, the modifying and querying module 404 is specifically configured to determine whether the entity class corresponding to the first data includes the logical deletion identifier, and if it is determined that the entity class corresponding to the first data includes the logical deletion identifier, automatically retrieve, according to the logical deletion annotation, the first data whose field corresponding to the logical deletion annotation is not logically deleted.
Optionally, the unique index creating module 402 is specifically configured to obtain first data corresponding to the database operation statement if the type is a unique index; judging whether the entity class corresponding to the first data contains the logic deletion identifier, if so, determining a field corresponding to the logic deletion annotation corresponding to the first data, and adding the field corresponding to the logic deletion annotation to the unique index corresponding to the first data.
Optionally, the unique index creating module 402 is specifically configured to determine whether the entity class corresponding to the first data includes the logical deletion identifier, and if it is determined that the entity class does not include the logical deletion identifier, execute the database operation statement.
Optionally, the deletion module 403 is specifically configured to determine whether the entity class corresponding to the first data includes the logical deletion identifier if the type is a deletion operation; and if the logic deletion identifier is determined to be included, updating a field corresponding to the logic deletion annotation of the first data according to the attribute value of the logic deletion annotation so as to logically delete the first data.
Optionally, the deletion module 403 is specifically configured to determine whether the entity class corresponding to the first data includes the logical deletion identifier, and if it is determined that the logical deletion identifier is not included, execute the database operation statement to implement physical deletion of the first data.
Optionally, the logical delete annotation attribute value includes: updating the logical delete annotation to be at least one of a field corresponding to a current primary key, updating the logical delete annotation to be a field corresponding to a current timestamp, and updating the field corresponding to the logical delete annotation to be NULL.
The present specification also provides a computer readable storage medium having stored thereon a computer program operable to perform a method of creating a unique index and optimizing logical deletion as provided in fig. 1 above.
The present specification also provides a schematic structural diagram of an electronic device corresponding to fig. 1 shown in fig. 5. At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile storage, as illustrated in fig. 5, although other hardware required by other services may be included. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs to implement the method of creating the unique index and optimizing the logical delete described above with respect to fig. 1. Of course, other implementations, such as logic devices or combinations of hardware and software, are not excluded from the present description, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or logic devices.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Controler, PLC) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A digital system is "integrated" on a PLC by the designer's own programming without requiring the chip manufacturer to design and fabricate application specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), lava, lola, myHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present specification.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present description is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present disclosure and is not intended to limit the disclosure. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description.

Claims (10)

1. A method of creating a unique index and optimizing logical deletions, comprising:
acquiring a database operation statement and determining the type of the database operation statement;
if the type is the unique index, acquiring first data corresponding to the database operation statement, determining a logic deletion annotation corresponding to the first data, and adding a field corresponding to the logic deletion annotation to the unique index corresponding to the first data;
if the type is a deletion operation, updating a field corresponding to the logical deletion annotation of the first data according to the attribute value of the logical deletion annotation so as to logically delete the first data;
and if the type is modification or inquiry, automatically searching the field corresponding to the logical deletion annotation as the first data which is not logically deleted according to the attribute value of the logical deletion annotation.
2. The method according to claim 1, wherein if the type is a modification or a query, automatically retrieving, according to the logical deletion annotation, the first data whose field corresponding to the logical deletion annotation is not logically deleted, includes:
and judging whether the entity class corresponding to the first data contains the logic deletion identifier or not, and if so, automatically searching the field corresponding to the logic deletion annotation as the first data which is not deleted by logic according to the logic deletion annotation.
3. The method according to claim 1, wherein if the type is a unique index created, acquiring the first data corresponding to the database operation statement, determining a logical deletion annotation corresponding to the first data, and adding a field corresponding to the logical deletion annotation to the unique index corresponding to the first data, specifically including:
if the type is a unique index, acquiring first data corresponding to the database operation statement;
judging whether the entity class corresponding to the first data contains the logic deletion identifier, if so, determining a field corresponding to the logic deletion annotation corresponding to the first data, and adding the field corresponding to the logic deletion annotation to the unique index corresponding to the first data.
4. The method of claim 3, wherein determining whether the entity class corresponding to the first data includes the logical deletion identifier specifically includes:
and judging whether the entity class corresponding to the first data contains the logic deletion identifier or not, and executing the database operation statement if the entity class does not contain the logic deletion identifier.
5. The method according to claim 1, wherein if the type is a delete operation, updating a field corresponding to the logical delete annotation of the first data according to the attribute value of the logical delete annotation to logically delete the first data, specifically comprising:
if the type is a deletion operation, judging whether the entity class corresponding to the first data contains the logic deletion identifier or not;
and if the logic deletion identifier is determined to be included, updating a field corresponding to the logic deletion annotation of the first data according to the attribute value of the logic deletion annotation so as to logically delete the first data.
6. The method of claim 5, wherein determining whether the entity class corresponding to the first data includes the logical deletion identifier specifically includes:
judging whether the entity class corresponding to the first data contains the logic deletion identifier, and executing the database operation statement if the entity class corresponding to the first data does not contain the logic deletion identifier, so as to realize the physical deletion of the first data.
7. The method of claim 1, wherein the logically deleting the annotated attribute value comprises: updating the logical delete annotation to be at least one of a field corresponding to a current primary key, updating the logical delete annotation to be a field corresponding to a current timestamp, and updating the field corresponding to the logical delete annotation to be NULL.
8. An apparatus for creating unique indexes and optimizing logical deletions, comprising:
the acquisition module is used for acquiring the database operation statement and determining the type of the database operation statement;
the unique index creating module is used for acquiring first data corresponding to the database operation statement, determining a logical deletion annotation corresponding to the first data and adding a field corresponding to the logical deletion annotation to the unique index corresponding to the first data if the type is the unique index;
the deleting module is used for updating a field corresponding to the logical deletion annotation of the first data according to the attribute value of the logical deletion annotation if the type is a deleting operation so as to logically delete the first data;
and the modification and query module is used for automatically searching the first data which is not logically deleted in the field corresponding to the logical deletion annotation according to the attribute value of the logical deletion annotation if the type is modification or query.
9. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1-7.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1-7 when executing the program.
CN202310075206.XA 2023-02-07 2023-02-07 Method and device for creating unique index and optimizing logic deletion Pending CN116010419A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310075206.XA CN116010419A (en) 2023-02-07 2023-02-07 Method and device for creating unique index and optimizing logic deletion

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310075206.XA CN116010419A (en) 2023-02-07 2023-02-07 Method and device for creating unique index and optimizing logic deletion

Publications (1)

Publication Number Publication Date
CN116010419A true CN116010419A (en) 2023-04-25

Family

ID=86021094

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310075206.XA Pending CN116010419A (en) 2023-02-07 2023-02-07 Method and device for creating unique index and optimizing logic deletion

Country Status (1)

Country Link
CN (1) CN116010419A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117827802A (en) * 2024-01-11 2024-04-05 江苏金融租赁股份有限公司 Hbase-based data processing system, method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473296A (en) * 2013-09-04 2013-12-25 国云科技股份有限公司 Recycle bin mechanism and recycle bin system applicable to cloud computing
CN104821876A (en) * 2015-04-16 2015-08-05 华中科技大学 Dynamic searchable symmetrical encryption method supporting physical deletion
CN107111628A (en) * 2014-10-31 2017-08-29 微软技术许可有限责任公司 Effective maintenance of row repository index on memory optimization table
CN108563694A (en) * 2018-03-19 2018-09-21 广州视源电子科技股份有限公司 Method, apparatus, computer equipment and storage medium are executed to the SQL that logic is deleted
CN109144994A (en) * 2017-06-19 2019-01-04 华为技术有限公司 Index updating method, system and relevant apparatus

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473296A (en) * 2013-09-04 2013-12-25 国云科技股份有限公司 Recycle bin mechanism and recycle bin system applicable to cloud computing
CN107111628A (en) * 2014-10-31 2017-08-29 微软技术许可有限责任公司 Effective maintenance of row repository index on memory optimization table
CN104821876A (en) * 2015-04-16 2015-08-05 华中科技大学 Dynamic searchable symmetrical encryption method supporting physical deletion
CN109144994A (en) * 2017-06-19 2019-01-04 华为技术有限公司 Index updating method, system and relevant apparatus
CN108563694A (en) * 2018-03-19 2018-09-21 广州视源电子科技股份有限公司 Method, apparatus, computer equipment and storage medium are executed to the SQL that logic is deleted

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
YXXYX: "唯一性索引与逻辑删除冲突问题解决思路", pages 1 - 2, Retrieved from the Internet <URL:https://blog.csdn.net/YXXXYX/article/details/125546093> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117827802A (en) * 2024-01-11 2024-04-05 江苏金融租赁股份有限公司 Hbase-based data processing system, method and device
CN117827802B (en) * 2024-01-11 2024-05-28 江苏金融租赁股份有限公司 Hbase-based data processing system, method and device

Similar Documents

Publication Publication Date Title
CN107526777B (en) Method and equipment for processing file based on version number
CN108848244B (en) Page display method and device
CN107391101B (en) Information processing method and device
CN111581230B (en) Method, equipment and medium for generating data analysis report
CN107622080B (en) Data processing method and equipment
CN110399359B (en) Data backtracking method, device and equipment
CN111400681B (en) Data authority processing method, device and equipment
CN115756449B (en) Page multiplexing method and device, storage medium and electronic equipment
CN115374117A (en) Data processing method and device, readable storage medium and electronic equipment
CN116010419A (en) Method and device for creating unique index and optimizing logic deletion
CN115617799A (en) Data storage method, device, equipment and storage medium
CN116521705A (en) Data query method and device, storage medium and electronic equipment
CN116432185B (en) Abnormality detection method and device, readable storage medium and electronic equipment
CN115878654A (en) Data query method, device, equipment and storage medium
CN115391426A (en) Data query method and device, storage medium and electronic equipment
CN115390852A (en) Method and device for generating uniform abstract syntax tree and program analysis
CN111339117B (en) Data processing method, device and equipment
CN116644090B (en) Data query method, device, equipment and medium
CN117349401B (en) Metadata storage method, device, medium and equipment for unstructured data
CN115587107A (en) Data updating method, device, storage medium and equipment
CN112434486B (en) Automatic paging method, device, equipment and medium for device in PCB design
CN117041980B (en) Network element management method and device, storage medium and electronic equipment
CN117033420B (en) Visual display method and device for entity data under same concept of knowledge graph
CN117591625B (en) Data storage method and device, storage medium and electronic equipment
US20240143298A1 (en) Data processing methods and apparatuses, devices, and storage mediums

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