As others have said, DNS is distributed/hierarchical/delegated. But if you wanted to try...
First, grab the root zone file which points to all the TLD nameservers: https://www.internic.net/domain/root.zone
Next, get zone files for the TLDs themselves. Not every TLD makes that freely or easily available, but https://github.com/jschauma/tld-zoneinfo is an excellent resource.
The author of the above repo runs https://netmeister.org/tldstats/ which will give you an idea of scale; they're able to get 98.89% of all TLDs.
(Correction: zone files for ccTLDs are mostly unavailable. That 98.89% is only domain count coverage, not zone file coverage.)