0

I have a similar question like this, but for PostgreSQL. I am using PostgreSQL 9.5.12 (x64) on my Windows 10 (x64) machine. I have a function (written in plpgsql) my_func() in database my_db. Is it possible to import/copy this function to another database in postgres?

0

2 Answers 2

4

In psql the \ef command will open the function in an editor you can then save it to a file... unfortunately the UI of the windows version of psql was pretty cruddy last time I checked.

a pg_dump of the database with --schema-only will also include all function definitions. you can then open it in an editor and copy the functions.

Sign up to request clarification or add additional context in comments.

Comments

3

You could use pg_get_functiondef to get function definition as follows:

SELECT pg_get_functiondef(oid) AS definition FROM pg_proc WHERE proname = 'my_func';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.