How to generate a random character string of length 8 in Netezza

netezzarandomstring

I am trying to generate a random character string of length 8 in Netezza, any suggestions?

Best Answer

If you're happy with a hex string, you could do:

select to_hex(round(random() * 2^32 - 1)::BIGINT) AS randchars;

You could also write a user-defined function if you want a very specific type of string. For this, you would need SSH access on the Netezza appliance and some basic knowledge of C++. It may be simpler for you to write these functions in Lua if you're not comfortable with C++ or if you don't have an account on the appliance, but this requires Netezza Analytics to be installed.