Programmable optoelectronic devices calls for the reversible control of photo-carrier recombination process by in-gap states in emergent oxide semiconductors. However, previous approaches to produce oxygen vacancies as a source of in-gap states in oxide semiconductors have hampered the reversible formation of oxygen vacancies and their related phenomena. Here, a new strategy to manipulate the two-dimensional photoconductivity from perovskite stannates is demonstrated by exploiting spatially-selective photochemical reaction under ultraviolet illumination at room temperature. Remarkably, the ideal trap-free photocurrent of air-illuminated BaSnO3 (∼ 200 pA) is reversibly switched into three orders of magnitude higher photocurrent of vacuum-illuminated BaSnO3 (∼ 335 nA) with persistent photoconductivity depending on ambient oxygen pressure under illumination. Multiple theoretical and experimental characterizations elucidate that ultraviolet illumination of BaSnO3 under low oxygen pressure induces surface oxygen vacancies as a result of surface photolysis combined with the low oxygen-diffusion coefficient of BaSnO3 ; the concentrated oxygen vacancies are likely to induce a two-step transition of photocurrent response by changing the characteristics of in-gap states from shallow level to deep level. These original results suggest a novel strategy that uses light-matter interaction in a reversible and spatially-confined way to manipulate functionalities related to surface defect states, for the emerging applications using newly discovered oxide semiconductors. This article is protected by copyright. All rights reserved.