How do you create a random string that’s suitable for a session ID in PostgreSQL?

You can fix your initial attempt like this:

SELECT md5(random()::text);

Much simpler than some of the other suggestions. 🙂

Leave a Comment