When I delete notes from Notes.app, I expect them to be deleted. However, it's clear that iCloud is storing lots of old, deleted, confidential information, and I don't know how to get rid of it.
I can access the Notes.app database on my Mac (10.12), dump the contents, and then inspect the SQL dump with an editor:
$ cd ~/Library/Containers/com.apple.Notes/Data/Library/Notes $ sqlite3 NotesV6.storedata SQLite version 3.16.0 2016-11-04 19:09:39 Enter ".help" for usage hints. sqlite> .output /tmp/dump.sql sqlite> .dump sqlite> .exit
Sure enough, the SQL dump has lots of sensitive notes:
... INSERT INTO "ZNOTEBODY" VALUES(472,15,2,271,13,'<html><head></head><body>secret notes<div><br></div><div>[REDACTED]</div></body></html>'); ...
It appears that these notes have a reference to a parent folder that no longer exists.
If I try to blank out these notes, they come back with the next iCloud sync:
sqlite> update znotebody set zhtmlstring = '' where z_pk = 472;
If I sign out of iCloud, the notes disappear, but they reappear in the database when I sign back in.
How can I delete these notes permanently?