如何获取与PostgreSQL中的视图或表相关联的触发器 [英] How to get the trigger(s) associated with a view or a table in PostgreSQL
问题描述
我有一个要求,我必须得到与给定表/视图相关联的触发器列表。
任何人都可以帮助我找到PostgreSQL中的表的触发器?
I have one requirement that I have to get the list of triggers associated to the given table/view.
Can anyone help me to find the triggers for a table in PostgreSQL?
推荐答案
information_schema.triggers
(除了慢)是每个文档:
视图触发器包含在当前用户拥有的表和视图上的当前
数据库中定义的所有触发器,或者具有除SELECT
之外的一些
特权。
The view triggers contains all triggers defined in the current database on tables and views that the current user owns or has some privilege other than
SELECT
on.
这意味着你只能看到具有适当权限的触发器。
Meaning, you only get to see triggers you have appropriate privileges on.
To see all triggers for a table, look in the system catalog pg_trigger
SELECT tgname
FROM pg_trigger
WHERE tgrelid = 'myschema.mytbl'::regclass; -- optionally schema-qualified
适用于表和视图。 >
或者您可以使用GUI来显示对象浏览器中表节点下的列表pgAdmin。
Works for tables and views.
Or you could use a GUI like pgAdmin that displays the list under the table node in the object browser.
这篇关于如何获取与PostgreSQL中的视图或表相关联的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!