skip to Main Content

I have a Postgres table with a field called user_uuid with type uuid. I also have a valid UUID value that I want to manually insert in that row, but I can’t seem to find a way to manually create this.

This is an example of the statement I’m trying to execute:

insert into my_table (account_number, type,  user_uuid) values ('1252', 'residential', 'dOfa6513-aOfd-4e78-9941-724b22804e9f');

I’ve tried appending ::UUID which I read somewhere might work, and to enclose the UUID text value inside curly brackets, instead of single quotes. None of that has worked, and the docs are not helpful either. The error I get is the following:

 invalid input syntax for type uuid: 'dOfa6513-aOfd-4e78-9941-724b22804e9f'

2

Answers


  1. The UUID you’re trying to insert is not a valid UUID.

    You can check the validity here https://www.freecodeformat.com/validate-uuid-guid.php

    This is one example of a valid UUID: a8adfa00-6680-49b3-bf94-caa8c3f1d823,
    can try pass this into your insert query and check if ok.

    Login or Signup to reply.
  2. There are 2 occurrences of the letter O in your uuid.
    It should have been the digit 0 instead (zero) to make it a proper hexadecimal string: d0fa6513-a0fd-4e78-9941-724b22804e9f

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search