Continuity equation and pressure head in a tank Consider a tank which is full of water. We connect a horozontal pipe at its bottom. When the pipe is open, water starts flowing through the pipe, then the velocity of water is proportional to the pressure head. 
In this condition the tank is at a certain level from the ground. So total head is the sum of pressure head and datum head. I think the velocity is equal to $\sqrt{2g\cdot\text{pressure head}}$. But now I extend the pipe length:
Please consider the horizontal pipe is of $2\ \mathrm{m}$ length in the first case. From there I connect a vertical pipe which has a length equal to datum head. So the pipe is now at the ground level. When I open the pipe, water starts flowing. But now the velocity is equal to $\sqrt{2g\cdot\text{pressure head}}$, isn't it? 
In the second case the pipe is of same diameter, but when we use the continuity equation to find the velocity, is it possible to get the same velocity for the first $2\ \mathrm{m}$ segment and at the end of vertical segment? I think for the first $2\ \mathrm{m}$ segment, the pressure head is the water height. Then for the vertical segment the pressure head is equal to pressure head + datum head.
 A: The values you cited could be considered first approximations, valid for the ideal case of inviscid liquids.  In actual practice, there will be energy loses, due to the viscosity of the water, which would decrease the flow.  To reduce the loses, hydraulic engineers use bellmouth fittings, smooth pipes, long radius bends, etc.
To predict the flow velocity more accurately, engineers use a modified Bernoulli equation.
$$\frac{P_1}{\rho}+\frac{1}{2}V_1^2+g z_1 = 
\frac{P_2}{\rho}+\frac{1}{2}V_2^2+g z_2+h_L
$$
The modification is the "head loss" term, $h_L$.  
Case 1 - no pipe attached at tank outlet
Take the first point to be at the top of the water in the tank.  The pressure $P_1$ can be taken as zero and the velocity $V_1$ will be zero if the tank is large enough to maintain a steady flow.  The elevation $z_1$ is the height above your datum.  The second point can be in the free stream of water coming from the tank.  The pressure $P_2$ can be taken as equal to $P_1$, since the point is not inside the pipe.  The elevation $z_2$ is the height of stream above the datum.  If we ignore the head loss, we get your expression, $v=\sqrt{2g(z_1-z_2)}$.  
The Bernoulli equation expresses the conservation of energy.  However, as the layers of water slip past each other trying to get through the outlet, the slippage causes friction-like energy losses.  To account for losses, engineers add the head loss term to the Bernoulli equation.
Engineers express the loss term as a value "K" times the velocity head $V^2/2$.  The numeric value of "K" could range from about 0.5 for a plain entrance to 0.04 for a smooth bellmouth.  As a worst case, with $K=0.5$, the flow velocity would be $v=\sqrt{g(z_1-z_2)}$, which is about 70% of the value we got when we ignored the losses.  With a bellmouth entrance, the flow velocity could be greater than 96% of the value without any energy loss.
Case 2 -- horizontal pipe attached to tank outlet
The pipe connected to tank outlet will introduce more losses.  The inside surface holds back the layer of water that is closest to it, so the next layer must slip past the outer layer, with leads to friction-like losses.  These losses will depend on the length, the diameter and the roughness of the pipe.  When the velocity is high enough, the flow will become fully turbulent
Engineers calculate the energy loss due to pipe friction based on the Darcy-Weisbach equation and the Moody diagram.  Piping flow capacity charts are based on industry standards and recommended practice.  They are not predictions of how much flow you will actually see.
Case 3 -- pipe extended in the vertical direction
If the pipe is then extended in the vertical direction to a lower elevation, $z_3$, the flow velocity may actually increase.  The ideal loss-free flow velocity would be $v_3=\sqrt{2g(z_1-z_3)}$, but the entrance loss and the pipe friction will prevent the flow from reaching that velocity.
Another loss that must be considered occurs when the flow goes through the bend or elbow between the horizontal pipe and the vertical pipe.  These losses may be due to the formation of vortexes. Again, for calculation purposes, the head loss is usually characterized by a "K" value.  A typical value would be 0.25 to 0.50, similar to the most severe entrance loss.  
If the pipeline contains other fittings or valves, there will be additional losses.  The magnitude of the losses will depend on the geometry of the fitting or valve.  Even though there are more losses to consider in the vertical section, the change in elevation from $z_2$ down to $z_3$ could still result in an overall increased flow velocity.
To further complicate matters, if the vertical pipe simply terminates without any restriction at the end, the pipe may not be flowing full.  That is, the water may be falling faster than it is flowing, which would invalidate the head loss calculations.  For this reason, it would be wise to put a valve and/or some kind of nozzle at the end of the pipe, and a vent at the top to bleed off any trapped air.
