I am trying to migrate PostgreSQL to Oracle database as per client requirements. In PostgreSQL I have used uuid data type and the values of the column are generated automatically using the uuid_generate_v4() function. I want to know the alternative in Oracle. I went through the documentation but its not clear if I can create a function and use it to generate a column value. This post was little helpful but don't understand how to use this function in create or alter statement How to generate a version 4 (random) UUID on Oracle?
Asked
Active
Viewed 13 times
0
-
See Kirill's answer in https://stackoverflow.com/questions/13951576/how-to-generate-a-version-4-random-uuid-on-oracle. This is what I have been using successfully for several months. – Thorsten Kettner Jan 28 '22 at 14:13
-
You need SQL functions rather than user-defined functions in the `DEFAULT` clause [db<>fiddle](https://dbfiddle.uk/?rdbms=oracle_21&fiddle=e39169998f6929cddffc04223fc7be99). – MT0 Jan 28 '22 at 14:46
-
You can write a before-insert trigger to call a UUID function and assign the value. – Thorsten Kettner Jan 28 '22 at 15:33