How to Compute the Oracle SQL_ID
The Oracle SQL_ID is computed using the following algorithm
- append a
0x00
byte to the native SQL query - compute the MD5 hash (it’s unclear whether UTF-8 or the database encoding should be used)
- create a 64 bit long value out last two 32 integer values of the hash using big endian order
- convert to Base32, 5 bits at a time starting with the most significant bit, using the alphabet
0123456789abcdfghjkmnpqrstuvwxyz
The native SQL query can be accessed in Java either using Connection#nativeSQL or using OracleDatabaseException#getSql.
For a Java implementation check out marschall/sqlid