Altered Scale

The altered scale is a common scale for creating tension over dominant chords. It includes all of the "spicy" notes that push towards the resolving tonic chord, including the root, 9, 9, 3, 5 or 11, 13, and 7 of the chord.

You can think of the altered scale as being built off of the 7th mode of the melodic minor scale; for example, if you play a melodic minor scale starting on the 7th scale degree, you are playing the altered scale.

In context, the altered scale for G7 is comes from A melodic minor (G is the 7th scale degree).