0

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:

The functions available in my postgresql gui

(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?

  • 4
    You can't. An extension is a single unit (btw: gen_random_uuid() from pgcrypto is a lot faster than uuid_generate_v4) – a_horse_with_no_name Aug 27 '19 at 11:25
  • 2
    You can easily write your own function: see e.g. this answer or the other answer – a_horse_with_no_name Aug 27 '19 at 11:31
  • Thanks for the tip. I did expect the answer was going to be "you can't, but here's the closest way". – Ben S Aug 27 '19 at 11:36
  • Out of curiosity, what problem are you having with the other functions? If they're not being called, they're not going to use any online resources. – jmelesky Aug 27 '19 at 15:38
  • You can install extensions into a different schema, to take some of the clutter out of your default schema. You can either do one schema per extension, or just make one schema for all extensions you use. – jjanes Aug 27 '19 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.