Posts

Showing posts with the label delete

Soft Delete

 Many applications are using soft delete approach, So many applications implement a "soft delete" instead. This adds an "is deleted" flag to your tables. For example: alter table toys add is_deleted varchar2( 1 ) default 'N' ; When adding new rows, ensure this value is N (No): delete toys; insert into toys values ( 'Baby Turtle' , 0.01 , 'N' ); insert into toys values ( 'Miss Snuggles' , 0.51 , 'N' ); insert into toys values ( 'Cuteasaurus' , 10.01 , 'N' ); insert into toys values ( 'Sir Stripypants' , 14.03 , 'N' ); insert into toys values ( 'Purple Ninja' , 14.22 , 'N' ); select * from toys; commit ; Now, to "delete" rows, you run an update. This sets the deleted flag to Yes: update toys set is_deleted = 'Y' where toy_name = 'Cuteasaurus' ; select * from toys; But now you need to filter out the "deleted...