Context. Meter-wavelength type II solar radio bursts are thought to be the signatures of shock-accelerated electrons in the corona. Studying these bursts can give information about the initial kinematics, dynamics, and energetics of coronal mass ejections (CMEs) in the absence of white-light observations. Aims. We investigate the occurrence of type II bursts in solar cycles 23 and 24 and their association with CMEs. We also explore whether type II bursts might occur in the absence of a CME. Methods. We performed a statistical analysis of type II bursts that occurred between 200 and 25 MHz in solar cycles 23 and 24 and determined the temporal association of these radio bursts with CMEs. We categorized the CMEs based on their linear speed and angular width and studied the distribution of type II bursts with fast (≥500 km s−1), slow (< 500 km s−1), wide (≥60°), and narrow (< 60°) CMEs. We explored the dependence of type II bursts occurrence on the phases of the solar cycle. Results. Our analysis shows that during solar cycles 23 and 24, 768 and 435 type II bursts occurred, respectively. Of these, 79% were associated with CMEs in solar cycle 23, and 95% were associated with CMEs in solar cycle 24. However, only 4% and 3% of the total number of CMEs were accompanied by type II bursts in solar cycle 23 and 24, respectively. Most of the type II bursts in both cycles were related to fast and wide CMEs (48%). We also determined the typical drift rate and duration for type II bursts, which is 0.06 MHz s−1 and 9 min. Our results suggest that type II bursts dominate at heights ≈1.7 − 2.3 ± 0.3 R⊙. A clear majority have an onset height around 1.7 ± 0.3 R⊙ assuming the four-fold Newkirk model. Conclusions. The results indicate that most of the type II bursts had a white-light CME counterpart, but a few type II bursts lacked a clear CME association. There were more CMEs in cycle 24 than in cycle 23. However, cycle 24 contained fewer type II radio bursts than cycle 23. The onset heights of type II bursts and their association with wide CMEs reported in this study indicate that the early lateral expansion of CMEs may play a key role in the generation of these radio bursts.