Andrey
Andrey

Reputation: 1759

uuid_generate_v4 extension unavailable from command line

I have very strange behavior of select uuid_generate_v4 (); function

When I run select from pgadmin its working select uuid_generate_v4 (); and return me UUID enter image description here

When I run it from the command line its trowing error

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

Have no idea why its happening and how to fix it.

Upvotes: 0

Views: 3168

Answers (1)

Andrey
Andrey

Reputation: 1759

Ok, the problem is I was running select in pgAdmin from the public schema, and in the command line, I run it from a specific schema by setting it

set search_path to my_schema;

The fix is to alter the extension and set it to proper schema

ALTER EXTENSION "uuid-ossp" SET SCHEMA my_schema;

Upvotes: 2

Related Questions