We present a multiscale quantum-defect theory (QDT) for two identical atoms in a symmetric harmonic trap that combines the quantum-defect theory for the van der Waals interaction [B. Gao, Phys. Rev. A 64, 010701(R) (2001)] at short distances with a quantum-defect theory for the harmonic trapping potential at large distances. The theory provides a systematic understanding of two atoms in a trap, from deeply bound molecular states and states of different partial waves, to highly excited trap states. It shows, e.g., that a strong p wave pairing can lead to a lower energy state around the threshold than a s wave pairing.