Search code examples
postgresqlpgadmin

Can't add item in Postgres using pgAdmin


I am trying to use Postgres with Django application. I am using pgAdmin to manage Postgres database. But I can't add new item to database using pgAdmin manually. Once I typed data manually and clicked the save button, I got

ERROR:  invalid input syntax for type uuid: "111"
LINE 3: '111'::uuid, 'asdfasdfdasf'::character varying)
        ^

Schema is just simple. Just id and name in the table. Please help me to fix the issue.

Thank you.


Solution

  • Try to add a default auto-generated value for your id field with the following commands:

    CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
    
     ALTER TABLE public.table_name
      ALTER COLUMN "id" SET DEFAULT uuid_generate_v4();
    

    After that, you need to populate only the name column.