Comprehensive study of the resistance switching in SrTiO3 and Nb-doped SrTiO3