0

Bit of an odd question, but tldr, I need an algorithm that will generate a unique fixed length hash that doesn't output any numbers. Is this even possible?

The names of my tables can sometimes be way too long (they are generated based on parameters and can exceed the 63 character limit enforced by PostgreSQL). Thus, I need a way too shorten the names of those tables while avoiding as much collision as possible. And the names shouldn't include any numbers.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
A.J
  • 315
  • 4
  • 17
  • Why not numbers? `SELECT substr('long_name', 1, 20) || abs(hashtext('long_name'));` will yield a standard conforming identifier if `long_name` is one. – Laurenz Albe Feb 08 '22 at 20:45
  • *...generate a unique fixed length hash...* A hash of what? Of the original possibly too long table name? How many distinct inputs might there be over the life of the project? Are you willing to live with a small but non-zero probability of a collision? – President James K. Polk Feb 08 '22 at 21:18

0 Answers0