Switching App Store Accounts in iOS

I’m one of those folks who has multiple Apple IDs due to historical accident. My music and iOS apps have been purchased under an old (mac.com) ID with no associated email or iCloud account.

I’ve set up family sharing under my real/current Apple ID, and would like to use that going forward.

My question: if I have free apps, or apps with paid accounts purchased outside of iOS, what happens if I change my App Store to a different Apple ID and then “get” (or even purchase) an app I already have on my device purchased under another Apple ID.

Most importantly: do I lose my data and local settings, as if I had deleted and redownloaded the app? Or is that preserved, and I just end up with the app updatable via the new Apple ID rather than the old one?

Anyone tried this?