Hello all,
I would like a generic way to generate an md5 hash for each row of a
table. Currently I do it thusly:
select id, md5(col_a || col_b || col_c || col_d) from mytable;
id | md5
------+----------------------------------
1 | 75acee3133f19d1a81ab2e7c1c32eb29
2 | 496f5e8bc945a922fcdd487e1ddde5c5
3 | ace10f4b1408d179da2e93267b300108
4 | bd029a826a98c21ec4c3661cc34657f8
5 | 4bacd2b0f34213a32f911ed5c1240c09
As you can see, I place each field inside the md5() function call.
This, however, requires that I know what the table fields are, and it is
not very robust (ie: boolean and any other column type that can't use
"||" concatenation fails). Is there a better, robust, or more generic
way to do this? I have tables with columns of type bytea, boolean,
binary, etc... all the difficult column types.
I would love something like this:
select id, md5(*) from mytable;
...which of course does not work.
Thanks for any ideas!
-Jon
--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
Jon Lapham <lapham@xxxxxxxxx> Rio de Janeiro, Brasil
Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------
---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend