Photoinduced second harmonic generation in Y–Ba–Cu–O ceramics was investigated. An analysis of the observed effect was performed based on quantum chemical modeling taking account of electron–phonon anharmonic interactions. Using band energy structure, calculations we have revealed a correlation between photoinduced electron charge density redistribution within the Cu–O octahedra of the Y–Ba–Cu–O ceramic and appropriate second-order nonlinear optical susceptibilities. Other structural fragments play only a minor role in the observed photostructural changes. The possibility of using the photoinduced optical second harmonic generation for detection of superconducting phase transition is demonstrated.