We consider $q$-ary (linear and nonlinear) block codes with exactly two distances: $d$ and $d+delta$. Several combinatorial constructions of optimal such codes are given. In the linear (but not necessary projective) case, we prove that under certain conditions the existence of such linear $2$-weight code with $delta > 1$ implies the following equality of great common divisors: $(d,q) = (delta,q)$. Upper bounds for the maximum cardinality of such codes are derived by linear programming and from few-distance spherical codes. Tables of lower and upper bounds for small $q = 2,3,4$ and $q,n < 50$ are presented.