postgresql的"函数"怎么导出脚本
展开全部
两种方法:
方法一:查询pg_proc:
osdba=# select prosrc from pg_proc where proname='get_username';
prosrc
--------------------------------------------------------
declare
ret text;
begin
SELECT name into ret from tang01 where id=userid;
return ret;
end;
(1 row)
方法二:调用pg_catalog.pg_get_functiondef函数:
osdba=# select pg_get_functiondef('get_username'::regproc);
pg_get_functiondef
----------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.get_username(userid integer)
RETURNS text
LANGUAGE plpgsql
AS $function$
declare
ret text;
begin
SELECT name into ret from tang01 where id=userid;
return ret;
end;
$function$
方法一:查询pg_proc:
osdba=# select prosrc from pg_proc where proname='get_username';
prosrc
--------------------------------------------------------
declare
ret text;
begin
SELECT name into ret from tang01 where id=userid;
return ret;
end;
(1 row)
方法二:调用pg_catalog.pg_get_functiondef函数:
osdba=# select pg_get_functiondef('get_username'::regproc);
pg_get_functiondef
----------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.get_username(userid integer)
RETURNS text
LANGUAGE plpgsql
AS $function$
declare
ret text;
begin
SELECT name into ret from tang01 where id=userid;
return ret;
end;
$function$
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询