2

I want to generate a v4 uuid in PostgreSQL using the extension uuid-ossp, so in psql I ran:

CREATE EXTENSION "uuid-ossp";

Then I ran SELECT uuid_generate_v1(); or SELECT uuid_generate_v4(); but I always get this error:

ERROR:  function uuid_generate_v1() does not exist
LINE 1: select uuid_generate_v1();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

So how can I solve this error?

2
  • 1
    What is the output of show search_path;?
    – CL.
    Aug 20, 2019 at 6:56
  • from postgresql.org/docs/9.4/uuid-ossp.html#AEN170626 Note: If you only need randomly-generated (version 4) UUIDs, consider using the gen_random_uuid() function from the pgcrypto module instead.
    – Jasen
    May 25, 2021 at 21:59

1 Answer 1

1

There are several possibilities:

  • you ran CREATE EXTENSION in a different database (postgres?)

  • you installed the extension in a schema that is not on the user's search_path.

Use

\dx "uuid-ossp"

in psql to see where the extension is installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.