skip to Main Content

I installed PostgreSql and checked if extention ‘uuid-ossp’ was there.

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

And I checked the results with sql query.

SELECT * FROM pg_available_extensions;

enter image description here

However, the uuid_generate_v4() function cannot be used when creating a table.

CREATE TABLE my_table
(
  uuid UUID NOT NULL UNIQUE DEFAULT uuid_generate_v4()
);

Error message is below

SQL Error [42883]: ERROR: function uuid_generate_v4() does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.

I’m looking for a solution to this problem. and I confirmed that superuser is executable. How can I enable the user I created to run it?

2

Answers


  1. Chosen as BEST ANSWER

    After making the user a superuser and reconnecting, the uuid_generate_v4() function can be used.

    alter user myuser with superuser;
    
    After making the user a superuser and reconnecting, the uuid_generate_v4() function can be used.
    

    Is there any way to use it without making it a superuser?


  2. Maybe schema is not proper. Did you try to:

    CREATE TABLE public.my_table (
        id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search