Can of course depend on the airport, time of day and how busy immigration is. Generally people advise allow 2-3 hours between connections to complete immigration formalities, could be less of course and often is. Which airport , time of day and a connection to where ?
As for moving to another flight that will depend on the airline, some will some will not plus of course that assumes another flight same day which a whole different scenario for overnight accomodation.