database – 如何使用PostgreSQL中的特定表获取存储过程列表?
发布时间:2020-12-13 15:50:53 所属栏目:百科 来源:网络整理
导读:在PostgreSQL(9.3)中有一种简单的方法来获取使用特定表的存储过程列表吗? 我正在更改几个表,需要修复使用它们的存储过程. 解决方法 在其正文中包含文本“thetable”的函数. 查询返回函数名称,行号和包含’thetable’的行: select *from ( select proname,r
在PostgreSQL(9.3)中有一种简单的方法来获取使用特定表的存储过程列表吗?
我正在更改几个表,需要修复使用它们的存储过程. 解决方法
在其正文中包含文本“thetable”的函数.
查询返回函数名称,行号和包含’thetable’的行: select * from ( select proname,row_number() over (partition by proname) as line,textline from ( select proname,unnest(string_to_array(prosrc,chr(10))) textline from pg_proc p join pg_namespace n on n.oid = p.pronamespace where nspname = 'public' and prosrc ilike '%thetable%' ) lines ) x where textline ilike '%thetable%'; 具有与表相关联的任何参数或返回值的函数. 例如: create function f2(rec thetable)... create function f1() returns setof thetable... 此查询提供函数的名称,返回类型和参数类型: with rtype as ( select reltype from pg_class where relname = 'thetable') select distinct on (proname) proname,prorettype,proargtypes from pg_proc p join pg_namespace n on n.oid = p.pronamespace cross join rtype where nspname = 'public' and ( prorettype = reltype or reltype::text = any(string_to_array(proargtypes::text,' '))) 当然,您可以将查询合并为一个.我将它们用于不同的目的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |