The invention provides compounds for inhibiting glycosidases, prodrugs of the compounds, and pharmaceutical compositions including the compounds or prodrugs of the compounds. The invention also provides methods of treating diseases and disorders related to deficiency or overexpression of O-GlcNAcase, accumulation or deficiency of O-GlcNAc.