The pike can be used for both defensive and offensive manoeuvres, but it was generally only useful defensively against enemy cavalry when the enemy obligingly charged straight onto the damn things - chivalry at its finest

. The Swiss and the Landsknechts used it mainly offensively - well disciplined and trained pike charges could roll right over enemy infantry.
The main difficulty with cavalry was that the enemy cavalry frequently out-ranged the pikemen and so wouldn't attack the pikes - and pike squares had serious problems turning. Unless there were friendly cavalry protecting their flanks they tended to get hit from the side. They could be used defensively but not on their own, and they were much more useful during the period of their dominance attacking and rolling over the enemy.
Also, don't mistake me for some weapons expert

, I have access to Wikipedia and I'm not afraid to use it

.