I\'d like to change the column type from an int to a uuid. I am using the following statement
ALTER TABLE tableA ALTER COLUMN colA
WARNING: I've noticed some comments and answers that try to cast integers to a UUID4.
You must not cast or force-set uuid values. They must be generated using functions relating to RFC4122.
UUIDs must be randomly distributed or they will not work. You cannot cast or enter your own UUIDs as they will not be properly distributed. This can lead to bad actors guessing your sequencing or finding other artifacts or patterns in your UUIDs that will lead them to discover others.
Any answer that converts to char types and then to uuid may lead to these kinds problems.
Follow any answer here that refers to 'uuid_generate_v4'. Ignore ones that are casting or setting without using the formal functions.