The invention provides compounds of formula (I) with substituents as specified in Claim 1 for selectively inhibiting glycosidases, prodrugs of the compounds, and pharmaceuticals compositions including the compounds or prodrugs of the compounds. The invention also provides methods of treating diseases and disorders related to over-expression of O-GlcNAcase or accumulation of O-GlcNac.