Just for the record: have a look at frappe/frappe/model/naming.py.
Look out for
def make_autoname(key="", doctype="", doc=""):
Here you will find
if key == "hash":
return frappe.generate_hash(doctype, 10)
which will lead you ultimately to
digest = hashlib.sha224(((txt or "") + repr(time.time()) + repr(random_string(8))).encode()).hexdigest()
txt will contain the name of your doctype. digest will then be shortened to the first 10 chars and used as “name”.
So to generate your own names to use in SQL and are not willing to duplicate frappes behaviour:
you could create your own sequence and use the resulting numbers as names
These will not collide with the names generated by frappe.
Didn’t test it, no gurantees.