To complement the answer provided by @Ian Fang and edited by @santiago, sodium hydride's action as a Brønsted base differs from other bases.
"Normal" acid base reactions are reactions of an equilibrium, like the partial deprotonation of malonic esters by 5 m% sodium carbonate in some Knoevenagel reactions:
$\ce{R-H} + \mbox{base} \rightleftharpoons{} \ce{R-} + \mbox{protonated base}$
Deploying sodium hydride as base however often intends a quantitative deprotonation. The equilibrium is driven to the right hand side, in favour of the protonated base ($\ce{H2}$) immediately leaving the reaction mixture -- so the back reaction can't take place.