The metric space \(\mathcal {H}_{q}(n,w)\) is the set of all words of length n with weight w over the alphabet \(\mathbb {Z}_{q}\) , under the Hamming distance metric. A q-ary constant-weight code, as a nonempty subset of \(\mathcal {H}_{q}(n,w)\) , has always been a fundamental topic in coding theory. This paper investigates the tiling problem of \(\mathcal {H}_{q}(n,w)\) with optimal \((n,d,w)_{q}\) -codes, simply denoted by \(\textrm{TOC}_{q}(n,d,w)\) , meaning a partition of \(\mathcal {H}_{q}(n,w)\) into mutually disjoint optimal q-ary constant-weight codes with distance d. When the distance d is odd, we investigate large sets of generalized Steiner systems. When d is even, we define large sets of generalized maximum H-packings. We present several general construction approaches for generating \(\textrm{TOC}_{q}(n,d,w)\) s via t-resolvable Steiner systems and almost-regular edge-colorings of complete hypergraphs. For the cases \(d=2\) and \(d=2w\) , we completely resolve the existence problem of \(\textrm{TOC}_{q}(n,d,w)\) s for all parameters q, n and w. Particularly, we pay attention to tilings for weight three. For binary case and weight three, the existence problem of \(\textrm{TOC}_{2}(n,d,3)\) s is totally resolved. For specific alphabet size \(q\ge 3\) , we obtain many infinite families of \(\textrm{TOC}_{q}(n,d,3)\) s for distances \(d=3,4,5\) .