It is not clear from your question whether the gas in the bottle starts out as air, or the only substance in the bottle is water, either in liquid or gas form. I'll assume the latter since it's easier to answer.
Once the bottle is closed, ambient temperature doesn't matter. The pressure of the gas part in the bottle will be stricly a function of temperature, with that function being solely a property of water. You can find what that function is in what is commonly referred to as a steam table.
As you heat the bottle, and presumably everything inside gets to the same temperature, the vapor pressure increases. This causes a little more of the liquid to boil and thereby make less liquid and more gas. Eventually for any one temperature, a new equilibrium is reached where the gas is at the pressure listed in the steam table for that temperature.
If you let the system reach equillibrium at 200°C, for example, then open a valve at the bottom, water at the bottom will be forced out under pressure. As the volume of water in the bottle decreases, the volume available to the gas increases, which decreases its pressure. The liquid that was at equillibrium now no longer is, since its pressure is reduced but its temperature (for the short term) remains the same. This will cause the liquid to boil and make more gas. This cools the liquid, and if done slowly enough the liquid will track the ever decreasing boiling temperature for the ever decreasing pressure.
Meanwhile, the gas is expanding, so it will cool. It won't condense because there is no place for the heat to go. We are making the assumption that the bottle is insulated at this point. Boiling liquid will keep the gas "topped off" at whatever temperature it is according to the steam table.
Once all the liquid is gone, the steam will still be at pressure above ambient. If the valve stays open, the steam will vent until its pressure is the same as ambient. If the bottle is truly insulated, nothing more should happen. If heat is lost thru the bottle, then the temperature will decrease and the pressure of the steam decrease, again according to the steam table. Outside air is then sucked into the bottle. If this air is at 20°C, for example, it will significantly cool the steam, which will cause much of it to condense, which creates lower pressure, which sucks in even more cool air, etc. The proceeds until most of the water is condensed to liquid, with the only remaining water gas being whatever maximum partial pressure of water that air at that temperature and pressure can support.
If the valve is opened so that the 200°C water is expelled "quickly", then it gets a lot more complicated because there is not enough time for the system to track equillibrium as pressure is abruptly release. In that case, I think all we can say is that a bunch of super-heated water will be violently released and quickly undergo decompression, which will cause some of it to boil quickly, making a lot of steam, with the left over liquid being at boiling temperature for ambient pressure, which would be 100°C. After the water is gone from the bottle, a rush of steam will come out, condensing in the (relatively) cold ambient air and adding to the already large saturated water vapor cloud. Once enough steam is expelled so that ambient pressure is reached the remaining steam acts as above.
Shaking the soda bottle makes the dissolved gas escape the liquid. As long as the lid is on, this can't happen (or happens for a little bit and then stops): the air in the bottle is already saturated with gas.
Then you poke a hole in the bottle, below the surface. The liquid may come out, reducing its volume in the bottle, thus expanding the volume of the air inside the bottle. In a non-fizzy beverage, the expanding air reduces its pressure and "sucks the liquids back in", as equilibrium is established. No liquid flows out of the hole.
In a fizzy beverage, the expansion of the air volume makes it so that it isn't saturated anymore; the gas solved in the liquid can move out of the solution; the air in the bottle thus is both expanding and gaining particles. As long as these two factors balance each other, the air can expand without dropping in pressure, allowing the liquid to flow out. When the separation of the gas from the solution can't supply a number of molecules large enough to keep the pressure constant, we would fall back into the "non-fizzy beverage" case, stopping the flow.
Best Answer
I cannot see, above, the correct answer to the first part of the question. They all have the second part right.
The first part: Why does shaking the bottle make it fizz when you open it? The gas is in solution in the closed, unshaken bottle. The solubility of that gas in that liquid at that temperature and that pressure dictates the saturation level of the gas in the liquid. Any more gas than that and it bubbles out, increasing the pressure inside the closed bottle and forcing more gas in solution thus reducing the pressure. An equilibrium is reached.
But why does shaking cause a problem? Because when you shake it, you slosh the contents around. The liquid flows quickly from one end of the container to the other. As it does so, it flows fast enough to become turbulent. In the turbulence, the curlicues, the intricacies, the eddies and the complex flow there are many locations in the liquid where the local pressure is forced lower than the saturation pressure. This is because any packet of liquid that is accelerating in any direction will leave a low pressure zone in its wake.
When the pressure is forced below the equilibrium level, the gas (given sufficient nucleating seeds) will come of of solution instantly given that the operation is occurring in the bulk and gas bubbles can be created anywhere in 3D.
But when the gas wants to go back into solution it is severely limited by the relatively small surface area of the liquid in the neck of the bottle. There is only a tiny surface available for gas transport through the liquid/air interface. We are severely dissolution rate limited. It can take hours for a shaken can to quiet down. It can be hastened by chilling as more gas can always be dissolved in a cooler liquid.