The US navy GOAL for a railgun in active service on many ships was, back in 2000s, a weapon fired at 2500 m/s, (mach 7.3 at sea level) reaching 200 miles (don't know if nautical or statute miles) and hitting the target at velocity of mach 5.
Current developmental gun that is testing is firing stuff at 2000 m/s and "long range tests" will be done at 100 miles. It's unclear whether added range is possible, it's unclear how similar the developmental gun is to possible future active service guns.
Range is very much subject to trajectory and controls as well. For example, lots of modern extended range shells achieve their added range by using their control surfaces to glide. It adds range but at the same time it slows the round down so terminal velocity is smaller. We don't know if the 200 mile range expectation was modeled with a gliding trajectory, for example.
Intercepting a mach 3 object coming in is something ESSM missile was pretty much designed to do. Intercepting a mach 5 object may be outside it's comfort zone. There's SM-3 for objects of such speed. That being said, SM-3s are likely not going to be featured on any ship in numbers above a dozen or so.
All that being said, I'd say rail guns today aren't going much over 200 km (not miles) and rail guns of the next decade or two are not going over 300-ish km. And their anti-ship rounds, if such rounds will happen, will very necessarily have to be self guided. And will easily cost a significant portion of the cost of an antiship missile. They will be readily tracked from afar by enemy radars. And interceptor weapons will most likely be able to deal with them in a cost efficient manner.
Anti-ship rail gun round would be suited against smaller ships, like corvettes and such, and various support and special mission ships. It will still be somewhat cheaper than a missile, and it'd be much smaller, so more of them could be carried by the ship.
the main role of a main deck gun on ships, when the railgun switch happens, will remain the same as it was for last few decades.
Shore bombardment, "cheap" engagement of lightly defended ships, and aid in the missile defense role.
Railguns are not going to bring a revolution in that regard, but a siginificant evolution.