Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite deleted data stays in database binary file

I deleted data from SQLite database table. If you open the database file in any SQL manager (e.g SQLiteStudio) deleted data is not present, but if you open database file in a text editor (e.g notepad++) deleted data is visible. Therefore there's a chance of restoring data, etc.

Example:

In the first picture SQLiteStudio is showing that deleted customer "Stan" is not seen. But binary file opened in Notepad++ shows customer "Stan".

Does anybody know how to make deleted data disappear from SQLite binary files?

SQLiteStudio showing that deleted customer "Stan" is not seen

Binary file open in Notepad++ shows customer "Stan"

like image 527
stanislavr Avatar asked Jul 04 '26 10:07

stanislavr


1 Answers

To prevent this, execute PRAGMA secure_delete = ON:

When secure_delete is on, SQLite overwrites deleted content with zeros. The default setting for secure_delete is determined by the SQLITE_SECURE_DELETE compile-time option and is normally off. The off setting for secure_delete improves performance by reducing the amount of disk I/O. Applications that wish to avoid leaving forensic traces after content is deleted or updated should enable the secure_delete pragma prior to performing the delete or update, or else run VACUUM after the delete or update.

like image 134
CL. Avatar answered Jul 07 '26 06:07

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!