Opinions differ of course, but I personally would never generate any kind of random identity.
Instead I've always used deterministic methods, such as concatenating other fields from the SELECT row result to construct a unique identity from that.
(This also means being sure to use DISTINCT or similar in the SELECT query to only get unique combinations of values used in that concatenation.)