I have 30,000 photos presently on my iPhone
I just ran out of space
See -> Connect external storage devices to iPhone
Connect external storage devices to iPhone – Apple Support (UK)
If the iPhone has an Apple Lightnng connection port, you can use a SanDisk iXpand flash drive to use as an external hard drive. They are available in various sizes.
You can also use that iXpand flash drive as a tool to save the photos to a real external hard drive afterwards.
iXpand Flash Drive are available at Apple Store and at Apple Authorized Service Providers.
iXpand flash drive app can be downloaded from the App Store.
See -> SanDisk iXpand-flashdrive Go
SanDisk 64 GB iXpand Flash Drive Go - Apple
Then download the SanDisk iXpand Drive app from the App Store, see ->
https://apps.apple.com/us/app/sandisk-ixpand-drive/id1079870681
but if I delete pictures from PHOTOS will they remain in the SHARED ALBUMS?
No, the photos in the Shared albums that's a quick link form your photos in Photos.
See also -> What's the difference between device storage and iCloud storage?
What's the difference between device storage and iCloud storage? - Apple Support
If you turn iCloud On, you get 5 GB iCloud free storage.
Do you need more, see this Apple article: Upgrade to iCloud+
Upgrade to iCloud+ - Apple Support
See also: iCloud+ plans and pricing
iCloud+ plans and pricing - Apple Support