How can I generate scripts for all functions in pgAdmin?
-
16-10-2019 - |
Question
I am using pgAdmin version 1.10.5, and I've checked the properties and menu options but couldn't find anything on the subject.
For example, I just want to generate a script that includes the functions that I've created for my schema. If I right click on the database node and choose backup it has an option to create a script for the schema, but it creates all the objects. And I want only the functions.
Solution
There is no explicit switch to just export functions. I did some research since it's a nice question.
I can think of some ways to do this:
- Using pgAdmin, you get the code that makes up the function when you right-click on the function, and choose "Scripts->Ceate". You could copy&paste the contens and put it into a sql file that you can import like any other file
Exporting the schema and importing only the functions you need (tedious, since you need the exact name and arguments of the function. This blog post explains it:
pg_dump -Fc -s | pg_restore -P 'funcname(args)'
Do some querying in the schema/pg_proc and export the results. This could be another function that just exports the functions...