Forum Stats

  • 3,826,763 Users
  • 2,260,705 Discussions


How to insert unique UUID for table primary key column?

User_AS6XD Member Posts: 39 Red Ribbon

I have to load unique uuid(uuid for primary key column) for each row in my table. Please let me know how to generate unique uuid's and insert them while loading data into my table. Please share script for the same.I have attached table structure and sample data for better understanding, earlier for this table unique uuid's were generated in some api written in java, now i have to replicate uuid logic in oracle.


  • Niels Hecker
    Niels Hecker Member Posts: 28 Bronze Badge

    You can use the function SYS_GUID(). In your case to get values in the form of the provided test data you must use "lower( rawtohex( sys_guid()))". The function SYS_GUID() itself returns a value of data-type RAW(16).

    Attention: if you use the function in SQL statements you must specify the empty braces after the function.