sqlpostgresqlhashcode

Finding the hash value of a row in postgresql


Is there a way to get the hash code of a row in postgresql?

I need to export some data only if there is some changes in the data after the last export, the last exported data rows can be stored in a table, the when the again I need to export the data I can get the hash values of all the data and export only those rows who has a different hash value than the last export.

Is it possible to achieve using postgresql?

Thank you


Solution

  • Cast the row to text and use md5 to make a hash:

    SELECT
        md5(CAST((f.*)AS text))
    FROM
        foo f;