dB is not a measurement unit like ,for instance, volts are. It is a ratio between two quantities of the same type.
The last equation is correct and can be used to represent a gain or a loss, in dB. In fact if you have a voltage gain of, lat me say, 1000 means the ouptut voltage Vo will be 1000*Vi (input voltage). Using the last equation we will have GdB = 20*log10(Vo/Vi) = 20*log10(1000*Vi/Vi) = 20*log10(1000) = 60 dB. Vo and Vi must be of the same type: both peak-to-peak or RMS or peak.
It could be you want, instead, to convert your voltage to dBV that is a logarithmic measurement unit that has a reference of 1Vrms. In this case, first of all you need to convert from peak-to-peak to RMS. In case of sinusoidal signal you just have to divide by 2*sqrt(2), then apply the dB formula using Vi = 1V:
dBV = 20*log10[ Vpp/(2*sqrt(2) ]
Or could also that you want to calculate the power in a logarithmic scale. In this case you also need to know the resistance (R) across which the voltage is applied. Also in this case we need the RMS voltage, that is Vrms = Vpp/(2*sqrt(2))
The power is given by: P = (Vrms)²/R. A logarithmic popular measurement unit for power is dBm (that means referred to 1 mW). The formula is:
dBm = 10*log10(P/1mW) = 10*log10[(Vrms)²/(0.001*R)] = 10*log10[(Vpp)²/0.008*R] (is your eq. 2, using the logarithm properties)