Updating rows of a table with a UUID column

You can update a UUID column whether or not it is GENERATED BY DEFAULT. You can use the function random_uuid to generate a random UUID value to update the column. The function random_uuid returns a randomly generated UUID, as a string of 36 characters.

Example : Updating a UUID Column defined without GENERATED BY DEFAULT clause

CREATE TABLE myTable (tabId INTEGER, id STRING AS UUID, PRIMARY KEY (tabId));
Statement completed successfully

INSERT INTO myTable values(1,"a81bc81b-dead-4e5d-abff-90865d1e13b1");
Statement completed successfully

UPDATE myTable set id=random_uuid() where tabId=1;
Statement completed successfully

The above example shows how you can update a UUID column which is NOT GENERATED BY DEFAULT. To do so, the UUID column should not be part of the primary key, as NoSQL Primary key values are immutable. In the above example, tabId is the Primary key. So you can update the UUID column using the random_uuid function.