Create Unique Identifier on SAP HANA Database using SQLScript
SQL programmers frequently require to generate or create unique string values like unique identifiers also on SAP HANA database using SQLScript. It is possible to create a unique identifier using SQLScript functions NEWUID or SYSUUID. In this HANA database tutorial I want to show examples how SQL developers can use NEWUID function or SYSUUID function to create unique string values.
SAP HANA SQLScript NEWUID Function
SQLScript NEWUID function creates a unique identifier within a specific SAP HANA database. The return type of HANA database NEWUID() function is varbinary(16). SQLScript programmers can use NEWUID SQL function for obtaining unique string which includes alphanumeric (aka alphameric) characters in it which cannot be generated once more on current HANA database using SQLScript function NEWUID.
Please check following SQL codes how you can use NEWUID output.
It is also possible to read unique identifier generated with NEWUID() function and store into a variable and then use it as follows in SQLScript codes.
SAP HANA SQLScript SYSUUID Function
Another option for database developer is to use SYSUUID function to generate unique identifier which is universally unique in that HANA instance. This is a broader uniqueness for the created unique identifier with SYSUUID function than NEWUID function which provides uniqueness in a specific database.
SYSUUID name stands for universally unique identifier.
Here is a sample SQL code block where I called SYSUUID function twice. It is interesting to see the difference and mostly the similarity between generated unique identifier values.