We report the results a comprehensive study of charge density wave (CDW) correlations in untwinned YBCO6+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, but not for samples with x<0.44 that exhibit incommensurate spin-density-wave order, and in slightly overdoped samples with x=0.99. This suggests the presence of two proximate zero-temperature CDW critical points at doping pc1~0.08 and pc2~0.18. The CDW reflections are observed at incommensurate in-plane wave vectors (d_a, 0) and (0, d_b). Both decrease linearly with increasing doping, in agreement with recent reports on Bi-based high-Tc superconductors, but in sharp contrast to the behavior of the 214 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. 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. We discuss the relationship of these results to stripe order 214, the pseudogap phenomenon, superconducting fluctuations, and quantum oscillations.