I have a table with a uuid column, and some of the rows are missing the data. I need to insert data into this uuid column. The data is entered manually, so we are suffixing with other column data to differentiate, but it gives me an error.
UPDATE schema.table
SET uuid_column = CONCAT ('f7949f56-8840-5afa-8c6d-3b0f6e7f93e9', '-', id_column)
WHERE id_column = '1234';
Error: [42804] ERROR: column "uuid_column" is of type uuid but expression is of type text
Hint: You will need to rewrite or cast the expression.
Position: 45
I also tried
UPDATE schema.table
SET uuid_column = CONCAT ('f7949f56-8840-5afa-8c6d-3b0f6e7f93e9', '-', id_column)::uuid
WHERE id_column = '1234';
Error: [22P02] ERROR: invalid input syntax for uuid: "f7949f56-8840-5afa-8c6d-3b0f6e7f93e9-1234"
f7949f56-8840-5afa-8c6d-3b0f6e7f93e9is already a complete and valid UUID, you can't append anything to that value. What exactly is the problem you are trying to solve with that? If you want to generate a UUID, install the uuid-ossp extension and use e.g.uuid_generate_v4()uuidtovarcharbut that makes things just difficult elsewhere.texttobigintcolumn. It is not anymoreuuidas rfc4122 specifies it.