Replace attachment file URL with another on specific attachment

I want to upload my images on another server and create an attachment post row in wp_posts table with external URL, but WordPress create permalinks automatically with site base URL. how can i update this URL for a specific attachment?

How can I replace attachment file URL with unique URL;

For example I have an URL like this: ‘’;

I want to replace this URL with ‘’;

Any solutions?