Hashing a String to a Numeric Value in PostgreSQL

前端 未结 4 1358
情歌与酒
情歌与酒 2020-12-07 23:16

I need to Convert Strings stored in my Database to a Numeric value. Result can be Integer (preferred) or Bigint. This conversion is to be done at Database side in a PL/pgSQL

4条回答
  •  粉色の甜心
    2020-12-07 23:32

    You can create a md5 hash value without problems:

    select md5('hello, world');
    

    This returns a string with a hex number.

    Unfortunately there is no built-in function to convert hex to integer but as you are doing that in PL/pgSQL anyway, this might help:

    https://stackoverflow.com/a/8316731/330315

提交回复
热议问题