I need to calculate the checksum of some columns. The built-in function checksum is used to calculate the checksum in Microsoft SQL Server.
Is there any built-in function checksum in Oracle?
checksumoracle
I need to calculate the checksum of some columns. The built-in function checksum is used to calculate the checksum in Microsoft SQL Server.
Is there any built-in function checksum in Oracle?
Best Answer
You can use Oracle's STANDARD_HASH function.
You might do something like this:
and then calculate a SHA256 checksum:
and
MY_HASH_2 0xCC2E018AA6EB9612CCD027BBDCDC9B8C8D351789F14CAE4D688A876C18938235
This will tell you if your records are the same or different (well, to a very high probablity! :-) ).
With STANDARD_HASH, you get to choose your hashing algorithm. You might want to be careful about your choice - MD5 is much less processor intensive than SHA256. If security is not a major concern, you might want to use that instead? See the fidddle here for more.
See here for the excellent question, and here (same thread) for the excellent answer, both of which I (shamelessly!) lifted to answer this question. I felt that the thread and answer were both good enough to merit a place on dba.stackexchange!