1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgreSQLでトリガーの情報を取得する

Last updated at Posted at 2017-09-02

PostgreSQL 9.5にて確認済み

SELECT	 tg.event_object_table		-- テーブル名
		,tg.trigger_name			-- トリガー名
		,CASE pgtg.tgenabled
			WHEN 'O' THEN	'Enabled'
			WHEN 'D' THEN	'Disabled'
			WHEN 'R' THEN	'Replica'
			WHEN 'A' THEN	'Always'
			ELSE			NULL
			END	AS tgenabled
		,tg.event_manipulation		-- 発火動作
		,tg.action_timing			-- タイミング
		,tg.action_statement		-- Statement that is executed by the trigger
FROM	information_schema.triggers	AS tg		-- https://www.postgresql.org/docs/9.5/static/infoschema-triggers.html
	INNER JOIN pg_trigger			AS pgtg		-- https://www.postgresql.jp/document/9.5/html/catalog-pg-trigger.html
		ON (pgtg.tgname = tg.trigger_name)

ORDER BY tg.event_object_table
		,tg.trigger_name
		,tg.event_manipulation

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?