We report the results of a comprehensive study of charge density wave (CDW) correlations in untwinned YBa2Cu3O6+x single crystals with 0.4 ≤ x ≤ 0.99 using Cu-L3 edge resonant x-ray scattering (RXS). Evidence of CDW formation is found for 0.45 ≤ x ≤ 0.93 (hole doping levels 0.086 p 0.163), but not for samples with x ≤ 0.44 (p 0.084) that exhibit incommensurate spin-density-wave order, and in slightly overdoped samples with x = 0.99 (p ∼ 0.19). This suggests the presence of two proximate zero-temperature CDW critical points at pc1 ∼ 0.08 and pc2 ∼ 0.18. Remarkably, pc2 is close to the doping level that is optimal for superconductivity. The CDW reflections are observed at incommensurate in-plane wave vectors (δa, 0) and (0, δ b ) with δa δ b . Both δa and δ b decrease linearly with increasing doping, in agreement with recent reports on Bibased high-Tc superconductors, but in sharp contrast to the behavior of the La2−x(Ba,Sr)xCuO4 family. The CDW intensity and correlation length exhibit maxima at p ∼ 0.12, coincident with a plateau in the superconducting transition temperature Tc. The onset temperature of the CDW reflections depends non-monotonically on p, with a maximum of ∼ 160 K for p ∼ 0.12. The RXS reflections exhibit a uniaxial intensity anisotropy. Whereas in strongly underdoped samples the reflections at (δa, 0) are much weaker than those at (0, δ b ), the anisotropy is minimal for p ∼ 0.12, and reversed close to optimal doping. We further observe a depression of CDW correlations upon cooling below Tc, and (for samples with p ≥ 0.09) an enhancement of the signal when an external magnetic field up to 6 T is applied in the superconducting state. For samples with p ∼ 0.08, where prior work has revealed a field-enhancement of incommensurate magnetic order, the RXS signal is field-independent. This supports a previously suggested scenario in which incommensurate charge and spin orders compete against each other, in addition to individually competing against superconductivity (Blanco-Canosa et al., Phys. Rev. Lett. 110, 187001 (2013)). We discuss the relationship of these results to prior observations of "stripe" order in La2−x(Ba,Sr)xCuO4, the "pseudogap" phenomenon, superconducting fluctuations, and quantum oscillations, as well as their implications for the mechanism of high-temperature superconductivity.