在PostgreSQL中查找现有功能脚本的命令是什么? [英] What is the command to find script of a existing function in postgresql?

查看:92
本文介绍了在PostgreSQL中查找现有功能脚本的命令是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们使用sp_helptext [过程名称]在Sqlserver中获取SP脚本,因此我需要可用于从postgresql检索功能脚本的命令。

As we are using sp_helptext [procedure name] to get the SP script in Sqlserver, I need the command that i can use to retrieve a function script from postgresql.

请帮助...。

推荐答案

如果使用的是psql(命令行界面),则可以使用 \df + 如tobixen所说(手册中已明确记录)。

If you are using psql (the commandline interface) you can use \df+ as tobixen has already stated (and which is clearly documented in the manual).

如果需要从内部进行操作一个SQL查询,看看系统信息功能。您正在寻找 pg_get_functiondef()

If you need to do this from within a SQL query, take a look a the system information functions. You are looking for pg_get_functiondef()

select pg_get_functiondef(oid)
from pg_proc
where proname = 'your_function';

如果要处理具有不同数量参数的重载函数,则需要包括参数签名

If you are dealing with overloaded functions having a different number of parameters, you need to include the parameter signature into the name:

select pg_get_functiondef('public.foo(int)'::regprocedure);
select pg_get_functiondef('public.foo(int,int)'::regprocedure);

将检索函数 foo (一个版本带有一个int参数,另一个版本带有两个int参数)。

will retrieve the overloaded versions of the function foo (one version with a single int parameter, the other version with two int parameters).

这篇关于在PostgreSQL中查找现有功能脚本的命令是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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