Electron-beam-induced current (EBIC) and cathodoluminescence (CL) have been applied to investigate the electrical and optical behaviors of dislocations in SrTiO3. The electrical recombination activity and defect energy levels of dislocations have been deduced from the temperature-dependent EBIC measurement. Dislocations contributed to resistive switching were clarified by bias-dependent EBIC. The distribution of oxygen vacancies around dislocations has been obtained by CL mapping. The correlation between switching, dislocation and oxygen vacancies was discussed.