gpt4 book ai didi

sql - PostgreSQL:如何列出访问特定表的所有存储函数

转载 作者:行者123 更新时间:2023-11-29 13:27:43 25 4
gpt4 key购买 nike

对于给定的表,我如何找到使用该表中任何字段的所有函数?说我有学生表 (studentid, studentname)

我想要一个使用学生的 studentid 和 studentname 的所有函数和触发器的列表。

我的问题类似于 List stored functions that reference a table in PostgreSQL但是那里给出的代码不起作用... n.nspname 是在与 Schema not to table 相关的条件下给出的。

最佳答案

也许不是很精确,但这个查询应该有效。

SELECT routine_schema, routine_name 
FROM information_schema.routines
WHERE routine_definition ~ 'student'
AND routine_definition ~ 'studentid'
AND routine_definition ~ 'studentname';

根据您编写程序的方式,您能否应用更精确的正则表达式。例如,如果您总是以这种形式编写表和列:table.column 您可以使用这个表达式吗:

... WHERE routine_definition ~ 'student\.studentid' 
AND routine_definition ~ 'student\.studentname'

关于sql - PostgreSQL:如何列出访问特定表的所有存储函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30614702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com