Re: Regarding copy of function from one db to another db

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Rohit Dwivedi <dwivedir092@gmail.com>
Cc: "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Date: 2017-06-15T15:42:16Z
Lists: pgsql-bugs
On Thu, Jun 15, 2017 at 3:43 AM, Rohit Dwivedi <dwivedir092@gmail.com>
wrote:

> Hello sir,
>             if we need to copy all the functions of database to another
> database then how  we can implement it other then copy paste and run
> it...Because there are total 153 functions in our database.
>
>
​General questions should be directed to the pgsql-general@postgresql.org
mailing list.

The tools provided to do what you want are pg_dump and pg_restore
(specifically note the --list and --list-file options to pg_restore).  You
will need to manually edit the list file to include only the functions as
there is no object type filter capability (well, I now see there is a
--function argument to pg_restore but I'm unsure about whether it take
wildcards.  You will probably want to try it).  You can restrict the dump
to schema only if you indeed only care about functions.

David J.