7

It is possible to move a table from one schema to another:

ALTER TABLE my_table SET SCHEMA different_schema;

However, I cannot find the equivalent feature for moving a function from one schema to another.

How can I do this?

(version 8.3+)

pstanton
  • 35,033
  • 24
  • 126
  • 168
  • 1
    preferably without a drop / create – pstanton Oct 21 '10 at 20:55
  • I ran into this helpful post recently, [but needed to move all the functions at once](http://stackoverflow.com/questions/19148055/change-schema-of-multiple-postgresql-functions-in-one-operation). Perhaps this can help someone in the same situation. – Michael M Oct 02 '13 at 22:51

1 Answers1

13

Taken from the docs:

ALTER FUNCTION name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
SET SCHEMA new_schema
Frank Bollack
  • 24,478
  • 5
  • 49
  • 58
  • 1
    Note that if the function calls itself, the self-reference in the function body is not updated to the new schema. – AdamAL Jun 19 '19 at 14:59