当前位置:网站首页>Use soft delete to delete data in database

Use soft delete to delete data in database

2020-11-10 11:27:00 Oc ct0tt1c

One . Soft delete ( Logical deletion ):(Soft Deleting), That is, when the data in the data table is deleted , It is not removed directly from the data table , It's marked as deleted , That is to set a delete field in each table ( Such as :IsDeleted) etc. , By default, the value is 0, And undeleted state ; When you need to delete data , Update this field to 1.

In reality , What we mean by deletion is not really deletion , Often we delete some data in the database after , It's hard to recover , In this way, it will be more convenient to use soft deletion to check again .

for example :

  • company “ fire ” An employee , Instead of deleting employees ;
  • company “ Cancel ” The order , Instead of deleting the order ;
  • company “ Discontinue use ” A device , Instead of deleting a device ;

Here we're going to use dismissal , Cancel , Stop using instead of “ Delete ”;

When you want to see the data status again , As long as IsDeleted To change the value of 0 that will do .

Two . Hard delete ( Physical delete ): Really delete data from the database , The data disappears .

 

版权声明
本文为[Oc ct0tt1c]所创,转载请带上原文链接,感谢