PostgreSQL:将用户定义的函数从一个数据库复制/导入到另一个数据库 [英] PostgreSQL: Copy/import a user defined function from one database to another database

查看:72
本文介绍了PostgreSQL:将用户定义的函数从一个数据库复制/导入到另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似的问题,例如,但适用于PostgreSQL.我在Windows 10(x64)计算机上使用PostgreSQL 9.5.12(x64).我在数据库 my_db 中有一个函数(用 plpgsql 编写) my_func().是否可以将此功能导入/复制到postgres中的另一个数据库?

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?

推荐答案

在psql中, \ ef 命令将在编辑器中打开该函数,然后可以将其保存到文件中...不幸的是上次我检查时, psql 的Windows版本的用户界面非常粗糙.

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.

一个 pg_dump 也将包括所有函数定义.然后可以在编辑器中将其打开并复制功能.

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.

这篇关于PostgreSQL:将用户定义的函数从一个数据库复制/导入到另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆