Sum rule relations over the excitation spectrum of a quantum system contain information about both the energy spectrum and eigenfunctions of the system in a compact form, particularly regarding closure relations. In this work, the effects of pressure induced by a spherical cavity on an atomic hydrogen impurity on the dipole oscillator strength (DOS) sum rule, Sk, and its logarithmic version, Lk, are studied by means of a numerical approach based on a finite-difference solution to the Schrödinger equation. Pressure effects are accounted for by means of a spherical cavity of radius R0 immersed in a medium characterized by a penetrable potential height V0. The DOS sum rules Sk and Lk are investigated as a function of these cavity parameters and thus directly related to the impurity static pressure and surrounding material. One finds that the sum rules are fulfilled within the numerical precision for low pressure conditions. However, when the barrier height is large or infinite (a non-penetrable cavity), the sum rule, for positive k, differs from its closure relation. One finds that this occurs for a cavity radius au, corresponding to a pressure such that the first p-state that contributes to the sum rule has positive energy and it is due to the fact that the spherical confinement cavity potential dominates over the Coulombic interaction for the hydrogenic impurity. Thus, as pressure increases, the excitation spectrum approaches that of a particle confined by a spherical cavity while the ground state is slightly affected by the cavity and more closely resembles a hydrogenic atom. Therefore, the sum rule over the excitation spectrum tends to a particle confined by a spherical cavity, while the closure relation gives that of a confined hydrogen atom in the ground state. For negative k, low excitations are the most important and this behavior is not presented. As the sum rule is the static dipole polarizability, the results are compared to available data in the literature, showing excellent agreement. This behavior in the sum rule and oscillator strength in electron–impurity excitations affects optical transitions of importance in semiconductor nanostructures.