In PostgreSQL, I am loading the uuid-ossp
extension so I can use the function that creates random UUIDs in my queries:
create extension if not exists "uuid-ossp";
However, as well as making available the one function I need (uuid_generate_v4
), it also makes nine other functions that I don't need available:
(Using \df
on the command-line shows the same data). Is there any way I can, using programming terms, "import" just the uuid_generate_v4
function into my "namespace", without importing the ones I'm not using?
Best Answer
In PostgreSQL 13, the
gen_random_uuid()
function is now available globally, with no need to use the pgcrypto or uuid-ossp extensions.It is still not possible to only load one function from an extension, but for this common case, it's possible to generate random UUIDs without having all those other UUID-related functions in scope.