Thursday, 28 May 2020

Update Random Value in Column Using PostgreSQL


Add Random Value Column In PostgreSQL Table
    Add Random Value Column In Existing Table
Create Random uuid Without postgresql extension

Test Query :

SELECT uuid_in(md5(random()::text || clock_timestamp()::text)::cstring);

Update Example :

update product
set random_uuid =
uuid_in(md5(random():: text || clock_timestamp():: text):: cstring);

Check IS random_uuid in Uniq Using :

SELECT (product.random_uuid):: text, count(*)
FROM product
GROUP BY product.random_uuid
HAVING count(*) > 1


No comments:

Post a Comment